Controlling inclusion of terms in equations

Hallo everybody,

I’m a beginner in working with GAMS and after a weak trying out, i’ve
my first
problem which i can’t solve so far. I’m trying to restrict with a $
condition whether a term is included
in an equation. Doesn’t matter which solver i’m using, i’m allways
getting errors.
Maybe someone can help me… thanks for your advices

Sets
i Kosten / Installation, Leitung /
j Nutzer / Gewerbe, Privat / ;

Table d(i,j) distance in thousands of miles
Gewerbe Privat
Installation 1000 2000
Leitung 1000 0 ;

Parameters
Va /10/
Vb /30/
x /3/
y /4/;

Variables
JN
Pzu
Pa
Pb
z total transportation costs in 1000s of dollars

*Binary variable JaNein1, JaNein2;

Equations
cost define objective function
demand Demand;

cost… z =e= d(‘Installation’,‘Gewerbe’)*Pzu
+d(‘Leitung’,‘Gewerbe’)$(Pzu)
+d(‘Installation’,‘Privat’)PaJaNein1+d(‘Installation’,‘Privat’)PbJaNein1;
demand … Pzu+Pa+Pb =e= Va+Vb ;

Model transport /all/ ;
option dnlp=minos;

solve transport using dnlp minimizing z ;
display Pzu.l, Pa.l, Pb.l;

\

DA
You can only restrict equations with condition when the term related with the condition is a parameter/scalar. Theoretically, if you restrict a variable with $ condition, you will generate a discontinuity in the search space which many solvers can’t handle. In this case you need to rebuild your model using binary variables.
Your model is a bit confusing you are using binary variables but you are not putting these variables in constraints and you are also using a dnlp solver. I suggest you to see in the gams model library for some transportation examples and you’ll probably solve your doubts.
Regards



2012/1/6 DA

Hallo everybody,

I’m a beginner in working with GAMS and after a weak trying out, i’ve
my first
problem which i can’t solve so far. I’m trying to restrict with a $
condition whether a term is included
in an equation. Doesn’t matter which solver i’m using, i’m allways
getting errors.
Maybe someone can help me… thanks for your advices

Sets
i Kosten / Installation, Leitung /
j Nutzer / Gewerbe, Privat / ;

Table d(i,j) distance in thousands of miles
Gewerbe Privat
Installation 1000 2000
Leitung 1000 0 ;

Parameters
Va /10/
Vb /30/
x /3/
y /4/;

Variables
JN
Pzu
Pa
Pb
z total transportation costs in 1000s of dollars

*Binary variable JaNein1, JaNein2;

Equations
cost define objective function
demand Demand;

cost… z =e= d(‘Installation’,‘Gewerbe’)*Pzu
+d(‘Leitung’,‘Gewerbe’)$(Pzu)
+d(‘Installation’,‘Privat’)PaJaNein1+d(‘Installation’,‘Privat’)PbJaNein1;
demand … Pzu+Pa+Pb =e= Va+Vb ;

Model transport /all/ ;
option dnlp=minos;

solve transport using dnlp minimizing z ;
display Pzu.l, Pa.l, Pb.l;


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Edson Valle
edsoncv@gmail.com



\

Edson Valle
edsoncv@gmail.com


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Yes, you’re absolutely right. My model is a little bit confusing. I’m
sorry
for that. Thanks for your answer. I didn’t find a solution till yet,
but maybe you can
tell me, how can manage this:

there’s a variable called ‘Pzu’. If this variable is 0, a term in
an equation
should not be considered. Otherwise, if ‘Pzu’ is greater than 0,
the term in the
equation should be included.

thanks a lot…
kind regards

\

On 1/6/12, Edson Cordeiro do Valle wrote:

   DA

You can only restrict equations with condition when the term related with the condition is a parameter/scalar. Theoretically, if you restrict a
variable with $ condition, you will generate a discontinuity in the search
space which many solvers can’t handle. In this case you need to rebuild
your model using binary variables.
Your model is a bit confusing you are using binary variables but you are
not putting these variables in constraints and you are also using a dnlp
solver. I suggest you to see in the gams model library for some
transportation examples and you’ll probably solve your doubts.
Regards

2012/1/6 DA

Hallo everybody,

I’m a beginner in working with GAMS and after a weak trying out, i’ve
my first
problem which i can’t solve so far. I’m trying to restrict with a $
condition whether a term is included
in an equation. Doesn’t matter which solver i’m using, i’m allways
getting errors.
Maybe someone can help me… thanks for your advices

Sets
i Kosten / Installation, Leitung /
j Nutzer / Gewerbe, Privat / ;

Table d(i,j) distance in thousands of miles
Gewerbe Privat
Installation 1000 2000
Leitung 1000 0 ;

Parameters
Va /10/
Vb /30/
x /3/
y /4/;

Variables
JN
Pzu
Pa
Pb
z total transportation costs in 1000s of dollars

*Binary variable JaNein1, JaNein2;

Equations
cost define objective function
demand Demand;

    cost.. z =e= d('Installation','Gewerbe')*Pzu

+d(‘Leitung’,‘Gewerbe’)$(Pzu)

+d(‘Installation’,‘Privat’)PaJaNein1+d(‘Installation’,‘Privat’)PbJaNein1;
demand … Pzu+Pa+Pb =e= Va+Vb ;

Model transport /all/ ;
option dnlp=minos;

solve transport using dnlp minimizing z ;
display Pzu.l, Pa.l, Pb.l;


“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.


Edson Valle
edsoncv@gmail.com


Edson Valle
edsoncv@gmail.com


“gamsworld” group.
To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to
gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/gamsworld?hl=en.


\

DA
This may depend: Pzu is an continuous or integer variable?
I think you should take a look at:
http://home.ubalt.edu/ntsbarsh/opre640a/partIII.htm
where many tips about integer programming is given.
Seems like your problem is not related to Gams, but with modeling, and the link above should help.

Regards

2012/1/7 DA

Yes, you’re absolutely right. My model is a little bit confusing. I’m
sorry
for that. Thanks for your answer. I didn’t find a solution till yet,
but maybe you can
tell me, how can manage this:

there’s a variable called ‘Pzu’. If this variable is 0, a term in
an equation
should not be considered. Otherwise, if ‘Pzu’ is greater than 0,
the term in the
equation should be included.

thanks a lot…
kind regards


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Edson Valle
edsoncv@gmail.com


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Thanks, this site looks very interesting.
Pzu is a continuous variabel. Is this important
for solving?
kind regars, thank you for your answer

\

DA
Only with continuous variables, you’ll probably not going to remove a equation based on the value of Pzu, here’s an example.
If Pzu (or other variable) is binary (can only have the 0 or 1 value) you can multiply the equation by Pzu and turn “on” or “off” the equation. But if Pzu is continuous, if you multiply your equation by it you’ll never make the equation exactly equal to zero ( since Pzu can have continuous values, such as, 0.1 or 0.01, or 0.0001).
So, to solve your problem you’ll probably have to use a mixed integer linear(or non-linear) approach, using continuous and binary (or integer) variables.
Take a look at the link at the previous e-mail
Regards

2012/1/9 DA

Thanks, this site looks very interesting.
Pzu is a continuous variabel. Is this important
for solving?
kind regars, thank you for your answer


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Edson Valle
edsoncv@gmail.com


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Thanks a lot, i managed it by using binary variables…
it’s working now.

kind regards

\