Getting wrong answer for an MINLP Topic is solved

Solver related questions
Post Reply
parag_patil
User
User
Posts: 30
Joined: 2 years ago
Location: Ahmedabad
Contact:

Getting wrong answer for an MINLP

Post by parag_patil »

I should get x = 3 ; but I am getting x = 1 as the answer for following MINLP. Can you please tell me, why is it so?

Code: Select all

integer variable
x;
x.lo = 1;
x.up = 3;

scalar
p1 /5/
p2 /10/
p3 /15/;

variable cost, y;

equations con1_eqn;

con1_eqn..
y =e= (x-1)*(x-2)*p3 + (x-2)*(x-3)*p1 + (x-3)*(x-1)*p2;

model all_eqn /all/;

solve all_eqn maximize y using MINLP;

abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: Getting wrong answer for an MINLP

Post by abhosekar »

which solver are you using? If you are using a local solver, you should expect a local solution (which very well could be x=1).

try giving initial value
x.l=3;
After this you will find the global solution.

- Atharv
parag_patil
User
User
Posts: 30
Joined: 2 years ago
Location: Ahmedabad
Contact:

Re: Getting wrong answer for an MINLP

Post by parag_patil »

Thank you for your answer. Indeed, I got global solution when I wrote, x.l = 3.

But I did not understand two things:
1. What do you mean by 'local solver' ? I did not choose any. Meaning, I did not wrote any option. The solver is by default.

Code: Select all

--- DICOPT: Starting major iteration 1
--- DICOPT: Setting up first (relaxed) NLP.

CONOPT 3         34.3.0 rac355f3 Released Feb 25, 2021 WEI x86 64bit/MS Window

How to know, so and so is an appropriate solver to use?
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: Getting wrong answer for an MINLP

Post by abhosekar »

You are using the default solver but you can choose the solver by using
option minlp = <solver_name>;

You are using DICOPT which can handle nonconvexities but does not necessarily find the global optimum.
Based on your license, you can try a solver such as baron.

For more details on solvers and their abilities, please refer to 'model types' table here https://www.gams.com/latest/docs/S_MAIN.html
The ones with * are deterministic global solvers. Please also read the paragraphs following the table where the difference in local vs global solvers is described.

- Atharv
Post Reply