error code 119 for loop including several if else statements

Dear All,
I have been trying to code if then, if else by using loop but some how I am struggling a great deal.
I keep getting error code 119 and I do not know how to fix it. I have searched all the old questions and asnwers but so far no luck.
If possible could you please let me know how can I fix the problem. Thank you in advance.

PARAMETERS

R1=0.3;
R2=0.6 ;
R3=0.8 ;

binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)

const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);

const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);


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,
where is your set definition? why do not you declare parameters before assigning data to them?
check GAMS grammar rules very carefully before trying again,
cheers
R

2015-05-19 1:16 GMT+02:00 deniz :

Dear All,
I have been trying to code if then, if else by using loop but some how I am struggling a great deal.
I keep getting error code 119 and I do not know how to fix it. I have searched all the old questions and asnwers but so far no luck.
If possible could you please let me know how can I fix the problem. Thank you in advance.

PARAMETERS

R1=0.3;
R2=0.6 ;
R3=0.8 ;

binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)

const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);

const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);


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.

Dear Ranger,
First of all, I would like to thank you for your help.
If it helps, I posted my model.
I define the sets and parameters. But when it comes to if statement. it gives me error code 119.
I am putting variables inside if statement. Is this error because of that or do I need to use other constraint to define my if then statement. I do not know how to fix this error code.

I really do appreciate your help very much and your helps mean a lot.

Regards.


Sets

p component/P1*P4/

T periods in the planning horizon / 0*4/

t0(t)/0/

;

SCALAR K1 correction factor /0.5/ ;

SCALAR K2 correction factor /0.3/ ;

SCALAR K3 correction factor /0.2/ ;

SCALAR A degradation constant /1.01/ ;

PARAMETERS

b(t) budget

EN(t) en need

ENP(p) eny production of each productat time t

U1(t) maintenance costs at time t

U2(t) mid-level cost at time t

U3(t) high-level cost at time t

R1 improvement level 1

R2 improvement level 2

R3 r improvement level 3

RS(t)

Rmin(T) min

Rmax(T) max

;



U1(t)=OMNN1(t,“OMNN”);

U2(t)=OMLR1(t,“OMLR”);

U3(t)=OMHR1(t,“OMHR”);

b(t)= b1(t,“budget”);

EN(t)= EN1(t,“energy”);

ENP(p)=ENP1(p,“ENPS”);

R1=0.3;

R2=0.6 ;

R3=0.8 ;

Rmin(T)=0.1 ;

Rmax(T)=0.9 ;



parameter

Lambdazero(P) given for time period zero



/P1 0.6

P2 0.7

P3 0.1

P4 0.1

/

;



variable

Lambda(p,t) lambda for component p at time t

h

;



binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)

;

Equations

objective

const1(T,P)

const1a(T,P)

const2(T,P)

Const3(T0,P)

Const3a(T,P)

const4(T,P)

const5(T,P)

const6(T,P)

const7(T)

const8(T)

const8a(T)



;

ALIAS (T,J);

const1(t,p) …sum((j),ENP1(P,“ENPS”)*lambda(P,t))=g=EN1(T,“energy”);

ALIAS (T,J);

const2(t,p) … sum((J),OMNN1(J,“OMNN”)*Z1(J,P))+ sum((J),OMLR1(J,“OMLR”)*Z2(J,P))

  • sum((J),OMHR1(J,“OMHR”)*Z3(J,P))=l=b1(T,“budget”);



    const3(t0,p) …lambda(p,t-1)=e= Lambdazero(P);

const3a(T,P)…lambda(p,t)=e=Lambda(P,t-1)*A+Lambda(P,t-1)B1Z1(t-1,p)+Lambda(P,t-1)B2Z2(t-1,p)+Lambda(P,t-1)B3Z3(T-1,P);



const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);



Const5(T,P) …Z1(T,P)+ Z2(T,P)+Z3(T,P)=e=1;



const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);

Const7(T)… RS(t)=E=1-prod(p,(1-exp(-lambda(p,t)*ord(T))));



Const8(T)… Rmin(T)=l= RS(t) ;

Const8a(T)…RS(t) =g= Rmax(T);



objective…h=e=sum((T,P),OMNN1(T,“OMNN”)*Z1(T,P))+ sum((T,P),OMLR1(T,“OMLR”)*Z2(T,P))+ sum((T,P),OMLR1(T,“OMHR”)*Z3(T,P));



model DEN /all/;

solve DEN using minlp minimizing h;

display z1.l;

display z2.l;

display z3.l;


On Tuesday, May 19, 2015 at 1:04:51 AM UTC-5, deniz wrote:

Dear All,
I have been trying to code if then, if else by using loop but some how I am struggling a great deal.
I keep getting error code 119 and I do not know how to fix it. I have searched all the old questions and asnwers but so far no luck.
If possible could you please let me know how can I fix the problem. Thank you in advance.

PARAMETERS

R1=0.3;
R2=0.6 ;
R3=0.8 ;

binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)

const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);

const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);


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 Deniz

If you send code, this should at least run without errors until the error you mention appears. Your code is incomplete and raises error far before the if statements.

Renger



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of deniz
Sent: Mittwoch, 20. Mai 2015 18:37
To: gamsworld@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Dear Ranger,

First of all, I would like to thank you for your help.

If it helps, I posted my model.

I define the sets and parameters. But when it comes to if statement. it gives me error code 119.

I am putting variables inside if statement. Is this error because of that or do I need to use other constraint to define my if then statement. I do not know how to fix this error code.



I really do appreciate your help very much and your helps mean a lot.



Regards.





Sets

p component/P1*P4/

T periods in the planning horizon / 0*4/

t0(t)/0/

;

SCALAR K1 correction factor /0.5/ ;

SCALAR K2 correction factor /0.3/ ;

SCALAR K3 correction factor /0.2/ ;

SCALAR A degradation constant /1.01/ ;

PARAMETERS

b(t) budget

EN(t) en need

ENP(p) eny production of each productat time t

U1(t) maintenance costs at time t

U2(t) mid-level cost at time t

U3(t) high-level cost at time t

R1 improvement level 1

R2 improvement level 2

R3 r improvement level 3

RS(t)

Rmin(T) min

Rmax(T) max

;



U1(t)=OMNN1(t,“OMNN”);

U2(t)=OMLR1(t,“OMLR”);

U3(t)=OMHR1(t,“OMHR”);

b(t)= b1(t,“budget”);

EN(t)= EN1(t,“energy”);

ENP(p)=ENP1(p,“ENPS”);

R1=0.3;

R2=0.6 ;

R3=0.8 ;

Rmin(T)=0.1 ;

Rmax(T)=0.9 ;



parameter

Lambdazero(P) given for time period zero



/P1 0.6

P2 0.7

P3 0.1

P4 0.1

/

;



variable

Lambda(p,t) lambda for component p at time t

h

;



binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)

;

Equations

objective

const1(T,P)

const1a(T,P)

const2(T,P)

Const3(T0,P)

Const3a(T,P)

const4(T,P)

const5(T,P)

const6(T,P)

const7(T)

const8(T)

const8a(T)



;

ALIAS (T,J);

const1(t,p) …sum((j),ENP1(P,“ENPS”)*lambda(P,t))=g=EN1(T,“energy”);

ALIAS (T,J);

const2(t,p) … sum((J),OMNN1(J,“OMNN”)*Z1(J,P))+ sum((J),OMLR1(J,“OMLR”)*Z2(J,P))

  • sum((J),OMHR1(J,“OMHR”)*Z3(J,P))=l=b1(T,“budget”);



    const3(t0,p) …lambda(p,t-1)=e= Lambdazero(P);

const3a(T,P)…lambda(p,t)=e=Lambda(P,t-1)*A+Lambda(P,t-1)B1Z1(t-1,p)+Lambda(P,t-1)B2Z2(t-1,p)+Lambda(P,t-1)B3Z3(T-1,P);



const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);



Const5(T,P) …Z1(T,P)+ Z2(T,P)+Z3(T,P)=e=1;



const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);

Const7(T)… RS(t)=E=1-prod(p,(1-exp(-lambda(p,t)*ord(T))));



Const8(T)… Rmin(T)=l= RS(t) ;

Const8a(T)…RS(t) =g= Rmax(T);



objective…h=e=sum((T,P),OMNN1(T,“OMNN”)*Z1(T,P))+ sum((T,P),OMLR1(T,“OMLR”)*Z2(T,P))+ sum((T,P),OMLR1(T,“OMHR”)*Z3(T,P));



model DEN /all/;

solve DEN using minlp minimizing h;

display z1.l;

display z2.l;

display z3.l;



On Tuesday, May 19, 2015 at 1:04:51 AM UTC-5, deniz wrote:

Dear All,

I have been trying to code if then, if else by using loop but some how I am struggling a great deal.

I keep getting error code 119 and I do not know how to fix it. I have searched all the old questions and asnwers but so far no luck.

If possible could you please let me know how can I fix the problem. Thank you in advance.



PARAMETERS



R1=0.3;
R2=0.6 ;
R3=0.8 ;



binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)



const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);



const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);


\

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.

Dear Renger,
Here is my gams model file along with data table.
Model work till if statement and after that it gives me error code.
Since if statements contains variable, can be this a problem?

I appreciate your help very much.
Sincerely.



On Thursday, May 21, 2015 at 12:47:03 AM UTC-5, Renger van Nieuwkoop wrote:

Hi Deniz

If you send code, this should at least run without errors until the error you mention appears. Your code is incomplete and raises error far before the if statements.

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Mittwoch, 20. Mai 2015 18:37
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Dear Ranger,

First of all, I would like to thank you for your help.

If it helps, I posted my model.

I define the sets and parameters. But when it comes to if statement. it gives me error code 119.

I am putting variables inside if statement. Is this error because of that or do I need to use other constraint to define my if then statement. I do not know how to fix this error code.



I really do appreciate your help very much and your helps mean a lot.



Regards.





Sets

p component/P1*P4/

T periods in the planning horizon / 0*4/

t0(t)/0/

;

SCALAR K1 correction factor /0.5/ ;

SCALAR K2 correction factor /0.3/ ;

SCALAR K3 correction factor /0.2/ ;

SCALAR A degradation constant /1.01/ ;

PARAMETERS

b(t) budget

EN(t) en need

ENP(p) eny production of each productat time t

U1(t) maintenance costs at time t

U2(t) mid-level cost at time t

U3(t) high-level cost at time t

R1 improvement level 1

R2 improvement level 2

R3 r improvement level 3

RS(t)

Rmin(T) min

Rmax(T) max

;



U1(t)=OMNN1(t,“OMNN”);

U2(t)=OMLR1(t,“OMLR”);

U3(t)=OMHR1(t,“OMHR”);

b(t)= b1(t,“budget”);

EN(t)= EN1(t,“energy”);

ENP(p)=ENP1(p,“ENPS”);

R1=0.3;

R2=0.6 ;

R3=0.8 ;

Rmin(T)=0.1 ;

Rmax(T)=0.9 ;



parameter

Lambdazero(P) given for time period zero



/P1 0.6

P2 0.7

P3 0.1

P4 0.1

/

;



variable

Lambda(p,t) lambda for component p at time t

h

;



binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)

;

Equations

objective

const1(T,P)

const1a(T,P)

const2(T,P)

Const3(T0,P)

Const3a(T,P)

const4(T,P)

const5(T,P)

const6(T,P)

const7(T)

const8(T)

const8a(T)



;

ALIAS (T,J);

const1(t,p) …sum((j),ENP1(P,“ENPS”)*lambda(P,t))=g=EN1(T,“energy”);

ALIAS (T,J);

const2(t,p) … sum((J),OMNN1(J,“OMNN”)*Z1(J,P))+ sum((J),OMLR1(J,“OMLR”)*Z2(J,P))

  • sum((J),OMHR1(J,“OMHR”)*Z3(J,P))=l=b1(T,“budget”);



    const3(t0,p) …lambda(p,t-1)=e= Lambdazero(P);

const3a(T,P)…lambda(p,t)=e=Lambda(P,t-1)*A+Lambda(P,t-1)B1Z1(t-1,p)+Lambda(P,t-1)B2Z2(t-1,p)+Lambda(P,t-1)B3Z3(T-1,P);



const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);



Const5(T,P) …Z1(T,P)+ Z2(T,P)+Z3(T,P)=e=1;



const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);

Const7(T)… RS(t)=E=1-prod(p,(1-exp(-lambda(p,t)*ord(T))));



Const8(T)… Rmin(T)=l= RS(t) ;

Const8a(T)…RS(t) =g= Rmax(T);



objective…h=e=sum((T,P),OMNN1(T,“OMNN”)*Z1(T,P))+ sum((T,P),OMLR1(T,“OMLR”)*Z2(T,P))+ sum((T,P),OMLR1(T,“OMHR”)*Z3(T,P));



model DEN /all/;

solve DEN using minlp minimizing h;

display z1.l;

display z2.l;

display z3.l;



On Tuesday, May 19, 2015 at 1:04:51 AM UTC-5, deniz wrote:

Dear All,

I have been trying to code if then, if else by using loop but some how I am struggling a great deal.

I keep getting error code 119 and I do not know how to fix it. I have searched all the old questions and asnwers but so far no luck.

If possible could you please let me know how can I fix the problem. Thank you in advance.



PARAMETERS



R1=0.3;
R2=0.6 ;
R3=0.8 ;



binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)



const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);



const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);


\

may14.txt (835 Bytes)
Model-Deniz-May21-2015.gms (3.13 KB)

Hi Deniz



You are not allowed to use if statements in equations. A way to solve this would be



const4(t,p)… (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) * lambda(p,t) - Lambda(P,t-1)*A +

z1(t-1,p) * (lambda(p,t) - Lambda(P,t-1)*B1) +

z2(t-1,p) * (lambda(p,t) - Lambda(P,t-1)*B2) +

z3(t-1,p) * (lambda(p,t) - Lambda(P,t-1)*B3) =E= 0;



If z1, z2, z3 are binary variables, this seems to do the trick.

Be aware, that you B1 is defined as B1(t,“budget“), so you should correct this, as well as introduce the parameters B2 and B3.



Hope this helps



Renger



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of deniz
Sent: Donnerstag, 21. Mai 2015 17:24
To: gamsworld@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Dear Renger,

Here is my gams model file along with data table.

Model work till if statement and after that it gives me error code.

Since if statements contains variable, can be this a problem?



I appreciate your help very much.

Sincerely.





On Thursday, May 21, 2015 at 12:47:03 AM UTC-5, Renger van Nieuwkoop wrote:

Hi Deniz

If you send code, this should at least run without errors until the error you mention appears. Your code is incomplete and raises error far before the if statements.

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Mittwoch, 20. Mai 2015 18:37
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Dear Ranger,

First of all, I would like to thank you for your help.

If it helps, I posted my model.

I define the sets and parameters. But when it comes to if statement. it gives me error code 119.

I am putting variables inside if statement. Is this error because of that or do I need to use other constraint to define my if then statement. I do not know how to fix this error code.



I really do appreciate your help very much and your helps mean a lot.



Regards.





Sets

p component/P1*P4/

T periods in the planning horizon / 0*4/

t0(t)/0/

;

SCALAR K1 correction factor /0.5/ ;

SCALAR K2 correction factor /0.3/ ;

SCALAR K3 correction factor /0.2/ ;

SCALAR A degradation constant /1.01/ ;

PARAMETERS

b(t) budget

EN(t) en need

ENP(p) eny production of each productat time t

U1(t) maintenance costs at time t

U2(t) mid-level cost at time t

U3(t) high-level cost at time t

R1 improvement level 1

R2 improvement level 2

R3 r improvement level 3

RS(t)

Rmin(T) min

Rmax(T) max

;



U1(t)=OMNN1(t,“OMNN”);

U2(t)=OMLR1(t,“OMLR”);

U3(t)=OMHR1(t,“OMHR”);

b(t)= b1(t,“budget”);

EN(t)= EN1(t,“energy”);

ENP(p)=ENP1(p,“ENPS”);

R1=0.3;

R2=0.6 ;

R3=0.8 ;

Rmin(T)=0.1 ;

Rmax(T)=0.9 ;



parameter

Lambdazero(P) given for time period zero



/P1 0.6

P2 0.7

P3 0.1

P4 0.1

/

;



variable

Lambda(p,t) lambda for component p at time t

h

;



binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)

;

Equations

objective

const1(T,P)

const1a(T,P)

const2(T,P)

Const3(T0,P)

Const3a(T,P)

const4(T,P)

const5(T,P)

const6(T,P)

const7(T)

const8(T)

const8a(T)



;

ALIAS (T,J);

const1(t,p) …sum((j),ENP1(P,“ENPS”)*lambda(P,t))=g=EN1(T,“energy”);

ALIAS (T,J);

const2(t,p) … sum((J),OMNN1(J,“OMNN”)*Z1(J,P))+ sum((J),OMLR1(J,“OMLR”)*Z2(J,P))

  • sum((J),OMHR1(J,“OMHR”)*Z3(J,P))=l=b1(T,“budget”);



    const3(t0,p) …lambda(p,t-1)=e= Lambdazero(P);

const3a(T,P)…lambda(p,t)=e=Lambda(P,t-1)*A+Lambda(P,t-1)B1Z1(t-1,p)+Lambda(P,t-1)B2Z2(t-1,p)+Lambda(P,t-1)B3Z3(T-1,P);



const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);



Const5(T,P) …Z1(T,P)+ Z2(T,P)+Z3(T,P)=e=1;



const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);

Const7(T)… RS(t)=E=1-prod(p,(1-exp(-lambda(p,t)*ord(T))));



Const8(T)… Rmin(T)=l= RS(t) ;

Const8a(T)…RS(t) =g= Rmax(T);



objective…h=e=sum((T,P),OMNN1(T,“OMNN”)*Z1(T,P))+ sum((T,P),OMLR1(T,“OMLR”)*Z2(T,P))+ sum((T,P),OMLR1(T,“OMHR”)*Z3(T,P));



model DEN /all/;

solve DEN using minlp minimizing h;

display z1.l;

display z2.l;

display z3.l;



On Tuesday, May 19, 2015 at 1:04:51 AM UTC-5, deniz wrote:

Dear All,

I have been trying to code if then, if else by using loop but some how I am struggling a great deal.

I keep getting error code 119 and I do not know how to fix it. I have searched all the old questions and asnwers but so far no luck.

If possible could you please let me know how can I fix the problem. Thank you in advance.



PARAMETERS



R1=0.3;
R2=0.6 ;
R3=0.8 ;



binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)



const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);



const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);


\

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.


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.

Thank you so much Renger,
You cannot imagine how important to get feedback/help from you.
I will certainly try the way you explained and hopefully will not bother you again…
I am very grateful to this group!
Regards.

On Tuesday, May 19, 2015 at 1:04:51 AM UTC-5, deniz wrote:

Dear All,
I have been trying to code if then, if else by using loop but some how I am struggling a great deal.
I keep getting error code 119 and I do not know how to fix it. I have searched all the old questions and asnwers but so far no luck.
If possible could you please let me know how can I fix the problem. Thank you in advance.

PARAMETERS

R1=0.3;
R2=0.6 ;
R3=0.8 ;

binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)

const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);

const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);


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.

Dear Ranger,

Now, I am stuck at constraint 6. I tried to use the same exact method that you showed for constraint 4 but I am getting error, is this because there is a range that I am using for R values?
Thank you very much for all your help!



const6(t,p)… z3(t-1,p) * lambda(p,t+1) l R1+ R1 gt z2(t-1,p) *lambda(p,t+1) l R2+ R2 gt z1(t-1,p) *lambda(p,t+1) l R3+ (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) *lambda(p,t+1) gt R3=E=0;

const6(T,P) …
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);



On Friday, May 22, 2015 at 8:24:36 AM UTC-5, deniz wrote:

Thank you so much Renger,
You cannot imagine how important to get feedback/help from you.
I will certainly try the way you explained and hopefully will not bother you again…
I am very grateful to this group!
Regards.

On Tuesday, May 19, 2015 at 1:04:51 AM UTC-5, deniz wrote:

Dear All,
I have been trying to code if then, if else by using loop but some how I am struggling a great deal.
I keep getting error code 119 and I do not know how to fix it. I have searched all the old questions and asnwers but so far no luck.
If possible could you please let me know how can I fix the problem. Thank you in advance.

PARAMETERS

R1=0.3;
R2=0.6 ;
R3=0.8 ;

binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)

const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);

const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);


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.

You can’t use loops or variables in $ assignments in an equation.

Renger



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 15:59
To: gamsworld@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Dear Ranger,



Now, I am stuck at constraint 6. I tried to use the same exact method that you showed for constraint 4 but I am getting error, is this because there is a range that I am using for R values?

Thank you very much for all your help!







const6(t,p)… z3(t-1,p) * lambda(p,t+1) l R1+ R1 gt z2(t-1,p) *lambda(p,t+1) l R2+ R2 gt z1(t-1,p) *lambda(p,t+1) l R3+ (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) *lambda(p,t+1) gt R3=E=0;



const6(T,P) …
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);





On Friday, May 22, 2015 at 8:24:36 AM UTC-5, deniz wrote:

Thank you so much Renger,

You cannot imagine how important to get feedback/help from you.

I will certainly try the way you explained and hopefully will not bother you again…

I am very grateful to this group!

Regards.

On Tuesday, May 19, 2015 at 1:04:51 AM UTC-5, deniz wrote:

Dear All,

I have been trying to code if then, if else by using loop but some how I am struggling a great deal.

I keep getting error code 119 and I do not know how to fix it. I have searched all the old questions and asnwers but so far no luck.

If possible could you please let me know how can I fix the problem. Thank you in advance.



PARAMETERS



R1=0.3;
R2=0.6 ;
R3=0.8 ;



binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)



const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);



const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);


\

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.

Sorry,

I think I did not posted revised code for the cont6. I removed the loop and if statement and wrote it the way you explained for constraint 4, but still getting errors. Is this because there are less than or greater than (ranges) defined in the constraint.
Hopefully, this is the last question.
Thank you so so much for your help!


const6(t,p)… z3(t-1,p) * lambda(p,t+1) l R1+ R1 gt z2(t-1,p) *lambda(p,t+1) l R2+ R2 gt z1(t-1,p) *lambda(p,t+1) l R3+ (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) *lambda(p,t+1) gt R3=E=0;

On Friday, May 22, 2015 at 9:07:10 AM UTC-5, Renger van Nieuwkoop wrote:

You can’t use loops or variables in $ assignments in an equation.

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 15:59
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Dear Ranger,



Now, I am stuck at constraint 6. I tried to use the same exact method that you showed for constraint 4 but I am getting error, is this because there is a range that I am using for R values?

Thank you very much for all your help!







const6(t,p)… z3(t-1,p) * lambda(p,t+1) l R1+ R1 gt z2(t-1,p) *lambda(p,t+1) l R2+ R2 gt z1(t-1,p) *lambda(p,t+1) l R3+ (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) *lambda(p,t+1) gt R3=E=0;



const6(T,P) …
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);





On Friday, May 22, 2015 at 8:24:36 AM UTC-5, deniz wrote:

Thank you so much Renger,

You cannot imagine how important to get feedback/help from you.

I will certainly try the way you explained and hopefully will not bother you again…

I am very grateful to this group!

Regards.

On Tuesday, May 19, 2015 at 1:04:51 AM UTC-5, deniz wrote:

Dear All,

I have been trying to code if then, if else by using loop but some how I am struggling a great deal.

I keep getting error code 119 and I do not know how to fix it. I have searched all the old questions and asnwers but so far no luck.

If possible could you please let me know how can I fix the problem. Thank you in advance.



PARAMETERS



R1=0.3;
R2=0.6 ;
R3=0.8 ;



binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)



const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);



const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);


\

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.

I don’t know what the sign | does in your equation

Renger



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 16:30
To: gamsworld@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Sorry,



I think I did not posted revised code for the cont6. I removed the loop and if statement and wrote it the way you explained for constraint 4, but still getting errors. Is this because there are less than or greater than (ranges) defined in the constraint.

Hopefully, this is the last question.

Thank you so so much for your help!





const6(t,p)… z3(t-1,p) * lambda(p,t+1) l R1+ R1 gt z2(t-1,p) *lambda(p,t+1) l R2+ R2 gt z1(t-1,p) *lambda(p,t+1) l R3+ (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) *lambda(p,t+1) gt R3=E=0;

On Friday, May 22, 2015 at 9:07:10 AM UTC-5, Renger van Nieuwkoop wrote:

You can’t use loops or variables in $ assignments in an equation.

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 15:59
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Dear Ranger,



Now, I am stuck at constraint 6. I tried to use the same exact method that you showed for constraint 4 but I am getting error, is this because there is a range that I am using for R values?

Thank you very much for all your help!







const6(t,p)… z3(t-1,p) * lambda(p,t+1) l R1+ R1 gt z2(t-1,p) *lambda(p,t+1) l R2+ R2 gt z1(t-1,p) *lambda(p,t+1) l R3+ (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) *lambda(p,t+1) gt R3=E=0;



const6(T,P) …
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);





On Friday, May 22, 2015 at 8:24:36 AM UTC-5, deniz wrote:

Thank you so much Renger,

You cannot imagine how important to get feedback/help from you.

I will certainly try the way you explained and hopefully will not bother you again…

I am very grateful to this group!

Regards.

On Tuesday, May 19, 2015 at 1:04:51 AM UTC-5, deniz wrote:

Dear All,

I have been trying to code if then, if else by using loop but some how I am struggling a great deal.

I keep getting error code 119 and I do not know how to fix it. I have searched all the old questions and asnwers but so far no luck.

If possible could you please let me know how can I fix the problem. Thank you in advance.



PARAMETERS



R1=0.3;
R2=0.6 ;
R3=0.8 ;



binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)



const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);



const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);


\

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.


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.

I am sorry for the confusion “l” means is less (<) than.


On Friday, May 22, 2015 at 10:22:12 AM UTC-5, Renger van Nieuwkoop wrote:

I don’t know what the sign | does in your equation

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 16:30
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Sorry,



I think I did not posted revised code for the cont6. I removed the loop and if statement and wrote it the way you explained for constraint 4, but still getting errors. Is this because there are less than or greater than (ranges) defined in the constraint.

Hopefully, this is the last question.

Thank you so so much for your help!





const6(t,p)… z3(t-1,p) * lambda(p,t+1) l R1+ R1 gt z2(t-1,p) *lambda(p,t+1) l R2+ R2 gt z1(t-1,p) *lambda(p,t+1) l R3+ (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) *lambda(p,t+1) gt R3=E=0;

On Friday, May 22, 2015 at 9:07:10 AM UTC-5, Renger van Nieuwkoop wrote:

You can’t use loops or variables in $ assignments in an equation.

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 15:59
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Dear Ranger,



Now, I am stuck at constraint 6. I tried to use the same exact method that you showed for constraint 4 but I am getting error, is this because there is a range that I am using for R values?

Thank you very much for all your help!







const6(t,p)… z3(t-1,p) * lambda(p,t+1) l R1+ R1 gt z2(t-1,p) *lambda(p,t+1) l R2+ R2 gt z1(t-1,p) *lambda(p,t+1) l R3+ (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) *lambda(p,t+1) gt R3=E=0;



const6(T,P) …
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);





On Friday, May 22, 2015 at 8:24:36 AM UTC-5, deniz wrote:

Thank you so much Renger,

You cannot imagine how important to get feedback/help from you.

I will certainly try the way you explained and hopefully will not bother you again…

I am very grateful to this group!

Regards.

On Tuesday, May 19, 2015 at 1:04:51 AM UTC-5, deniz wrote:

Dear All,

I have been trying to code if then, if else by using loop but some how I am struggling a great deal.

I keep getting error code 119 and I do not know how to fix it. I have searched all the old questions and asnwers but so far no luck.

If possible could you please let me know how can I fix the problem. Thank you in advance.



PARAMETERS



R1=0.3;
R2=0.6 ;
R3=0.8 ;



binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)



const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);



const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);


\

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+...@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.

I would probably write these lesser and greater conditions as additional constraints and keep the original constraint without these conditions.

Renger



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 17:32
To: gamsworld@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements





I am sorry for the confusion “l” means is less (<) than.



On Friday, May 22, 2015 at 10:22:12 AM UTC-5, Renger van Nieuwkoop wrote:

I don’t know what the sign | does in your equation

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 16:30
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Sorry,



I think I did not posted revised code for the cont6. I removed the loop and if statement and wrote it the way you explained for constraint 4, but still getting errors. Is this because there are less than or greater than (ranges) defined in the constraint.

Hopefully, this is the last question.

Thank you so so much for your help!





const6(t,p)… z3(t-1,p) * lambda(p,t+1) l R1+ R1 gt z2(t-1,p) *lambda(p,t+1) l R2+ R2 gt z1(t-1,p) *lambda(p,t+1) l R3+ (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) *lambda(p,t+1) gt R3=E=0;

On Friday, May 22, 2015 at 9:07:10 AM UTC-5, Renger van Nieuwkoop wrote:

You can’t use loops or variables in $ assignments in an equation.

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 15:59
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Dear Ranger,



Now, I am stuck at constraint 6. I tried to use the same exact method that you showed for constraint 4 but I am getting error, is this because there is a range that I am using for R values?

Thank you very much for all your help!







const6(t,p)… z3(t-1,p) * lambda(p,t+1) l R1+ R1 gt z2(t-1,p) *lambda(p,t+1) l R2+ R2 gt z1(t-1,p) *lambda(p,t+1) l R3+ (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) *lambda(p,t+1) gt R3=E=0;



const6(T,P) …
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);





On Friday, May 22, 2015 at 8:24:36 AM UTC-5, deniz wrote:

Thank you so much Renger,

You cannot imagine how important to get feedback/help from you.

I will certainly try the way you explained and hopefully will not bother you again…

I am very grateful to this group!

Regards.

On Tuesday, May 19, 2015 at 1:04:51 AM UTC-5, deniz wrote:

Dear All,

I have been trying to code if then, if else by using loop but some how I am struggling a great deal.

I keep getting error code 119 and I do not know how to fix it. I have searched all the old questions and asnwers but so far no luck.

If possible could you please let me know how can I fix the problem. Thank you in advance.



PARAMETERS



R1=0.3;
R2=0.6 ;
R3=0.8 ;



binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)



const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);



const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);


\

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+...@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.


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.

Thank you very much Ranger.
I will write additional constraints.
Again, I appreciate your help very much.

On Friday, May 22, 2015 at 11:04:17 AM UTC-5, Renger van Nieuwkoop wrote:

I would probably write these lesser and greater conditions as additional constraints and keep the original constraint without these conditions.

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 17:32
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements





I am sorry for the confusion “l” means is less (<) than.



On Friday, May 22, 2015 at 10:22:12 AM UTC-5, Renger van Nieuwkoop wrote:

I don’t know what the sign | does in your equation

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 16:30
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Sorry,



I think I did not posted revised code for the cont6. I removed the loop and if statement and wrote it the way you explained for constraint 4, but still getting errors. Is this because there are less than or greater than (ranges) defined in the constraint.

Hopefully, this is the last question.

Thank you so so much for your help!





const6(t,p)… z3(t-1,p) * lambda(p,t+1) l R1+ R1 gt z2(t-1,p) *lambda(p,t+1) l R2+ R2 gt z1(t-1,p) *lambda(p,t+1) l R3+ (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) *lambda(p,t+1) gt R3=E=0;

On Friday, May 22, 2015 at 9:07:10 AM UTC-5, Renger van Nieuwkoop wrote:

You can’t use loops or variables in $ assignments in an equation.

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 15:59
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Dear Ranger,



Now, I am stuck at constraint 6. I tried to use the same exact method that you showed for constraint 4 but I am getting error, is this because there is a range that I am using for R values?

Thank you very much for all your help!







const6(t,p)… z3(t-1,p) * lambda(p,t+1) l R1+ R1 gt z2(t-1,p) *lambda(p,t+1) l R2+ R2 gt z1(t-1,p) *lambda(p,t+1) l R3+ (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) *lambda(p,t+1) gt R3=E=0;



const6(T,P) …
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);





On Friday, May 22, 2015 at 8:24:36 AM UTC-5, deniz wrote:

Thank you so much Renger,

You cannot imagine how important to get feedback/help from you.

I will certainly try the way you explained and hopefully will not bother you again…

I am very grateful to this group!

Regards.

On Tuesday, May 19, 2015 at 1:04:51 AM UTC-5, deniz wrote:

Dear All,

I have been trying to code if then, if else by using loop but some how I am struggling a great deal.

I keep getting error code 119 and I do not know how to fix it. I have searched all the old questions and asnwers but so far no luck.

If possible could you please let me know how can I fix the problem. Thank you in advance.



PARAMETERS



R1=0.3;
R2=0.6 ;
R3=0.8 ;



binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)



const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);



const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);


\

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+...@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+...@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.

Dear Ranger,

Finally, I was able to run the model without error but now, I get a warning stating that


“An equation in the pre-triangular part of the model cannot be solved becaue the critical slack is at a bound”.

I am not sure what does this means. This is my first MINPL and I am not sure how can I solve the problem.

I appreciate your guidance very much. If it would be more appropriate, I can post separate question.

Again, Thank you very much for all your help.

Regards.



On Friday, May 22, 2015 at 11:36:17 AM UTC-5, deniz wrote:

Thank you very much Ranger.
I will write additional constraints.
Again, I appreciate your help very much.

On Friday, May 22, 2015 at 11:04:17 AM UTC-5, Renger van Nieuwkoop wrote:

I would probably write these lesser and greater conditions as additional constraints and keep the original constraint without these conditions.

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 17:32
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements





I am sorry for the confusion “l” means is less (<) than.



On Friday, May 22, 2015 at 10:22:12 AM UTC-5, Renger van Nieuwkoop wrote:

I don’t know what the sign | does in your equation

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 16:30
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Sorry,



I think I did not posted revised code for the cont6. I removed the loop and if statement and wrote it the way you explained for constraint 4, but still getting errors. Is this because there are less than or greater than (ranges) defined in the constraint.

Hopefully, this is the last question.

Thank you so so much for your help!





const6(t,p)… z3(t-1,p) * lambda(p,t+1) l R1+ R1 gt z2(t-1,p) *lambda(p,t+1) l R2+ R2 gt z1(t-1,p) *lambda(p,t+1) l R3+ (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) *lambda(p,t+1) gt R3=E=0;

On Friday, May 22, 2015 at 9:07:10 AM UTC-5, Renger van Nieuwkoop wrote:

You can’t use loops or variables in $ assignments in an equation.

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 15:59
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Dear Ranger,



Now, I am stuck at constraint 6. I tried to use the same exact method that you showed for constraint 4 but I am getting error, is this because there is a range that I am using for R values?

Thank you very much for all your help!







const6(t,p)… z3(t-1,p) * lambda(p,t+1) l R1+ R1 gt z2(t-1,p) *lambda(p,t+1) l R2+ R2 gt z1(t-1,p) *lambda(p,t+1) l R3+ (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) *lambda(p,t+1) gt R3=E=0;



const6(T,P) …
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);





On Friday, May 22, 2015 at 8:24:36 AM UTC-5, deniz wrote:

Thank you so much Renger,

You cannot imagine how important to get feedback/help from you.

I will certainly try the way you explained and hopefully will not bother you again…

I am very grateful to this group!

Regards.

On Tuesday, May 19, 2015 at 1:04:51 AM UTC-5, deniz wrote:

Dear All,

I have been trying to code if then, if else by using loop but some how I am struggling a great deal.

I keep getting error code 119 and I do not know how to fix it. I have searched all the old questions and asnwers but so far no luck.

If possible could you please let me know how can I fix the problem. Thank you in advance.



PARAMETERS



R1=0.3;
R2=0.6 ;
R3=0.8 ;



binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)



const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);



const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);


\

May-25-Model.gms (3.58 KB)
may14.txt (835 Bytes)

Sorry, but this is something for the more OR-inclined people to answer. I am just an economist…

Renger



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of deniz
Sent: Dienstag, 26. Mai 2015 06:56
To: gamsworld@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Dear Ranger,



Finally, I was able to run the model without error but now, I get a warning stating that





“An equation in the pre-triangular part of the model cannot be solved becaue the critical slack is at a bound”.

I am not sure what does this means. This is my first MINPL and I am not sure how can I solve the problem.

I appreciate your guidance very much. If it would be more appropriate, I can post separate question.

Again, Thank you very much for all your help.

Regards.




On Friday, May 22, 2015 at 11:36:17 AM UTC-5, deniz wrote:

Thank you very much Ranger.

I will write additional constraints.

Again, I appreciate your help very much.

On Friday, May 22, 2015 at 11:04:17 AM UTC-5, Renger van Nieuwkoop wrote:

I would probably write these lesser and greater conditions as additional constraints and keep the original constraint without these conditions.

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 17:32
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements





I am sorry for the confusion “l” means is less (<) than.



On Friday, May 22, 2015 at 10:22:12 AM UTC-5, Renger van Nieuwkoop wrote:

I don’t know what the sign | does in your equation

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 16:30
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Sorry,



I think I did not posted revised code for the cont6. I removed the loop and if statement and wrote it the way you explained for constraint 4, but still getting errors. Is this because there are less than or greater than (ranges) defined in the constraint.

Hopefully, this is the last question.

Thank you so so much for your help!





const6(t,p)… z3(t-1,p) * lambda(p,t+1) l R1+ R1 gt z2(t-1,p) *lambda(p,t+1) l R2+ R2 gt z1(t-1,p) *lambda(p,t+1) l R3+ (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) *lambda(p,t+1) gt R3=E=0;

On Friday, May 22, 2015 at 9:07:10 AM UTC-5, Renger van Nieuwkoop wrote:

You can’t use loops or variables in $ assignments in an equation.

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 15:59
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Dear Ranger,



Now, I am stuck at constraint 6. I tried to use the same exact method that you showed for constraint 4 but I am getting error, is this because there is a range that I am using for R values?

Thank you very much for all your help!







const6(t,p)… z3(t-1,p) * lambda(p,t+1) l R1+ R1 gt z2(t-1,p) *lambda(p,t+1) l R2+ R2 gt z1(t-1,p) *lambda(p,t+1) l R3+ (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) *lambda(p,t+1) gt R3=E=0;



const6(T,P) …
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);





On Friday, May 22, 2015 at 8:24:36 AM UTC-5, deniz wrote:

Thank you so much Renger,

You cannot imagine how important to get feedback/help from you.

I will certainly try the way you explained and hopefully will not bother you again…

I am very grateful to this group!

Regards.

On Tuesday, May 19, 2015 at 1:04:51 AM UTC-5, deniz wrote:

Dear All,

I have been trying to code if then, if else by using loop but some how I am struggling a great deal.

I keep getting error code 119 and I do not know how to fix it. I have searched all the old questions and asnwers but so far no luck.

If possible could you please let me know how can I fix the problem. Thank you in advance.



PARAMETERS



R1=0.3;
R2=0.6 ;
R3=0.8 ;



binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)



const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);



const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);


\

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+...@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+...@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.


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.

Deniz,

This message is not specific to MINLP or any other model type. It is specific to CONOPT, however.

Short version: your model is infeasible.

Long version: I can’t say it better than the CONOPT manual, which even includes pictures! See

http://www.gams.com/dd/docs/solvers/conopt/#CONOPT_PREPROCESSING_PRE_TRIANGULAR_VARIABLES_AND_CONSTRAINTS

-Steve

On Tue, May 26, 2015 at 12:55 AM, deniz wrote:

Dear Ranger,

Finally, I was able to run the model without error but now, I get a warning stating that


“An equation in the pre-triangular part of the model cannot be solved becaue the critical slack is at a bound”.

I am not sure what does this means. This is my first MINPL and I am not sure how can I solve the problem.

I appreciate your guidance very much. If it would be more appropriate, I can post separate question.

Again, Thank you very much for all your help.

Regards.



On Friday, May 22, 2015 at 11:36:17 AM UTC-5, deniz wrote:

Thank you very much Ranger.
I will write additional constraints.
Again, I appreciate your help very much.

On Friday, May 22, 2015 at 11:04:17 AM UTC-5, Renger van Nieuwkoop wrote:

I would probably write these lesser and greater conditions as additional constraints and keep the original constraint without these conditions.

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 17:32
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements





I am sorry for the confusion “l” means is less (<) than.



On Friday, May 22, 2015 at 10:22:12 AM UTC-5, Renger van Nieuwkoop wrote:

I don’t know what the sign | does in your equation

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 16:30
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Sorry,



I think I did not posted revised code for the cont6. I removed the loop and if statement and wrote it the way you explained for constraint 4, but still getting errors. Is this because there are less than or greater than (ranges) defined in the constraint.

Hopefully, this is the last question.

Thank you so so much for your help!





const6(t,p)… z3(t-1,p) * lambda(p,t+1) l R1+ R1 gt z2(t-1,p) *lambda(p,t+1) l R2+ R2 gt z1(t-1,p) *lambda(p,t+1) l R3+ (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) *lambda(p,t+1) gt R3=E=0;

On Friday, May 22, 2015 at 9:07:10 AM UTC-5, Renger van Nieuwkoop wrote:

You can’t use loops or variables in $ assignments in an equation.

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 15:59
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Dear Ranger,



Now, I am stuck at constraint 6. I tried to use the same exact method that you showed for constraint 4 but I am getting error, is this because there is a range that I am using for R values?

Thank you very much for all your help!







const6(t,p)… z3(t-1,p) * lambda(p,t+1) l R1+ R1 gt z2(t-1,p) *lambda(p,t+1) l R2+ R2 gt z1(t-1,p) *lambda(p,t+1) l R3+ (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) *lambda(p,t+1) gt R3=E=0;



const6(T,P) …
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);





On Friday, May 22, 2015 at 8:24:36 AM UTC-5, deniz wrote:

Thank you so much Renger,

You cannot imagine how important to get feedback/help from you.

I will certainly try the way you explained and hopefully will not bother you again…

I am very grateful to this group!

Regards.

On Tuesday, May 19, 2015 at 1:04:51 AM UTC-5, deniz wrote:

Dear All,

I have been trying to code if then, if else by using loop but some how I am struggling a great deal.

I keep getting error code 119 and I do not know how to fix it. I have searched all the old questions and asnwers but so far no luck.

If possible could you please let me know how can I fix the problem. Thank you in advance.



PARAMETERS



R1=0.3;
R2=0.6 ;
R3=0.8 ;



binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)



const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);



const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);


\

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+...@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+...@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.



\

Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com

Thank you all,

I am so grateful to all of your help and guidance!
Regards.


On Tuesday, May 26, 2015 at 9:24:28 AM UTC-5, Steven Dirkse wrote:

Deniz,

This message is not specific to MINLP or any other model type. It is specific to CONOPT, however.

Short version: your model is infeasible.

Long version: I can’t say it better than the CONOPT manual, which even includes pictures! See

http://www.gams.com/dd/docs/solvers/conopt/#CONOPT_PREPROCESSING_PRE_TRIANGULAR_VARIABLES_AND_CONSTRAINTS

-Steve

On Tue, May 26, 2015 at 12:55 AM, deniz wrote:

Dear Ranger,

Finally, I was able to run the model without error but now, I get a warning stating that


“An equation in the pre-triangular part of the model cannot be solved becaue the critical slack is at a bound”.

I am not sure what does this means. This is my first MINPL and I am not sure how can I solve the problem.

I appreciate your guidance very much. If it would be more appropriate, I can post separate question.

Again, Thank you very much for all your help.

Regards.



On Friday, May 22, 2015 at 11:36:17 AM UTC-5, deniz wrote:

Thank you very much Ranger.
I will write additional constraints.
Again, I appreciate your help very much.

On Friday, May 22, 2015 at 11:04:17 AM UTC-5, Renger van Nieuwkoop wrote:

I would probably write these lesser and greater conditions as additional constraints and keep the original constraint without these conditions.

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 17:32
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements





I am sorry for the confusion “l” means is less (<) than.



On Friday, May 22, 2015 at 10:22:12 AM UTC-5, Renger van Nieuwkoop wrote:

I don’t know what the sign | does in your equation

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 16:30
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Sorry,



I think I did not posted revised code for the cont6. I removed the loop and if statement and wrote it the way you explained for constraint 4, but still getting errors. Is this because there are less than or greater than (ranges) defined in the constraint.

Hopefully, this is the last question.

Thank you so so much for your help!





const6(t,p)… z3(t-1,p) * lambda(p,t+1) l R1+ R1 gt z2(t-1,p) *lambda(p,t+1) l R2+ R2 gt z1(t-1,p) *lambda(p,t+1) l R3+ (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) *lambda(p,t+1) gt R3=E=0;

On Friday, May 22, 2015 at 9:07:10 AM UTC-5, Renger van Nieuwkoop wrote:

You can’t use loops or variables in $ assignments in an equation.

Renger



From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of deniz
Sent: Freitag, 22. Mai 2015 15:59
To: gams...@googlegroups.com
Subject: Re: error code 119 for loop including several if else statements



Dear Ranger,



Now, I am stuck at constraint 6. I tried to use the same exact method that you showed for constraint 4 but I am getting error, is this because there is a range that I am using for R values?

Thank you very much for all your help!







const6(t,p)… z3(t-1,p) * lambda(p,t+1) l R1+ R1 gt z2(t-1,p) *lambda(p,t+1) l R2+ R2 gt z1(t-1,p) *lambda(p,t+1) l R3+ (1 - z1(t-1,p)) * (1 - z2(t-1,p)) * (z3(t-1,p) - 0) *lambda(p,t+1) gt R3=E=0;



const6(T,P) …
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);





On Friday, May 22, 2015 at 8:24:36 AM UTC-5, deniz wrote:

Thank you so much Renger,

You cannot imagine how important to get feedback/help from you.

I will certainly try the way you explained and hopefully will not bother you again…

I am very grateful to this group!

Regards.

On Tuesday, May 19, 2015 at 1:04:51 AM UTC-5, deniz wrote:

Dear All,

I have been trying to code if then, if else by using loop but some how I am struggling a great deal.

I keep getting error code 119 and I do not know how to fix it. I have searched all the old questions and asnwers but so far no luck.

If possible could you please let me know how can I fix the problem. Thank you in advance.



PARAMETERS



R1=0.3;
R2=0.6 ;
R3=0.8 ;



binary variables
Z1(T,P)
Z2(T,P)
Z3(T,P)



const4(t+1,p)…loop(t,
if((z1(t,p)=0)and (z2(t,p)=0) and (z3(t,p)=0), lambda(p,t+1)= Lambda(P,t)*A);
elseif ((z1(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B1);
elseif ((z2(t,p)=1), lambda(p,t+1)= Lambda(P,t)*B2);
elseif ((z3(t,p))=1, lambda(p,t+1)= Lambda(P,t)*B3);
);



const6(T,P) … loop (t,
If ((lambda(p,t+1) l R1),
z1(t,p)=0;
z2(t,p)=0;
elseif ((lambda(p,t+1)gt R1 and (lambda(p,t+1)l R2),
z1(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R2 and (lambda(p,t+1)l R3),
z2(t,p)=0;
z3(t,p)=0;
elseif ((lambda(p,t+1)gt R3),
z1(t,p)=0;
z2(t,p)=0;
z3(t,p)=0;
);


\

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+...@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+...@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+...@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.



\

Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdi...@gams.com
http://www.gams.com


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.