## Linearization of Non-Linear equations Topic is solved

Problems with syntax of GAMS
arvindmarandi
User Posts: 8
Joined: 9 months ago

### Linearization of Non-Linear equations

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'.

abhosekar
Moderator Posts: 288
Joined: 2 years ago

### Re: Linearization of Non-Linear equations

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

arvindmarandi
User Posts: 8
Joined: 9 months ago

### Re: Linearization of Non-Linear equations

Thanks for your help. It had solved my problem and improve my understanding of the syntax.

Manassaldi
User Posts: 116
Joined: 6 years ago
Location: Rosario - Argentina

### Re: Linearization of Non-Linear equations

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

shih
User Posts: 8
Joined: 2 months ago

### Re: Linearization of Non-Linear equations

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

bussieck
Moderator Posts: 933
Joined: 6 years ago

### Re: Linearization of Non-Linear equations

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

shih
User Posts: 8
Joined: 2 months ago

### Re: Linearization of Non-Linear equations

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!!!

Manassaldi
User Posts: 116
Joined: 6 years ago
Location: Rosario - Argentina

### Re: Linearization of Non-Linear equations

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

shih
User Posts: 8
Joined: 2 months ago