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 11 differences in piecewise-linear approximation results #227

Open
4er4er4er opened this issue Dec 16, 2023 · 4 comments
Open

Gurobi 11 differences in piecewise-linear approximation results #227

4er4er4er opened this issue Dec 16, 2023 · 4 comments
Assignees

Comments

@4er4er4er
Copy link
Contributor

Gurobi 10 and 11 give somewhat different results for piecewise-linear approximation of this simple test problem:

var x;
minimize f: 0.2*x^2 + 1/(1+exp(-x));
subj to bounds: -1 <= x <= 1;

Gurobi 10 with nonconvex=2 reports:

Gurobi 10.0.3:   qp:nonconvex = 2
Gurobi 10.0.3: optimal solution; objective 0.4262084321
3531 simplex iterations
168 branching nodes
absmipgap=1.57774e-06, relmipgap=3.70181e-06

f = 0.4262088256
x = -0.5766163358

Since this is a feasible solution to a minimization of a piecewise-linear approximation, it's expected that the objective will be greater than the true solution. But it only differs by 1 in the 7th digit from the "true" objective value of 0.4262087102 returned by Gurobi 11 with funcnonlinear=1 and also by Knitro.

Gurobi 11 with funcnonlinear=-1 reports the following:

Gurobi 11.0.0:   pre:funcnonlinear = -1
Gurobi 11.0.0: optimal solution; objective 0.4260218562
394 simplex iterations
35 branching nodes

------------ WARNINGS ------------
WARNING:  "Solution Check"
     [ sol:chk:feastol=1e-06, :feastolrel=1e-06, :inttol=1e-05,
       :round='', :prec='' ]
Algebraic expression violations:
  - 1 constraint(s) of type ':exp',
        up to 2E-03 (abs), up to 9E-04 (rel)

WARNING:  "Solution Check (Idealistic)"
     [ sol:chk:feastol=1e-06, :feastolrel=1e-06, :inttol=1e-05,
       :round='', :prec='' ]
Objective value violations:
  - 1 objective value(s) violated,
        up to 2E-04 (abs), up to 5E-04 (rel)
AMPL may evaluate constraints/objectives differently
than the solver, see mp.ampl.com/solution-check.html.

f = 0.4262241326
x = -0.584057913

So the result has changed. Maybe that is OK, but here are two questions to consider:

  • Gurobi uses significantly fewer nodes and simplex iterations, but returns an objective value that is only correct to 4 places. Can this be explained by the change in the default behavior of FuncPieces previously mentioned by Gleb?

  • Is the long warning appropriate for the piecewise-linear case? In other situations, this kind of message warns that the solution may be incorrect, whereas here Gurobi has correctly found a solution to the p-l approximation that the user requested. If MP can tell when a p-l approximation has been solved, then an alternative to the warning would be to adjust the solve result message to something like this:
    Gurobi 11.0.0: optimal solution to p-l approximation; objective 0.4260218562

@glebbelov
Copy link
Contributor

  1. The changed result might be due to different default setting, but also due to a bug in PL approximation, submitted to Gurobi (ticket 62337).
  2. Reporting solution to p-l approximation can be difficult. First, the default behavior may change in future. Second, user might have .global suffixes.

What about compacting solution check warnings? It can be a table as follows, with the lines appearing only when there are violations of the corr. type:

WARNING: Solution check  violations
Type                   Max               MaxRel                 [Name]
Var Bounds       ..............
Linear Cons       ..............
Nonlinear Cons    ..............
Logical Cons      ..............
Expression 'exp'     .............
Expression 'numberof'   ............
Objective(s)       ...............
Nonlinear Cons*   ..............
Logical Cons*     .............
Nonlinear Obj(s)*     ..............
*: AMPL may evaluate constraints/objectives differently
than the solver, see mp.ampl.com/solution-check.html.

glebbelov added a commit that referenced this issue Dec 20, 2023
@glebbelov
Copy link
Contributor

Docu enhancement: https://mp.ampl.com/solution-check.html#warnings-format now contains a list of expressions.

But ideally we should have this list somewhere in the modeling guide?

glebbelov added a commit that referenced this issue Jan 9, 2024
@glebbelov
Copy link
Contributor

@4er4er4er @fdabrandao I am experimenting with compact format #200 which reports the following for the above example:

Gurobi 11.0.0: optimal solution; objective 0.4260218562
425 simplex iteration(s)
48 branching node(s)
 
------------ WARNINGS ------------
WARNING:  "Tolerance violations"
  Type                         MaxAbs [Name]   MaxRel [Name]
  objective(s)                 2E-04           5E-04         
Documentation: mp.ampl.com/modeling-tools.html.
WARNING:  "Tolerance violations (solver model)"
  Type                         MaxAbs [Name]   MaxRel [Name]
  expr ':exp'                  2E-03           9E-04         
 

Let me know any comments.

@glebbelov
Copy link
Contributor

Changing once more as follows:

WARNING:  "Tolerance violations"
  Type                         MaxAbs [Name]   MaxRel [Name]
  objective(s)                 2E-04           5E-04         
* expr ':exp'                  2E-03           9E-04         
*: Using the solver's aux variable values.
Documentation: mp.ampl.com/modeling-tools.html.

glebbelov added a commit that referenced this issue Mar 7, 2024
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

4 participants