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

gurobi_options format and echoing #220

Open
4er4er4er opened this issue Aug 7, 2023 · 3 comments
Open

gurobi_options format and echoing #220

4er4er4er opened this issue Aug 7, 2023 · 3 comments
Assignees

Comments

@4er4er4er
Copy link
Contributor

In build 20230728, gurobiasl recognizes a space or an = sign between an option name and the corresponding value. But gurobi only recognizes an = sign:

ampl: option gurobi_options 'nodemethod 0 iterlim 1000';

ampl: option solver gurobiasl;
ampl: solve;
Gurobi 10.0.2: nodemethod 0
iterlim 1000
Gurobi 10.0.2: optimal solution; objective 235625
280 simplex iterations
1 branch-and-cut nodes
plus 34 simplex iterations for intbasis

ampl: option solver gurobi;
ampl: solve;
Gurobi 10.0.2: mip:nodemethod=1
Unknown option or invalid key "0"

ampl: option gurobi_options 'nodemethod=0 iterlim=1000';
ampl: solve;
Gurobi 10.0.2: mip:nodemethod=0
lim:iter=1000
Gurobi 10.0.2: optimal solution; objective 235625
247 simplex iterations
1 branching nodes

Also, when outlev=1 is specified, the beginning of the log lists Gurobi names for options that were specified:

ampl: option gurobi_options 'outlev=1 nodemethod=0 iterlim=1000';
ampl: solve;
Gurobi 10.0.2: Set parameter LogToConsole to value 1
Set parameter NodeMethod to value 0
Set parameter IterationLimit to value 1000
Set parameter InfUnbdInfo to value 1
Gurobi Optimizer version 10.0.2 build v10.0.2rc0 (win64)

The AMPL names for the options are only echoed at the end of the log:

Optimal solution found (tolerance 1.00e-04)
Best objective 2.356250000000e+05, best bound 2.356250000000e+05, gap 0.0000%
tech:outlev=1
mip:nodemethod=0
lim:iter=1000
Gurobi 10.0.2: optimal solution; objective 235625
247 simplex iterations
1 branching nodes
ampl: 

The Gurobi names for the options are not helpful to most AMPL users, so it would be desirable to suppress them and to instead echo the AMPL option names at the beginning, like gurobiasl does:

ampl: option solver gurobiasl;
ampl: solve;
Gurobi 10.0.2: outlev=1
nodemethod=0
iterlim=1000
Set parameter OutputFlag to value 1
Set parameter InfUnbdInfo to value 1
Gurobi Optimizer version 10.0.2 build v10.0.2rc0 (win64)

(It would be really good if the few remaining stray Set parameter messages could also be suppressed, but I recall that that's more challenging.)

@glebbelov
Copy link
Contributor

@4er4er4er I cannot reproduce the output order. Both in Windows and Linux I see:

ampl: solve;
Gurobi 10.0.2: Set parameter LogToConsole to value 1
tech:outlev=1
Set parameter NodeMethod to value 0
mip:nodemethod=0
Set parameter IterationLimit to value 1000
lim:iter=1000
Set parameter InfUnbdInfo to value 1
Gurobi Optimizer version 10.0.2 build v10.0.2rc0 (win64)

(and nothing about options after that.) I'd need the exact test setup please. @mapgccv do you guess what's happening?

glebbelov added a commit that referenced this issue Aug 14, 2023
Allow 'outlev 1' instead of 'outlev=1', 'outlev ?', etc
glebbelov added a commit that referenced this issue Aug 14, 2023
Allowing space for '=' requires dedicated 'flagged' options (no value)
@4er4er4er
Copy link
Contributor Author

I did some further testing:

  1. I see the same output as you (the preferred output) when I run in a Windows Command Prompt window, or in a Google Colab window.
  2. I see the output that I reported, when I run in an "sw" command window, or in the AMPL IDE.

glebbelov pushed a commit that referenced this issue Aug 18, 2023
Need to flush console output for AMPL IDE and SW console
@glebbelov
Copy link
Contributor

Fixed, to appear in the next release. Tested in Windows IDE (assume SW works similarly).

Solution: flush console output.

Log:

ampl: option gurobi_options 'outlev=1 nodemethod=0 iterlim 1000 version';
ampl: solve;
Gurobi 10.0.2: Set parameter LogToConsole to value 1
  tech:outlev = 1
Set parameter NodeMethod to value 0
  mip:nodemethod = 0
Set parameter IterationLimit to value 1000
  lim:iter = 1000
  tech:version
AMPL/Gurobi Optimizer [10.0.2] (Windows AMD64), driver(20230817), MP(20230817)

Licensed to License for development and testing <[email protected]>.
Maintenance expires with version 20231231.
Using license file "C:\Users\gbelov\AMPL\ampl.lic".


Set parameter InfUnbdInfo to value 1
Gurobi Optimizer version 10.0.2 build v10.0.2rc0 (win64)
....

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