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

Issues with writeprob in Gurobi #218

Closed
4er4er4er opened this issue Jul 25, 2023 · 3 comments
Closed

Issues with writeprob in Gurobi #218

4er4er4er opened this issue Jul 25, 2023 · 3 comments
Assignees

Comments

@4er4er4er
Copy link
Contributor

Several cases of the Gurobi writeprob option are handled incorrectly by the MP interface. The following examples also show the ASL results, which are as intended.

  1. MP rejects quotes around a filename, with an "Unknown file type" error:
ampl: model multmip3.mod;
ampl: data multmip3.dat;
ampl: option gurobi_options 'writeprob="..\multmip3.lp"';

ampl: option solver gurobiasl;
ampl: solve;
Gurobi 10.0.1: writeprob="..\multmip3.lp"
Gurobi 10.0.1: optimal solution; objective 235625
282 simplex iterations
32 branch-and-cut nodes
plus 34 simplex iterations for intbasis

ampl: option solver gurobi;
ampl: solve;
Gurobi 10.0.1: tech:exportfile=..\multmip3.lp"
Unknown file type for file '..\multmip3.lp"'
ampl: 
  1. MP fails to write a Gurobi .sol file:
ampl: option gurobi_options 'writeprob=..\multmip3.sol';

ampl: option solver gurobiasl;
ampl: solve;
Gurobi 10.0.1: writeprob=..\multmip3.sol
Gurobi 10.0.1: optimal solution; objective 235625
282 simplex iterations
32 branch-and-cut nodes
plus 34 simplex iterations for intbasis

ampl: option solver gurobi;
ampl: solve;
Gurobi 10.0.1: tech:exportfile=..\multmip3.sol
Unable to retrieve attribute 'X'
ampl: 
  1. An LP file written with option gurobi_auxfiles rc; contains the AMPL names for variables, but generic names for constraints. Consider the following example:
ampl: option gurobi_options 'writeprob=..\multmip3.lp';

ampl: option solver gurobiasl;
ampl: option gurobiasl_auxfiles rc;
ampl: solve;
Gurobi 10.0.1: writeprob=..\multmip3asl.lp
Gurobi 10.0.1: optimal solution; objective 235625
282 simplex iterations
32 branch-and-cut nodes
plus 34 simplex iterations for intbasis

ampl: option solver gurobi;
ampl: option gurobi_auxfiles rc;
ampl: solve;
Gurobi 10.0.1: tech:exportfile=..\multmip3.lp
Gurobi 10.0.1: optimal solution; objective 235625
108 simplex iterations
1 branching nodes
ampl: 

File multmip3asl.lp contains, for instance,

Supply['PITT','plate']: Trans['PITT','FRA','plate']
   + Trans['PITT','DET','plate'] + Trans['PITT','WIN','plate']
   + Trans['PITT','STL','plate'] + Trans['PITT','FRE','plate']
   + Trans['PITT','LAF','plate'] = 300
Max_Serve['GARY']: Use['GARY','FRA'] + Use['GARY','DET']
   + Use['GARY','LAN'] + Use['GARY','WIN'] + Use['GARY','STL']
   + Use['GARY','FRE'] + Use['GARY','LAF'] <= 5

while multmip3.lp contains (with different ordering)

R0: Use['GARY','FRA'] + Use['GARY','DET'] + Use['GARY','LAN']
   + Use['GARY','WIN'] + Use['GARY','STL'] + Use['GARY','FRE']
   + Use['GARY','LAF'] <= 5
R32: Trans['PITT','FRA','plate'] + Trans['PITT','DET','plate']
   + Trans['PITT','WIN','plate'] + Trans['PITT','STL','plate']
   + Trans['PITT','FRE','plate'] + Trans['PITT','LAF','plate'] = 300

The same issue is observed when writing MPS files.

glebbelov added a commit that referenced this issue Jul 26, 2023
cvt:names=1 default
glebbelov added a commit that referenced this issue Jul 26, 2023
Option writesol
@glebbelov
Copy link
Contributor

Task 2: added option writesol for solution/basis/IIS etc. Note that writeprob existed as synonym for tech:exportfile (which is now tech:writemodel.) All file writing options in Gurobi are now:

tech:writegraph (writegraph, exportgraph)
      File to export conversion graph. Format: JSON Lines.

tech:writemodel (writeprob, writemodel)
      Specifies the name of a file where to export the model before solving
      it. This file name can have extension ".lp[.7zip]", ".mps", etc. Default
      = "" (don't export the model).

tech:writemodelonly (justwriteprob, justwritemodel)
      Specifies the name of a file where to export the model, do not solve it.
      This file name can have extension ".dlp", ".mps", etc. Default = ""
      (don't export the model).

tech:writepresolved (writepresolved, writepresolvedmodel, exportpresolvedfile)
      Specifies the name of a file where to export the presolved model before
      solving it. This file name can have extension ".lp", ".mps", etc.
      Default = "" (don't export the model).

tech:writesolution (writesol, writesolution)
      Specifies the name of a file where to export the solution or other
      result file. This file name can have extension ".sol[.tar.gz]", ".json",
      ".bas", ".ilp", etc. Default = "" (don't export results).

Task 3 was solved in #209.

@glebbelov
Copy link
Contributor

For compatibility with ASL, allow ".sol", ".mst", ".bas" etc with the writeprob option. Their writing is delayed to after solving. However this is not documented.

Moreover now allowing repeated use of writeprob and writesol; tech:exportfile restored as synonym. Current docu:

tech:writemodel (writeprob, writemodel, tech:exportfile)
      Specifies files where to export the model before solving (repeat the
      option for several files.) File name extensions can be ".lp[.7z]",
      ".mps", etc.

tech:writemodelonly (justwriteprob, justwritemodel)
      Specifies files where to export the model, no solving (option can be
      repeated.) File extensions can be ".dlp", ".mps", etc.

tech:writepresolved (writepresolved, writepresolvedmodel, exportpresolvedfile)
      Specifies the name of a file where to export the presolved model before
      solving it. This file name can have extension ".lp", ".mps", etc.
      Default = "" (don't export the model).

tech:writesolution (writesol, writesolution)
      Specifies the names of files where to export the solution and/or other
      result files in solver's native formats. Option can be repeated. File
      name extensions can be ".sol[.tar.gz]", ".json", ".bas", ".ilp", etc.

To be released next week, unless any remarks.

glebbelov added a commit that referenced this issue Jul 28, 2023
@glebbelov
Copy link
Contributor

Released, also works in Highs and Xpress.

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