Need assistance with types of variables
Posted: Mon Jul 09, 2018 5:19 am
Dear sir or madam,
I'm trying to learn by myself some basic procedures in GAMS and I would like to ask for some help regarding the following issue: I'm trying to run an integer LP using the code below, but I have difficulties when trying to declare my variable x1 as an "integer variable" and x2 as an "positive variable", I literally have no idea what would be te correct way to declare the variables.
Please help me to replace the "<I do no know what to write here>" lines with the correct code.
It is easy when I have to use only one type of variables, for example:
When I have to use only continuous variables, I write:
When I have to use only discrete variables, I write:
My problem is that I do not what to write in the cases where I have to use a mixture of both continuous and discrete variables.
PD: I know an easier way to do this is using the following code:
But I really want to make the first one work.
Thanks & Regards
I'm trying to learn by myself some basic procedures in GAMS and I would like to ask for some help regarding the following issue: I'm trying to run an integer LP using the code below, but I have difficulties when trying to declare my variable x1 as an "integer variable" and x2 as an "positive variable", I literally have no idea what would be te correct way to declare the variables.
Please help me to replace the "<I do no know what to write here>" lines with the correct code.
Code: Select all
$ontext
Min 55*x1+x2
st 13*x1+0.09*x2 =g= 250
33*x1-0.4*x2 =l= 0
55*x1 =l= 750
x1,x2 =g= 0
x1 = positive integer (Z+)
$offtext
sets
a /a1*a2/
b /b1*b3/;
parameters
c(a) /a1=55,a2=1/
d(b) /b1=-250,b2=0,b3=750/ ;
table t(b,a)
a1 a2
b1 -13 -0.09
b2 33 -0.4
b3 55 0 ;
variables
z;
positive variables
<I do no know what to write here>
integer variable
<I do no know what to write here>
equations
obj
r ;
obj.. z=e=sum(a,c(a)*x(a)) ;
r(b).. sum(a,t(b,a)*x(a)) =l= d(b);
model model1 /all/;
solve model1 using mip minizing z;
display z.l;
When I have to use only continuous variables, I write:
Code: Select all
positive variables
x(a);
Code: Select all
integer variable
x(a);
Code: Select all
positive variables
<I do no know what to write here>
integer variable
<I do no know what to write here>
Code: Select all
$ontext
Min 55*x1+x2
st 13*x1+0.09*x2 =g= 250
33*x1-0.4*x2 =l= 0
55*x1 =l= 750
x1,x2 =g= 0
x1 = positive integer (Z+)
$offtext
variables
z
positive variables
x2;
integer variables
x1;
equations
obj,r1,r2,r3;
obj.. z =e= 55*x1+x2 ;
r1.. 13*x1+0.09*x2 =g= 250 ;
r2.. 33*x1-0.4*x2 =l= 0 ;
r3.. 55*x1 =l= 750 ;
model model1 /all/;
option optcr=0.000001;
solve model1 using mip minimizing z;
display z.l;
Thanks & Regards