ampl / mp

An open-source library for mathematical programming
https://mp.ampl.com
Other
229 stars 42 forks source link

x-gurobi with iisfind=1 on Windows fails with "early end of file" #185

Closed fdabrandao closed 2 years ago

fdabrandao commented 2 years ago

Trying to find IIS for the following model with x-gurobi on Windows:

set I := 1..500;
var x{I} binary;
param v{i in I} := 1 + Irand224() mod 1000;
param w{i in I} := 1 + Irand224() mod 1000;
maximize value: sum{i in I} v[i] * x[i];
s.t. capacity: sum{i in I} w[i] * x[i] <= 1000;
s.t. minobj: sum{i in I} v[i] * x[i] >= sum{i in I} v[i]/2; 
option solver x-gurobi;
option gurobi_options "outlev=1 iisfind=1";
solve;

results into:

Error executing "solve" command:
early end of file reading C:\Users\username\AppData\Local\Temp\at5356.sol
glebbelov commented 2 years ago

When adding

write giis_win;

before solve;, i.e., making AMPL keep .nl/.sol files, the same error happens also with gurobi-asl.

glebbelov commented 2 years ago

gurobi-asl does this because in text mode Windows uses \n\r.

Fixed by 9ff3a2c writing to the file in binary mode only (still text format, MP has no binary .sol files export #142)