Dear all,
I want to model if b(y)<0, then c(y)=b(y), otherwise c(y)=0. Likewise if b(y)>0, then d(y)=b(y), otherwise d(y)=0. Where b,c,d are variables.
Attached is the model which is MINLP. I will really appreciate if someone can help me to formulate MILP formulation. Thanks in advance!
Kind regards,
Rofice
Conditional variables
Re: Conditional variables
Hi,
you could use a big M formulation and change your model as follows:
Note that you should make sure to choose bigM sufficiently large but as small as possible.
I hope this helps!
Fred
you could use a big M formulation and change your model as follows:
Code: Select all
$eolcom //
set y year /0*10/
parameter a(y) /
1 -5.5
2 -16.5
3 -20.5
4*10 30.5 /
display a;
scalar bigM /100/;
free variable
b
obj fake objective;
negative variable c ;
positive variable d ;
binary variable e ;
equation
eq1
eq2
eq3 Non-linear constraint that should be linearized
eq4 Non-linear constraint that should be linearized
eq11 ;
eq1(y)..
b(y) =e= a(y);
eq2(y)..
c(y)+d(y) =e= b(y);
eq3(y)..
c(y) =g= -bigM*(1-e(y));
eq4(y)..
d(y) =l= bigM*e(y);
eq11.. obj =e= 2;
model m /all/
option optcr = 0, minlp = baron;
solve m maximizing obj using minlp;
I hope this helps!
Fred
Re: Conditional variables
Hi,
Thank you very much for the codes! One more thing, you said bound for big M should be large enough but as small as possible. I am just wondering what will happen if a very very big value for big M is used?
Regards,
Rofice
Thank you very much for the codes! One more thing, you said bound for big M should be large enough but as small as possible. I am just wondering what will happen if a very very big value for big M is used?
Regards,
Rofice
Re: Conditional variables
For example, the solver might run into numerical difficulties.
Best,
Fred
Best,
Fred
Re: Conditional variables
Hi Fred,
Can you help me with formulating the following function: where, a(n) and a(n+1) are parameters, x and lambda(n) are variables.
Appreciate your help.
Thanks,
zar
Can you help me with formulating the following function: where, a(n) and a(n+1) are parameters, x and lambda(n) are variables.
Appreciate your help.
Thanks,
zar