Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couenne in Minizinc is unable to find an optimal solution #53

Open
indrajitsg opened this issue Jan 12, 2021 · 8 comments
Open

Couenne in Minizinc is unable to find an optimal solution #53

indrajitsg opened this issue Jan 12, 2021 · 8 comments

Comments

@indrajitsg
Copy link

Hi All,

I downloaded the latest version of Couenne available from the AMPL website and was testing on a very small problem which I am posting here. If I run the solver using AMPL, it gives the correct optimal solution. However if I run the same model through Minizinc, the solution that I get is sub-optimal.

Minizinc Model: model.mzn

int: nMOVES;
set of int: MOVES = 1..nMOVES;
int: timeBound;
array[MOVES] of int: power;
array[MOVES] of int: duration;
array[MOVES] of var 0..1: occur;
var int: totalPower = sum(i in MOVES) (power[i] * occur[i]);

constraint (sum(i in MOVES) (duration[i] * occur[i])) <= timeBound;

solve maximize totalPower;

output ["Moves to train: \(occur)\n" ++ "Power: \(totalPower)"];

Minizinc Data: data.dzn

nMOVES = 5;
timeBound = 10;
power = [6, 8, 5, 3, 4];
duration = [4, 5, 3, 2, 3];

AMPL Model: model.mod

set MOVES;
param timeBound > 0;
param power {MOVES} > 0;
param duration {MOVES} > 0;
var occur{i in MOVES} binary;

maximize totalPower: sum{i in MOVES} power[i] * occur[i];

subject to constTime: sum{i in MOVES} duration[i] * occur[i] <= timeBound;

AMPL Data: data.dat

data;

set MOVES := M1 M2 M3 M4 M5;

param timeBound:= 10;

param: power duration :=
     M1     6     4
     M2     8     5
     M3     5     3
     M4     3     2
     M5     4     3;
@indrajitsg indrajitsg changed the title Couenne in Minizinc is unable finds a sub-optimal solution Couenne in Minizinc is unable to find a sub-optimal solution Jan 12, 2021
@indrajitsg indrajitsg changed the title Couenne in Minizinc is unable to find a sub-optimal solution Couenne in Minizinc is unable to find an optimal solution Jan 12, 2021
@merraksh
Copy link
Member

merraksh commented Jan 14, 2021 via email

@indrajitsg
Copy link
Author

Hi @merraksh , yes you are correct. Couenne is an overkill for such a simple problem. The way we interface Minizinc with any of the solvers available from AMPL website is to specify in the configuration to use NL format. So Minizinc must be first converting it to NL format and then solving. Now I have tested the same model with many of the solvers including CBC, Bonmin, CPLEX, Gurobi and Baron. All of them are giving correct results. Hence the model translation is not an issue in my view.

The configuration file (couenne.msc) for Couenne (or any other solver from AMPL) needs to be placed in the directory: \MiniZinc\share\minizinc\solvers. The config file should have the following information:

{
  "id": "org.coin-or.couenne",
  "name": "Couenne",
  "description": "Couenne executable",
  "version": "0.5.7",
  "executable": "../../../bin/couenne-win64/couenne",
  "supportsFzn": false,
  "supportsNL": true
}

Regards,
Indrajit

@merraksh
Copy link
Member

merraksh commented Jan 14, 2021 via email

@kistamas
Copy link

Hi,
I have checked in detail this example, and it seems that the problem is with the interpretation of the solution by the interface between minizinc and couenne.
The solution file is

3
1
1
0
2
0
6
6
0
0.9999999999999999
1
1
0
16
objno 0 3

The value of the 5 decision variables are in lines -6 .. -2, and the second one is 0.99999. So, my guess is that the number 0.999999 rounded to 0, which is a problem.
Regards,
Tamas

@merraksh
Copy link
Member

merraksh commented Jan 21, 2021 via email

@indrajitsg
Copy link
Author

indrajitsg commented Jan 21, 2021

Hi @merraksh , I have placed the couenne.opt file in the same location as couenne.exe. But I don't think it is being used by couenne. What should I do? This is when I am running through Minizinc.

@merraksh
Copy link
Member

merraksh commented Jan 21, 2021 via email

@indrajitsg
Copy link
Author

indrajitsg commented Jan 22, 2021

@merraksh - thanks it is working now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants