Page 1 of 1

Linearization of Non-Linear equations

Posted: Tue Jul 19, 2022 10:30 am
by arvindmarandi
Hello GAMS Community, Warm Greetings!

Here is my problem, suppose I have a following objective function:

Code: Select all

objF.. obj =e= 10*x1 + 12*x2 - 20*z1 - 25*z2 - 10*z1*z2
Symbols (x1,x2) are variables.
Symbols (z1,z2) are binary variables.

I wishes to linearize this objective function as product term z1*z2 term making the equation non-linear.

From a course I have learned that, you can linearize the same equation by considering an another variable w. Such that, w = z1 * z2

Then add an another constraint, w ≥ z1 + z2 - 1, where w ∈ {0,1}.

I had made numerous attempt to do the same, but have failed. As soon has, I write this equation w = z1 * z2 in GAMS. It gives me an error 'A suffix is missing'.

Re: Linearization of Non-Linear equations

Posted: Tue Jul 19, 2022 2:34 pm
by abhosekar
Hi,

Couple of logical flaws here. You want to linearize z1*z2 but if you still have a constraint w= z1*z2, your entire formulation will still be nonlinear.
Second, even if you have w = z1*z2 constraint, you would want it to be a part of the model so it will be w =e= z1*z2.
w = z1*z2 is simply an assignment and z1 has no meaning (GAMS expects z1.l, z1.lo,... etc. i.e., suffix) this explains the error you get.

Now to the solution.
Simply remove w = z1*z2 from your model.

The constraint you mentioned w >= z1 + z2 - 1 replaces w = z1*z2.
You can look at it case by case.
if both are 1, then w >= 1 but since w is binary, it will be 1.
if one of them is 0, w >= 0 depending on minimize or maximize and the sign of w in the objective function this should force w = 0.
Similarly, if both are 0 then w >= -1 should make w = 0.

Hope this helps.

- Atharv

Re: Linearization of Non-Linear equations

Posted: Thu Jul 21, 2022 5:36 am
by arvindmarandi
Thanks for your help. It had solved my problem and improve my understanding of the syntax.

Re: Linearization of Non-Linear equations

Posted: Fri Jul 22, 2022 9:43 pm
by Manassaldi
Hello, you can also try this alternative:

Code: Select all

objF.. obj =e= 10*x1 + 12*x2 - 20*z1 - 25*z2 - 10*w
eq1.. 1 - z1 + 1 - z2 + w =g= 1
eq2.. z1 + 1 - w =g= 1
eq3.. z2 + 1 - w =g= 1
Best

Re: Linearization of Non-Linear equations

Posted: Tue Feb 28, 2023 12:06 am
by shih
Dear Experts:

I have an extremely nonlinear constraint like following:

Ttargetgap(t).. (V25(t)*T25(t)+V35(t)*T35(t)) - Ttarget(t) * (V25(t)+V35(t)) =E= Ttarget_p(t) * (V25(t) + V35(t)) - Ttarget_n(t) * (V25(t) + V35(t)) ;

In the constraint, only Ttarget(t) is a given/known parameter. All others are positive and unknown variables. My questions: is there a way to linearize the nonlinear equation to make it solvable? or any suggestions for other solution strategies? Thanks.

Shih

Re: Linearization of Non-Linear equations

Posted: Tue Feb 28, 2023 10:16 am
by bussieck
To me this looks like a quadratic constraint. Probably non-convex. Why do you want to linearize? "Just" solve it with a (global) QCP solver. There are a number of such solvers in the GAMS solver zoo.

-Michael

Re: Linearization of Non-Linear equations

Posted: Wed Mar 01, 2023 2:18 pm
by shih
I'm currently continuing my work on finding a suitable nonlinear solver as I've discovered that although one of them is effective for certain datasets, it doesn't work for all of them. Thanks Michael for the helpful advice!!!

Re: Linearization of Non-Linear equations

Posted: Thu Mar 02, 2023 2:32 pm
by Manassaldi
Hi, you can try replacing the products with a new variable and then linearize each one of them.

Ttargetgap(t).. (V25_T25(t) + V35_T35(t)) - Ttarget(t)*(V25(t)+V35(t)) =E= Ttarget_p_V25(t) + Ttarget_p_V35(t) - Ttarget_n_V25(t) - Ttarget_n_V35(t);

for example:
V25_T25(t) is a new variable and a linearization of the product V25(t)*T25(t)

You can try a McCormick linearization and then successively adjust the bounds. It is not a simple job, which is why there are solvers that do it automatically.
Best

Re: Linearization of Non-Linear equations

Posted: Fri Mar 03, 2023 3:11 pm
by shih
Thanks Manassaldi for your comments! Shih