problem in use condition ( if or else)

hi
i am beginner student in GAMS software
i have 2 problems in my codes please help me if you have idea about follow problems:

  1. when i want to use condition of " if " i see the some of the errors in program run
    i want add this condition : if(x(t,i)=0) then p(t,i)=0 please help me to add this condition

  2. I dont know why the limited condition with name cons(t,i) in my codes never can run true!!! if i use l replace g in (p(t,i)*x(t,i)=l=sum(c$(ord(i) ord(c)),p(t,c)*x(t,c)*SINRth):wink: with every p the condition true. but i want to Gams assign p(t,i) greater than sum p(t,ic) i~c . ( p(t,i) is my variables in this codes p.lo(t,i)=10; p.up(t,i)=100)


    my code:

sets
i /12/
t /1
10/
alias(i,c);

variables
x
z
x(t,c)
p(t,i);
p.lo(t,i)=10;
p.up(t,i)=100;

binary variables x;

equations

cost
cons2(i)
cons(t,i);

cost… z=e=sum((t,i),p(t,i)x(t,i));
cons2(i)… sum(t,2
x(t,i))=e=4;
********************************************i want add the condition if(x(t,i)=0) then p(t,i)=0 in this place{ ************************************
cons(t,i)… p(t,i)*x(t,i)=g=sum(c$(ord(i) ord(c)),p(t,c)*x(t,c)*SINRth);
}
model test /all/;
solve test using minlp minimizing z;
display p.l,z.l,x.l,cons.l;



\

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

\

I am also beginner but i think you need to modify it means remove this limits

p.lo(t,i)=10;
p.up(t,i)=100;

and

instead of this define p as positive variable.

Define 2 more equations as

p(t,i)=L=100x(t,i);
and
p(t,i)=G=10
x(t,i);

So when x(t,i)=1,
then p(t,i)=10
thus you achieve your upper and lower limit of variable p(t,i).

and when x(t,i)=0;
then p(t,i)=0 which net result to p(t,i)=0…
so in this way you will get what you want!!



On Tuesday, May 28, 2013 9:54:47 AM UTC+3, ebrahim wrote:

hi
i am beginner student in GAMS software
i have 2 problems in my codes please help me if you have idea about follow problems:

  1. when i want to use condition of " if " i see the some of the errors in program run
    i want add this condition : if(x(t,i)=0) then p(t,i)=0 please help me to add this condition

  2. I dont know why the limited condition with name cons(t,i) in my codes never can run true!!! if i use l replace g in (p(t,i)*x(t,i)=l=sum(c$(ord(i) ord(c)),p(t,c)*x(t,c)*SINRth):wink: with every p the condition true. but i want to Gams assign p(t,i) greater than sum p(t,ic) i~c . ( p(t,i) is my variables in this codes p.lo(t,i)=10; p.up(t,i)=100)


    my code:

sets
i /12/
t /1
10/
alias(i,c);

variables
x
z
x(t,c)
p(t,i);
p.lo(t,i)=10;
p.up(t,i)=100;

binary variables x;

equations

cost
cons2(i)
cons(t,i);

cost… z=e=sum((t,i),p(t,i)x(t,i));
cons2(i)… sum(t,2
x(t,i))=e=4;
********************************************i want add the condition if(x(t,i)=0) then p(t,i)=0 in this place{ ************************************
cons(t,i)… p(t,i)*x(t,i)=g=sum(c$(ord(i) ord(c)),p(t,c)*x(t,c)*SINRth);
}
model test /all/;
solve test using minlp minimizing z;
display p.l,z.l,x.l,cons.l;



\

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

\

thank you so much!!!




On Tue, May 28, 2013 at 1:37 PM, Owais Nooruddin wrote:

I am also beginner but i think you need to modify it means remove this limits

p.lo(t,i)=10;
p.up(t,i)=100;

and

instead of this define p as positive variable.

Define 2 more equations as

p(t,i)=L=100x(t,i);
and
p(t,i)=G=10
x(t,i);

So when x(t,i)=1,
then p(t,i)=10
thus you achieve your upper and lower limit of variable p(t,i).

and when x(t,i)=0;
then p(t,i)=0 which net result to p(t,i)=0…
so in this way you will get what you want!!



On Tuesday, May 28, 2013 9:54:47 AM UTC+3, ebrahim wrote:

hi
i am beginner student in GAMS software
i have 2 problems in my codes please help me if you have idea about follow problems:

  1. when i want to use condition of " if " i see the some of the errors in program run
    i want add this condition : if(x(t,i)=0) then p(t,i)=0 please help me to add this condition

  2. I dont know why the limited condition with name cons(t,i) in my codes never can run true!!! if i use l replace g in (p(t,i)*x(t,i)=l=sum(c$(ord(i) ord(c)),p(t,c)*x(t,c)*SINRth):wink: with every p the condition true. but i want to Gams assign p(t,i) greater than sum p(t,ic) i~c . ( p(t,i) is my variables in this codes p.lo(t,i)=10; p.up(t,i)=100)


    my code:

sets
i /12/
t /1
10/
alias(i,c);

variables
x
z
x(t,c)
p(t,i);
p.lo(t,i)=10;
p.up(t,i)=100;

binary variables x;

equations

cost
cons2(i)
cons(t,i);

cost… z=e=sum((t,i),p(t,i)x(t,i));
cons2(i)… sum(t,2
x(t,i))=e=4;
********************************************i want add the condition if(x(t,i)=0) then p(t,i)=0 in this place{ ************************************
cons(t,i)… p(t,i)*x(t,i)=g=sum(c$(ord(i) ord(c)),p(t,c)*x(t,c)*SINRth);
}
model test /all/;
solve test using minlp minimizing z;
display p.l,z.l,x.l,cons.l;



\

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.



\

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

\

problem 1 solve tanks!!!
but problem number 2 dont solve with this Solution. I dont know why the limited condition with name cons(t,i) in my codes never can run true!!! if i use L instead of G in (p(t,i)*x(t,i)=L=sum(c$(ord(i) ord(c)),p(t,c)*x(t,c)*SINRth):wink: with every p the condition true. but i want to Gams assign p(t,i) greater than sum p(t,ic) i dont equal c . ( p(t,i) is my variables in this codes) . the objective function is minimum of p in all t,i . i hopes GAMS assign anothers P except p=10(minimum of p) to all of term until red condition satisfy. for example: p(t,1)=30 >= p(t,2)+p(t,3)+p(t,4) p(t,2)=10,p(t,3)=10,p(t,4)=10 !!


any body can help me to this problem??


thanks


On Tue, May 28, 2013 at 4:11 PM, Ebrahim Nikmaleki wrote:

thank you so much!!!




On Tue, May 28, 2013 at 1:37 PM, Owais Nooruddin wrote:

I am also beginner but i think you need to modify it means remove this limits

p.lo(t,i)=10;
p.up(t,i)=100;

and

instead of this define p as positive variable.

Define 2 more equations as

p(t,i)=L=100x(t,i);
and
p(t,i)=G=10
x(t,i);

So when x(t,i)=1,
then p(t,i)=10
thus you achieve your upper and lower limit of variable p(t,i).

and when x(t,i)=0;
then p(t,i)=0 which net result to p(t,i)=0…
so in this way you will get what you want!!



On Tuesday, May 28, 2013 9:54:47 AM UTC+3, ebrahim wrote:

hi
i am beginner student in GAMS software
i have 2 problems in my codes please help me if you have idea about follow problems:

  1. when i want to use condition of " if " i see the some of the errors in program run
    i want add this condition : if(x(t,i)=0) then p(t,i)=0 please help me to add this condition

  2. I dont know why the limited condition with name cons(t,i) in my codes never can run true!!! if i use l replace g in (p(t,i)*x(t,i)=l=sum(c$(ord(i) ord(c)),p(t,c)*x(t,c)*SINRth):wink: with every p the condition true. but i want to Gams assign p(t,i) greater than sum p(t,ic) i~c . ( p(t,i) is my variables in this codes p.lo(t,i)=10; p.up(t,i)=100)


    my code:

sets
i /12/
t /1
10/
alias(i,c);

variables
x
z
x(t,c)
p(t,i);
p.lo(t,i)=10;
p.up(t,i)=100;

binary variables x;

equations

cost
cons2(i)
cons(t,i);

cost… z=e=sum((t,i),p(t,i)x(t,i));
cons2(i)… sum(t,2
x(t,i))=e=4;
********************************************i want add the condition if(x(t,i)=0) then p(t,i)=0 in this place{ ************************************
cons(t,i)… p(t,i)*x(t,i)=g=sum(c$(ord(i) ord(c)),p(t,c)*x(t,c)*SINRth);
}
model test /all/;
solve test using minlp minimizing z;
display p.l,z.l,x.l,cons.l;



\

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




\

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

\

I understand where is my mistake!!! tanks


On Tue, May 28, 2013 at 4:31 PM, Ebrahim Nikmaleki wrote:

problem 1 solve tanks!!!
but problem number 2 dont solve with this Solution. I dont know why the limited condition with name cons(t,i) in my codes never can run true!!! if i use L instead of G in (p(t,i)*x(t,i)=L=sum(c$(ord(i) ord(c)),p(t,c)*x(t,c)*SINRth):wink: with every p the condition true. but i want to Gams assign p(t,i) greater than sum p(t,ic) i dont equal c . ( p(t,i) is my variables in this codes) . the objective function is minimum of p in all t,i . i hopes GAMS assign anothers P except p=10(minimum of p) to all of term until red condition satisfy. for example: p(t,1)=30 >= p(t,2)+p(t,3)+p(t,4) p(t,2)=10,p(t,3)=10,p(t,4)=10 !!


any body can help me to this problem??


thanks


On Tue, May 28, 2013 at 4:11 PM, Ebrahim Nikmaleki wrote:

thank you so much!!!




On Tue, May 28, 2013 at 1:37 PM, Owais Nooruddin wrote:

I am also beginner but i think you need to modify it means remove this limits

p.lo(t,i)=10;
p.up(t,i)=100;

and

instead of this define p as positive variable.

Define 2 more equations as

p(t,i)=L=100x(t,i);
and
p(t,i)=G=10
x(t,i);

So when x(t,i)=1,
then p(t,i)=10
thus you achieve your upper and lower limit of variable p(t,i).

and when x(t,i)=0;
then p(t,i)=0 which net result to p(t,i)=0…
so in this way you will get what you want!!



On Tuesday, May 28, 2013 9:54:47 AM UTC+3, ebrahim wrote:

hi
i am beginner student in GAMS software
i have 2 problems in my codes please help me if you have idea about follow problems:

  1. when i want to use condition of " if " i see the some of the errors in program run
    i want add this condition : if(x(t,i)=0) then p(t,i)=0 please help me to add this condition

  2. I dont know why the limited condition with name cons(t,i) in my codes never can run true!!! if i use l replace g in (p(t,i)*x(t,i)=l=sum(c$(ord(i) ord(c)),p(t,c)*x(t,c)*SINRth):wink: with every p the condition true. but i want to Gams assign p(t,i) greater than sum p(t,ic) i~c . ( p(t,i) is my variables in this codes p.lo(t,i)=10; p.up(t,i)=100)


    my code:

sets
i /12/
t /1
10/
alias(i,c);

variables
x
z
x(t,c)
p(t,i);
p.lo(t,i)=10;
p.up(t,i)=100;

binary variables x;

equations

cost
cons2(i)
cons(t,i);

cost… z=e=sum((t,i),p(t,i)x(t,i));
cons2(i)… sum(t,2
x(t,i))=e=4;
********************************************i want add the condition if(x(t,i)=0) then p(t,i)=0 in this place{ ************************************
cons(t,i)… p(t,i)*x(t,i)=g=sum(c$(ord(i) ord(c)),p(t,c)*x(t,c)*SINRth);
}
model test /all/;
solve test using minlp minimizing z;
display p.l,z.l,x.l,cons.l;



\

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.





\

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

\