Basic question, details in the entry.

Sorry that I couldn’t find a proper subject to introduce my problem but here it goes:

I have two different parameters f(t) and d(i) that I want to put into the same equation.

i is the index of customers and t is the index of the time periods.

d(i) puts which customer wants their demand to be covered at which time period. For example, d(2)=3 is the customer with index 2’s demand must be covered at the time period with index number 3.

f(t) is the number of vehicles used in period t. f(2)=3 implies that 3 vehicles must be used in period 2 to cover the exact total demand within that period.

s(i) is the demand of the customer with the index number i. Say that s(2)=5

The model must cover all the demands exactly at the exact periods. To do so, I made an equation which is SUM(i,s(i)) = f(d(i)). (Each unit of demand requires one vehicle to be covered.)
The model thus should take into account all the customers and spend vehicles according to their demand periods. For instance, for the customer with index number 2 and with the information d(2)=3, it should increase f(d(i))=f(d(2))=f(3) by 5. Note that s(2)=5.

So far so good yet GAMS does not accept such syntax. I cannot put d(i) into the parameter f(t). The question is therefore how to tackle this problem. This may be done by modifying the equation or some of the parameters, I do not know. Thanks in advance for any information on how to put this into the GAMS code.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Yakup,

Funny that you couldn’t find the right subject for your question. I can’t think of one either, or I would first google the subject and perhaps find an answer. It’s a good question, one that comes up periodically.

Essentially, you want to store a time index in d(i), so that the syntax f(d(i)) makes sense (assuming f(t) is indexed over time t). The way you’re going about it would be the usual way in C# or Java, etc., but the GAMS way is different. I would create a set it(i,t) with entries exactly when customer i must satisfy a demand at period t. Note that you could have multiple time entries for a given customer, i.e. sum{it(i,t), 1} > 1 for a given i, or the sum could be exactly one, or zero. It’s up to you how you set it(i,t).

I don’t think your equation SUM(i,s(i)) = f(d(i)) is quite right: you sum over i on the left but i is given or controlled on the right. Perhaps you mean this:

equation dem(i); dem(i) … s(i) =E= sum{it(i,t), d(t)}.

HTH,

-Steve


On Thu, Jul 3, 2014 at 4:40 AM, Yakup Koca wrote:

Sorry that I couldn’t find a proper subject to introduce my problem but here it goes:

I have two different parameters f(t) and d(i) that I want to put into the same equation.

i is the index of customers and t is the index of the time periods.

d(i) puts which customer wants their demand to be covered at which time period. For example, d(2)=3 is the customer with index 2’s demand must be covered at the time period with index number 3.

f(t) is the number of vehicles used in period t. f(2)=3 implies that 3 vehicles must be used in period 2 to cover the exact total demand within that period.

s(i) is the demand of the customer with the index number i. Say that s(2)=5

The model must cover all the demands exactly at the exact periods. To do so, I made an equation which is SUM(i,s(i)) = f(d(i)). (Each unit of demand requires one vehicle to be covered.)
The model thus should take into account all the customers and spend vehicles according to their demand periods. For instance, for the customer with index number 2 and with the information d(2)=3, it should increase f(d(i))=f(d(2))=f(3) by 5. Note that s(2)=5.

So far so good yet GAMS does not accept such syntax. I cannot put d(i) into the parameter f(t). The question is therefore how to tackle this problem. This may be done by modifying the equation or some of the parameters, I do not know. Thanks in advance for any information on how to put this into the GAMS code.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.



\

Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com

@steven

First of all, thanks for the reply. I now understand that I should “set” up a table. I am still trying to eliminate the errors but I have yet to do so. I created a table which is attached below. I changed my equation as:

satisfy(t)… SUM[(t),it(i,t)] =E= f(t)*4;

According to this, I want model to sum up all the it(i,t) values for each t value and equalise it to f(t)*4. Error is giving stating that the set is under control already for this particular equation. Here I am also attaching a copy of the gams file which may come in handy if I lack of wit.

Thanks and it was nice to hear from a GAMS employee!


qtablegams.png

My bad that I forgot to attach the GAMS file. You can find it attached to this post.


question.gms (1.14 KB)

I solved the problem by setting up a table thanks to Steven’s advice. Not having managed to force integer values on some values on LP solver yet this is not the concern of this topic. For those who may wonder how I tackled this actually a simple problem, I am attaching the last version of the fileç Note that the coding may not be very comprehensible.


question.gms (1.14 KB)