GAMS Help Needed

I’m a new GAMS user. I am trying to model and solve a problem using
binary variables.

In the problem I have two sets:

set
t time periods /t1t7/
l location /L1
L5/ ;

Currently, I do not have an objective function and I am just trying to
satisfy the constraints of my problem. I have a simplifed case of my
problem working.

Simplified case equations and constraints:

  • I have a binary variable x with 35 entries
    binary variable x(t,l)

  • “Equation1” Solves for the supply at time period for each location
    (L1, L2, L3, L4, and L5). The supply depends on the binary variable x
    (t,l). For example:
    x(t1,L1) = 1, then the supply value would INCREASE
    x(t1,L1) = 0, then the supply value would DECREASE

  • “Equation2” The sum of all the binary variables x(t,l) over a time
    period must equal 1 (only one location can have increasing supply
    during a given time period). Example:
    equation2(t) … sum(l,x(t,l)) =e= 1 ;

  • “Equation3” Provides the upper limit of the supply value that can be
    reached at each location.

  • “Equation4” Provides the lower limit of the supply value that can be
    reached at each location.

This simplified case solves correctly (satisfies all constraints).

Current problem:
My problem is that currently (in the simplified case), the binary
variable can move to any location from one time period to the next.
So, if the supply gets too low at location 5 (L5), the binary variable
can jump from any location to L5 (example, from L1 during time period
t4 to L5 during time period t5).

What I need to tell GAMS is that the binary variable can only move 1
spot from time period to time period. Example:

At t1, x(t1,‘L1’) = 1 (so the binary variable is at L1).
The supply value is low at L5.
But the binary variable can only move in the following manner:
t1 → x(t1,‘L1’) = 1
t2 → x(t2,‘L2’) = 1
t3 → x(t3,‘L3’) = 1
t4 → x(t4,‘L4’) = 1
t5 → x(t5,‘L5’) = 1 (finally arrives at L5)

Also, the binary variable can’t move from L1 to L5 (imagine the
locations are in a line, unable to wrap around).

Can anyone provide an idea (or similar example problem implementation,
if possible) on how to model this in GAMS? I tried the following:

m1(t)((ord(t) lt card(t)) and (x(t,'b1') eq 1)) .. x(t+1,'L1') + x(t +1,'L2') =e= 1 ; m2(t)(ord(t) lt card(t) and x(t,‘b2’) = 1) … x(t+1,‘L2’) + x(t
+1,‘L1’) + x(t+1,‘L3’) =e= 1 ;
m3(t)(ord(t) lt card(t) and x(t,'b3') = 1) .. x(t+1,'L3') + x(t +1,'L2') + x(t+1,'L4') =e= 1 ; m4(t)(ord(t) lt card(t) and x(t,‘b4’) = 1) … x(t+1,‘L4’) + x(t
+1,‘L3’) + x(t+1,‘L5’) =e= 1 ;
m5(t)$(ord(t) lt card(t) and x(t,‘b5’) = 1) … x(t+1,‘L5’) + x(t
+1,‘L4’) =e= 1 ;

But I got the following error from GLPK (using mip):
**** The following MIP errors were detected in model first:
**** 57 equation m1 … VAR operands relational or boolean
**** 57 equation m2 … VAR operands relational or boolean
**** 57 equation m3 … VAR operands relational or boolean
**** 57 equation m4 … VAR operands relational or boolean
**** 57 equation m5 … VAR operands relational or boolean

I don’t understand these error messages…

In summary:
I would appreciate any help (examples, books, etc.) on how to
constrain the movement on the binary variable to the position that is
either 1) the same (L2 to L2 is legal) or 2) adjacent (L2 can only
move to L1 or L3, if not staying at L2). I am stuck and getting
frustrated. Thank you!

Francis

–~–~---------~–~----~------------~-------~–~----~
To post to this group, send email to gamsworld@googlegroups.com
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en
-~----------~----~----~----~------~----~------~–~—

\

dear Gazurt
you need to model your problem at first and then think about coding you problem in gams.
fortunately, your problem is an famous one and you can find its mathematical model in every modelling book(just check this book : Model Building by H.Paul Williams).


On Tue, Jun 7, 2011 at 3:50 AM, Gazurt wrote:

Hello everyone,
I’ve got a term project that includes one question of linear
programming and its biggest part has to be done by using GAMS. I’m a
new learner of this program and have problems while trying to do it so
I decided to ask you. It’s really important for me to pass the lecture
by doing this homework; so I need your help to solve it and how to put
it in GAMS.

A food is manufactured by refining raw oils and blending them
together.
The raw oils come in two categories:

Vegetable oils: Veg1 and Veg2
Non-­‐Vegetable oils: Oil1, Oil2, Oil3.
Each oil may be purchased for immediate delivery (January) or
bought on the futures market for delivery in subsequent
month. Prices now and in the futures market are given below in ($/
ton):

Veg1 Veg2 Oil1 Oil2 Oil3
January 110 120 130 110 115
February 130 130 110 90 115
March 110 140 130 100 95
April 120 110 120 120 125
May 100 120 150 110 105
June 90 100 140 80 135

The final product sells at $150 per ton.

Vegetable oils and non-­‐vegetable oils require different production
lines for refining. In any month it is not possible to refine more
than 200 tons of vegetable oils and more than 250 tons of non-­‐
vegetable oils. There is no loss of weight in the refining process and
the cost of refining may be ignored.

It is possible to store up to 1000 tons of each raw oil for use
later. The cost of storage for vegetable and non-­‐vegetable oil is $5
per ton per month. The final product cannot be stored nor can refined
oils be stored.

There is a technological restriction of hardness on the final
product. In the units in which hardness is measured, this must lie
between 3 and 6. It is assumed that hardness blends linearly and that
the hardness of the raw oils are:

Veg1=8.8
Veg2=6.1
Oil1=2.0
Oil2=4.2
Oil3=5.0

What buying and manufacturing policy the company pursue in order to
maximize profit? At present, there is 500 tons of each type of raw
oil in storage. It is required that these stocks will also exist at
the end of June.

1.) Model this problem by using LP.
2.) Write the model in a Word file.
3.) Write the Model by using Gams.
4.) Solve the model by using Gams.

\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

dear babak,

I appreciate your help and I could find some closest examples for my
model and started modelling it. But it’s still hard to put it in gams
for me so I need your full help to do it in gams. If you have the
solution for me or direct link to be demonstrated, it will be really
helpful for me.

\

Gazurt,

Please do not use this form to cheat on your homework assignment.
.



Gazurt
Sent by: gamsworld@googlegroups.com
06/07/2011 06:39 AM
Please respond to
gamsworld@googlegroups.com


To
gamsworld
cc

Subject
Re: GAMS Help Needed






dear babak,

I appreciate your help and I could find some closest examples for my
model and started modelling it. But it’s still hard to put it in gams
for me so I need your full help to do it in gams. If you have the
solution for me or direct link to be demonstrated, it will be really
helpful for me.

\

dear Gazurt

this group is not to teach you how to use gams, it’s for problems that gams user may have in coding. so you need to have a look on gams user guide( just see how it solve a transportation problem), you can learn so much from it. then try to code your problem, where ever you have problem in detail, you can express it in this group and be sure that you will get your answer.

bests

On Tue, Jun 7, 2011 at 3:17 PM, Jon Lee wrote:

Gazurt,

Please do not use this form to cheat on your homework assignment.
.



Gazurt
Sent by: gamsworld@googlegroups.com
06/07/2011 06:39 AM
Please respond to
gamsworld@googlegroups.com


To
gamsworld
cc

Subject
Re: GAMS Help Needed






dear babak,

I appreciate your help and I could find some closest examples for my
model and started modelling it. But it’s still hard to put it in gams
for me so I need your full help to do it in gams. If you have the
solution for me or direct link to be demonstrated, it will be really
helpful for me.


“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.


\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Babak Saleck Pay
M.Sc
Socio-Economic System Engineering
Group of Industrial Engineering
University of Tehran
Tehran,Iran


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.