Why does GAMS change binary variables to positive ones in a loop?

Problems with modeling
Post Reply
moosavi_69
User
User
Posts: 31
Joined: 6 years ago

Why does GAMS change binary variables to positive ones in a loop?

Post by moosavi_69 »

Dear friends,

I have coded a scheduling problem in GAMS using the Sample Average Approximation. This model is a MILP mathematical model. I have chosen Cplex as the solver for this problem. The code solves a problem in a loop for multiple times, and it fixes binary variables, i.e., xa, and xaa, in each iteration. Finally, it will free their upper and lower bounds. For more clarification, I have provided a summary of this model in the following:

loop(rr,
****************** First sample for SAA
Solve Finall using MIP min f;

****************** Second sample for SAA
xa.fx(i,j,k,r,t)=x.l(i,j,k,r,t);
Solve Finalls using MIP min fa;

****************** Solving Simple Model
loop(scenarios,
xaa.fx(i,j,k,r,t)=x.l(i,j,k,r,t);
Solve Finallss using MIP min fss;

xaa.lo(i,j,k,r,t)=0;
xaa.up(i,j,k,r,t)=1;
);

xa.lo(i,j,k,r,t)=0;
xa.up(i,j,k,r,t)=1;
);

My problem is that as the model runs the problem, it changes the first set of binary variables, i.e., x, to positive variables.

Could you please help me out. I have to thank you for the privilege of your time in advance.
GabrielYin
User
User
Posts: 72
Joined: 6 years ago
Location: Dallas, TX, USA
Contact:

Re: Why does GAMS change binary variables to positive ones in a loop?

Post by GabrielYin »

Hi,

I am just curious if you have defined xa and xaa as binary variables, why you still need to set the lower/upper bound in your loop? Actually in SAA you only need to calculate the sampling expectation as lower bound and the replication expectation as upper bound to formulate the confidence interval (though there are multiple ways to do SAA and calculate CI, the process is similar).

My suggestion is, if you have defined them as 'binary' in the definition part, just deleting the codes binding xa and xaa. Their being positive might be resulted from repeated bound settings.

Best,
Gabriel
cladelpino
User
User
Posts: 108
Joined: 7 years ago

Re: Why does GAMS change binary variables to positive ones in a loop?

Post by cladelpino »

Not familiar with SAA. The code does what it says. Can you be more specific as to what is the behaviour that you don't desire ?
My problem is that as the model runs the problem, it changes the first set of binary variables, i.e., x, to positive variables.
which Model (Finall,Finalls, etc) ? all of them ? Why would you expect x to remain at some value if you are not fixing them ?
Aminz
User
User
Posts: 5
Joined: 5 years ago

Re: Why does GAMS change binary variables to positive ones in a loop?

Post by Aminz »

Hey
im looking for saa in gams. would appreciate if you would help me out

moosavi_69 wrote: 6 years ago Dear friends,

I have coded a scheduling problem in GAMS using the Sample Average Approximation. This model is a MILP mathematical model. I have chosen Cplex as the solver for this problem. The code solves a problem in a loop for multiple times, and it fixes binary variables, i.e., xa, and xaa, in each iteration. Finally, it will free their upper and lower bounds. For more clarification, I have provided a summary of this model in the following:

loop(rr,
****************** First sample for SAA
Solve Finall using MIP min f;

****************** Second sample for SAA
xa.fx(i,j,k,r,t)=x.l(i,j,k,r,t);
Solve Finalls using MIP min fa;

****************** Solving Simple Model
loop(scenarios,
xaa.fx(i,j,k,r,t)=x.l(i,j,k,r,t);
Solve Finallss using MIP min fss;

xaa.lo(i,j,k,r,t)=0;
xaa.up(i,j,k,r,t)=1;
);

xa.lo(i,j,k,r,t)=0;
xa.up(i,j,k,r,t)=1;
);

My problem is that as the model runs the problem, it changes the first set of binary variables, i.e., x, to positive variables.

Could you please help me out. I have to thank you for the privilege of your time in advance.
Post Reply