 Hi Juan Jose,
 I could not respond your message until today, sorry for late reply, in case you are still wandering,
 you can activate a variable in the way I do it below, see the scalar condition, which should set to 1 or to 0 to work as a logic switcher
 as per your need; you can then create a logic condition at any point of the code to let this parameter be 1 or 0
 so your variable would be activated only when you want it!
 I do not know what do you intend but it seems an easy way to have conditions in variables
 (search for “condition” below, I used a model from the library)
 Best,
 Roger
scalar condition;
condition = 1;
*condition = 0;
$title APL1PCA Stochastic Programming Example for GAMS/DECIS (APL1PCA,SEQ=198)
$ontext
Stochastic Electric Power Expansion Planning Problem.
This is a twostage stochastic linear program.
Facing uncertain demand, decisions about generation
capacity need to be made.
Compared to APL1P this model introduces dependent
stochastic parameters.
This model is also used as an example in the
GAMS/DECIS user’s guide.
Infanger, G, Planning Under Uncertainty  Solving LargeScale
Stochastic Linear Programs, 1988.
$offtext
$if not set decisalg $set decisalg decism
set g generators / g1, g2/;
set dl demand levels /h, m, l/;
parameter alpha(g) availability / g1 0.68, g2 0.64 /;
parameter ccmin(g) min capacity / g1 1000, g2 1000 /;
parameter ccmax(g) max capacity / g1 10000, g2 10000 /;
parameter c(g) investment / g1 4.0, g2 2.5 /;
table f(g,dl) operating cost
h m l
g1 4.3 2.0 0.5
g2 8.7 4.0 1.0;
parameter d(dl) demand / h 1040, m 1040, l 1040 /;
parameter us(dl) cost of unserved demand / h 10, m 10, l 10 /;
free variable tcost total cost;
positive variable x(g) capacity of generators;
positive variable y(g, dl) operation level;
positive variable s(dl) unserved demand;
equations
cost total cost
cmin(g) minimum capacity
cmax(g) maximum capacity
omax(g) maximum operating level
demand(dl) satisfy demand;
cost … tcost =e= sum(g, c(g)*x(g))
 sum(g, sum(dl, f(g,dl)*y(g,dl)))
 I added the line below to the code of this model from the library, so you can see a trick for having a condition on a variable, good luck
 sum(g, sum(dl, f(g,dl)conditiony(g,dl)))
 sum(dl,us(dl)*s(dl));
cmin(g) … x(g) =g= ccmin(g);
cmax(g) … x(g) =l= ccmax(g);
omax(g) … sum(dl, y(g,dl)) =l= alpha(g)*x(g);
demand(dl) … sum(g, y(g,dl)) + s(dl) =g= d(dl);
model apl1p /all/;
\
x.stage(g) = 1;
y.stage(g, dl) = 2;
s.stage(dl) = 2;
cmin.stage(g) = 1;
cmax.stage(g) = 1;
omax.stage(g) = 2;
demand.stage(dl) = 2;

 defining independent stochastic parameters

set stoch /out, pro/;
set omega1 / o11, o12 /;
table v1(stoch,omega1)
o11 o12
out 2.1 1.0
pro 0.5 0.5 ;
set omega2 / o21, o22 /;
table v2(stoch, omega2)
o21 o22
out 2.0 1.0
pro 0.2 0.8 ;
parameter hm1(dl) / h 300, m 400, l 200 /;
parameter hm2(dl) / h 100, m 150, l 300 /;

 outputting stochastic file

file stg / MODEL.STG /;
put stg;
put “BLOCKS DISCRETE” /;
scalar h1;
loop(omega1,
put "BL v1 period2 ", v1(“pro”, omega1)/;
loop(dl,
h1 = hm1(dl) * v1(“out”, omega1);
put "RHS demand ",dl.tl:1, " ", h1/;
);
);
loop(omega2,
put "BL v2 period2 ", v2(“pro”, omega2)/;
loop(dl,
h1 = hm2(dl) * v2(“out”, omega2);
put "RHS demand ",dl.tl:1, " ", h1/;
);
);
putclose;

 output a MINOS option file

file mopt / MINOS.SPC /;
put mopt;
put “begin”/;
put “rows 250”/;
put “columns 250”/;
put “elements 10000”/;
put “end”/;
putclose;
\
option lp=%decisalg%;
solve apl1p using lp minimizing tcost;
scalar ccost capital cost;
scalar ocost operating cost;
ccost = sum(g, c(g) * x.l(g));
ocost = tcost.l  ccost;
display x.l, tcost.l, ccost, ocost, y.l, s.l;
20150319 5:26 GMT+01:00 Juan JosÃ© UcrÃ³s Ospino :
Hi Roger
Thanks for your answer. That is exactly what I was trying to figured out. Just a little additional question: How can I add conditions to my variables?? Can you give me a little example?
–
Best
J
On Wednesday, March 18, 2015 at 2:57:23 AM UTC5, Roger Cremades wrote:
Hi Juan Jose,
you can add conditions to your equations, e.g. with $, and in the same
way you can add conditions to your variables. If the condition does
not hold, the equations are not created, same for the variables. I am
not sure if this is what you wanted to know, but you can always
display and check after the solution, and revise the model until you
have what you need.
Cheers,
Roger
20150318 3:01 GMT+01:00 Juan JosÃ© UcrÃ³s Ospino :
Hi, sorry for the rookie question.
I’m trying to create a multiechelon production model. But, I’m concerned about the number of variables. I define the variables ovee the sets of Sites, Skus, etc. But not all the possible combinations are allowed, i.e. not all the Skus are produced in all the Sites.
I create subsets for the possible combinations and filter the equations (using $ conditional). Every variable that does not appear in any equations will be created by Gams and then set to zero? Or the variable will never be created?
My concern is about the initial model’s size.
Thanks in advance
–
Best
J
–
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
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.