Loop over solving statement (solving the model for each value of the sets)

Dear All,
I want to solve the following test model (one time) for each given values of sets S and CLIM. I know it needs a loop over the solve statement, but don’t succeed to do it. Can anyone advise? thanks!!


SETS S STRATS /M1*M4/
CLIM CLIMATIC STAGE /HSH, SAS, SAI, ARID /


equations
objective(s,clim)
fert(s,clim)
mecan(s,clim)
trav(s,clim)
water(s,clim)
Objective1(s,clim)
;
objective(s,clim)… F_Income(s,clim)=e=sum(i,({Rendement(I,s,clim)*Prix_Prod(I,s,clim)+ Sous_produits(I,s,clim)*Prix_Sprod(I,s,clim)}
-{Semence(I,s,clim)*Prix_Sem(I,s,clim)+ Fertilisation(I,s,clim)*Prix_Fert(I,s,clim)+Traitement(I,s,clim)*Prix_Trai(I,s,clim)+
Mecanisation(I,s,clim)*Prix_Mec(I,s,clim)+ Travail(I,s,clim)*Prix_Trav(I,s,clim)+Eau_irrigation(I,s,clim)*Prix_Eau(I,s,clim)+
Divers(I,s,clim)*Prix_Div(I,s,clim)})*X_Sim(i,s,clim)) ;
fert(s,clim)… sum(i,X_Sim(i,s,clim)*Fertilisation(I,s,clim))=l=fert_Available(s,clim) ;
mecan(s,clim)… sum(i,X_Sim(i,s,clim)*Mecanisation(I,s,clim))=l=mecan_Available(s,clim) ;
trav(s,clim)… sum(i,X_Sim(i,s,clim)*Travail(I,s,clim))=l=trav_Available(s,clim) ;
water(s,clim)… sum(i,X_Sim(i,s,clim)*Eau_irrigation(I,s,clim))=l=W_Available(s,clim) ;
Objective1(s,clim)… F_Income(s,clim)=e=z ;

model Test01 /all/;

\

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.

Reply-to: gamsworld@googlegroups.com

hi
I have solved a problem as like as your problem at previously.
solve your problem by this solution :

sets
s states /…/
t time /1120/
n senario /s1
s31/
.
.
.
.
.

model problem /pa,pm,na,nm,drsd,dmsf,dmsxl,d,OBJECT/;
OPTION LIMROW = 0 ,LIMCOL = 0 ,reslim = 1000, iterlim = 10000;
loop(n,
scw=ord(n)-1;
SOLVE problem using dnlp minimizing z;
trl(s,n)= tr.l(s);
arl(s,t,n)= ar.l(s,t);
mal(s,t,n)= ma.l(s,t);
msl(s,t,n)= ms(s,t);
msxl(s,t,n)= msx.l(s,t);
msfl(s,t,n)= msf.l(s,t);
rsdl(s,t,n)= rsd.l(s,t);
ssrl(n)= ssr.l;
cl(s,n)= c.l(s);
DISPLAY trl,arl,mal,msl,msxl,msfl,rsdl,ssrl,cl;
)
;
execute_unload ‘problem.gdx’ trl,arl,mal,msl,msxl,msfl,rsdl,ssrl,cl;


On Wednesday, July 29, 2015 at 10:49:27 AM UTC+3:30, Aymen_Fr wrote:


Dear All,
I want to solve the following test model (one time) for each given values of sets S and CLIM. I know it needs a loop over the solve statement, but don’t succeed to do it. Can anyone advise? thanks!!


SETS S STRATS /M1*M4/
CLIM CLIMATIC STAGE /HSH, SAS, SAI, ARID /


equations
objective(s,clim)
fert(s,clim)
mecan(s,clim)
trav(s,clim)
water(s,clim)
Objective1(s,clim)
;
objective(s,clim)… F_Income(s,clim)=e=sum(i,({Rendement(I,s,clim)*Prix_Prod(I,s,clim)+ Sous_produits(I,s,clim)*Prix_Sprod(I,s,clim)}
-{Semence(I,s,clim)*Prix_Sem(I,s,clim)+ Fertilisation(I,s,clim)*Prix_Fert(I,s,clim)+Traitement(I,s,clim)*Prix_Trai(I,s,clim)+
Mecanisation(I,s,clim)*Prix_Mec(I,s,clim)+ Travail(I,s,clim)*Prix_Trav(I,s,clim)+Eau_irrigation(I,s,clim)*Prix_Eau(I,s,clim)+
Divers(I,s,clim)*Prix_Div(I,s,clim)})*X_Sim(i,s,clim)) ;
fert(s,clim)… sum(i,X_Sim(i,s,clim)*Fertilisation(I,s,clim))=l=fert_Available(s,clim) ;
mecan(s,clim)… sum(i,X_Sim(i,s,clim)*Mecanisation(I,s,clim))=l=mecan_Available(s,clim) ;
trav(s,clim)… sum(i,X_Sim(i,s,clim)*Travail(I,s,clim))=l=trav_Available(s,clim) ;
water(s,clim)… sum(i,X_Sim(i,s,clim)*Eau_irrigation(I,s,clim))=l=W_Available(s,clim) ;
Objective1(s,clim)… F_Income(s,clim)=e=z ;

model Test01 /all/;

\

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.

Hi,


file fx / Solutions.txt /;
put fx ’ >‘;
put / put ’ RHS’ put ’ Objective ’ put ’ N ’ put ’ q1’ put ’ q2’put ’ q3’put ’ q4’put ’ q5’put ’ q6’put ’ q7’put ’ q8’put ’ q9’put ’ q10’
put /
for (RHS=16525 to 23000 by 223,
solve chain using minlp minimizing obj


put / put RHS put’ ’ put obj.l put N.l
Loop (i, put q.l(i); ); )
;


It’s a sample of using loop in solve statement. First creates a text file named “Solutions.txt”. q(i), N and Objective are the variables. RHS changes from 16525 to 23000 by 223.


Date: Wed, 29 Jul 2015 00:16:10 -0700
From: frijaaymen@gmail.com
To: gamsworld@googlegroups.com
Subject: Loop over solving statement (solving the model for each value of the sets)


Dear All,
I want to solve the following test model (one time) for each given values of sets S and CLIM. I know it needs a loop over the solve statement, but don’t succeed to do it. Can anyone advise? thanks!!


SETS S STRATS /M1*M4/
CLIM CLIMATIC STAGE /HSH, SAS, SAI, ARID /


equations
objective(s,clim)
fert(s,clim)
mecan(s,clim)
trav(s,clim)
water(s,clim)
Objective1(s,clim)
;
objective(s,clim)… F_Income(s,clim)=e=sum(i,({Rendement(I,s,clim)*Prix_Prod(I,s,clim)+ Sous_produits(I,s,clim)*Prix_Sprod(I,s,clim)}
-{Semence(I,s,clim)*Prix_Sem(I,s,clim)+ Fertilisation(I,s,clim)*Prix_Fert(I,s,clim)+Traitement(I,s,clim)*Prix_Trai(I,s,clim)+
Mecanisation(I,s,clim)*Prix_Mec(I,s,clim)+ Travail(I,s,clim)*Prix_Trav(I,s,clim)+Eau_irrigation(I,s,clim)*Prix_Eau(I,s,clim)+
Divers(I,s,clim)*Prix_Div(I,s,clim)})*X_Sim(i,s,clim)) ;
fert(s,clim)… sum(i,X_Sim(i,s,clim)*Fertilisation(I,s,clim))=l=fert_Available(s,clim) ;
mecan(s,clim)… sum(i,X_Sim(i,s,clim)*Mecanisation(I,s,clim))=l=mecan_Available(s,clim) ;
trav(s,clim)… sum(i,X_Sim(i,s,clim)*Travail(I,s,clim))=l=trav_Available(s,clim) ;
water(s,clim)… sum(i,X_Sim(i,s,clim)*Eau_irrigation(I,s,clim))=l=W_Available(s,clim) ;
Objective1(s,clim)… F_Income(s,clim)=e=z ;

model Test01 /all/;


\

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.


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.