Modeling the absolute value

Problems with modeling
Manassaldi
User
User
Posts: 44
Joined: 10 months ago
Location: Rosario - Argentina

Re: Modeling the absolute value

Postby Manassaldi » 4 months ago

You can find some here (page 14): http://www.minlp.org/pdf/GBDEWOGrossmann.pdf
Th Basic Steps are simple, the difficult is the manipulation of the propositions.
Best regard!

PeterBe
User
User
Posts: 29
Joined: 8 months ago

Re: Modeling the absolute value

Postby PeterBe » 3 months ago

Hi guys, I have a further question:

I still have not fully understood how to modell the absolute value of a difference in GAMS. I have used the following equations for binary variables for modelling: abs(x(t) - y(t)):
eq_z_firstCondition(t).. z(t) =l= 2 - x(t) - y(t);
eq_z_secondCondition(t).. z(t) =l= x (t) + y(t);

but what if you don't have binary variables but for example a sum:
abs( (sum(t, x(t))) - (sum(t, y(t))).

How could I model something like that?

PeterBe
User
User
Posts: 29
Joined: 8 months ago

Re: Modeling the absolute value

Postby PeterBe » 3 months ago

Hi guys,

does nobody have a clue? I just want incoorporate the absolute value of:
abs( (sum(t, x(t))) - (sum(t, y(t))) (with x(t) and y(t) being binary variables)

Manassaldi suggest the following for binary variables:

Code: Select all

eq1(t).. 1 - x(t)  +    c(t) +    absvalue(t)   =g= 1;
eq2(t).. 1 - x(t)  + 1-c(t) + 1-absvalue(t)  =g= 1;
eq3(t)..      x(t)  + 1-c(t) +     absvalue(t)  =g= 1;
eq4(t)..      x(t)  +    c(t) +  1- absvalue(t) =g= 1;
eq5..        z =e= sum(t,absvalue(t) )
Let's say x(t) and c(t) are not binary variables. How would you model the absolute value of the difference between them: abs (x(t)-c(t))?

Manassaldi
User
User
Posts: 44
Joined: 10 months ago
Location: Rosario - Argentina

Re: Modeling the absolute value

Postby Manassaldi » 3 months ago

Hi again PeterBe, I think this can works

x(t) and c(t) are continuous variables
p(t) are binary variables
M is a sufficiently large number (BigM parameter)

if "p=1", by "eq3" (x-c) is greater than 0 so by "eq1" and "eq2" absvalue = x-c (the rest of equation are also satisfied)
if "p=0", by "eq6" (x-c) is lower than 0 so by "eq4" and "eq5" absvalue = c-x (the rest of equation are also satisfied)

eq1(t).. absvalue(t) =l= x(t) - c(t) + (1-p(t))*M;
eq2(t).. absvalue(t) =g= x(t) - c(t) - (1-p(t))*M;
eq3(t).. x(t) - c(t) =g= -(1-p(t))*M
eq4(t).. absvalue(t) =l= c(t) - x(t) + p(t)*M;
eq5(t).. absvalue(t) =g= c(t) - x(t) - p(t)*M;
eq6(t).. x(t) - c(t) =l= p(t)*M
eq7.. z =e= sum(t,absvalue(t))

All this restrictions are for "z = sum(t,abs(x(t)-c(t)))" with x and c continuous variables

Bye!

gnaeidj
User
User
Posts: 8
Joined: 7 months ago

Re: Modeling the absolute value

Postby gnaeidj » 2 months ago

Dear Friend
I've Written a MIQCP code which has an absolute value in its constraints and I don't know how exactly I must write it so that the code works.

here is the constraint:

sum((n,m,t),abs(z(n,m,t) - z(n,m,t+1)) =l= 2*j

the summation basically is based on t (time) and I want this absolute value constraint to work within my code

I'll be so thankful if you guide me

Best Reards
Ghassem

Manassaldi
User
User
Posts: 44
Joined: 10 months ago
Location: Rosario - Argentina

Re: Modeling the absolute value

Postby Manassaldi » 2 months ago

Hi,
What kind of variables are z and j?

gnaeidj
User
User
Posts: 8
Joined: 7 months ago

Re: Modeling the absolute value

Postby gnaeidj » 2 months ago

Hi,
Z is a binary variable and J is a scalar

actually the Z variable represents a line status (being in circuit or out of it) and J represents the maximum number of lines which can get out of service

I want to use the mentioned constraint to express the maximum number of switching in a system, but I don't know how to insert it into my codes, so that it works properly.

Manassaldi
User
User
Posts: 44
Joined: 10 months ago
Location: Rosario - Argentina

Re: Modeling the absolute value

Postby Manassaldi » 2 months ago

Hi, this constraints are equivalent to "sum((n,m,t),abs(z(n,m,t) - z(n,m,t+1)) =l= 2*j"
With the command "$" you must decide what happens with the last t

eq1(n,m,t).. 1 - z(n,m,t) + z(n,m,t+1) + absvalue(n,m,t) =g= 1;
eq2(n,m,t).. 1 - z(n,m,t) + 1-z(n,m,t+1) + 1-absvalue(n,m,t) =g= 1;
eq3(n,m,t).. z(n,m,t) + 1-z(n,m,t+1) + absvalue(n,m,t) =g= 1;
eq4(n,m,t).. z(n,m,t) + z(n,m,t+1) + 1-absvalue(n,m,t) =g= 1;
eq5.. sum((n,m,t),absvalue(n,m,t)) =l= 2*j;

Bye

gnaeidj
User
User
Posts: 8
Joined: 7 months ago

Re: Modeling the absolute value

Postby gnaeidj » 2 months ago

Thank you so much

gnaeidj
User
User
Posts: 8
Joined: 7 months ago

Re: Modeling the absolute value

Postby gnaeidj » 2 months ago

Just something I didn't catch
what did you mean by "$" command?


Who is online

Users browsing this forum: No registered users and 2 guests