Skip to content

Conversation

@odow
Copy link
Member

@odow odow commented Jun 16, 2022

Closes #1906

julia> using JuMP, Ipopt

julia> model = read_from_file("test/FileFormats/MOF/nlp.mof.json")
A JuMP Model
Minimization problem with:
Variables: 4
Objective function type: AffExpr
`VariableRef`-in-`MathOptInterface.Interval{Float64}`: 4 constraints
Model mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.

julia> set_optimizer(model, Ipopt.Optimizer)

julia> optimize!(model)

******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
 Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit https://github.com/coin-or/Ipopt
******************************************************************************

This is Ipopt version 3.14.4, running with linear solver MUMPS 5.4.1.

Number of nonzeros in equality constraint Jacobian...:        4
Number of nonzeros in inequality constraint Jacobian.:        4
Number of nonzeros in Lagrangian Hessian.............:       24

Total number of variables............................:        4
                     variables with only lower bounds:        0
                variables with lower and upper bounds:        4
                     variables with only upper bounds:        0
Total number of equality constraints.................:        1
Total number of inequality constraints...............:        1
        inequality constraints with only lower bounds:        1
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        0

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  4.1009029e+00 3.59e+01 1.54e+00  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  6.3052937e+00 3.43e+01 2.33e+01  -1.0 5.89e+00    -  2.21e-03 4.20e-02h  1
   2  5.3929003e+00 3.42e+01 7.45e+02  -1.0 3.89e+00   2.0 6.10e-06 3.54e-03F  1
   3  6.6372159e+01 6.01e+00 2.27e+05  -1.0 3.78e+00   4.2 9.48e-04 4.80e-01h  2
   4  9.6419121e+01 4.30e-01 5.82e+04  -1.0 7.23e+01    -  1.59e-02 1.00e+00h  1
   5  9.4884972e+01 1.15e-03 3.12e+02  -1.0 1.47e+00    -  1.00e+00 1.00e+00h  1
   6  8.7460064e+01 8.24e-02 1.95e+01  -1.0 6.98e-01    -  1.00e+00 1.00e+00f  1
   7  8.9880566e+01 9.69e-03 3.14e+02  -1.0 7.37e-02   3.8 1.00e+00 1.00e+00h  1
   8  8.9330308e+01 3.71e-04 1.71e+01  -1.0 2.19e-01    -  1.00e+00 1.00e+00f  1
   9  8.9331900e+01 1.73e-06 4.10e+00  -1.0 2.16e-03   3.3 1.00e+00 1.00e+00h  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  10  8.0133699e+01 1.20e-01 1.86e+01  -1.0 2.30e+00    -  1.00e+00 1.00e+00f  1
  11  8.2219265e+01 7.59e-03 3.27e+01  -1.0 6.41e-02   2.8 1.00e+00 1.00e+00h  1
  12  7.5619844e+01 5.78e-02 1.78e+01  -1.0 2.89e+00    -  1.00e+00 1.00e+00f  1
  13  7.6383207e+01 1.10e-03 4.23e+00  -1.0 2.53e-02   2.3 1.00e+00 1.00e+00h  1
  14  5.6773756e+01 5.44e-01 1.90e+01  -1.0 1.15e+01    -  1.00e+00 1.00e+00f  1
  15  6.0190720e+01 2.74e-02 5.29e+00  -1.0 1.24e-01   1.8 1.00e+00 1.00e+00h  1
  16  2.8936531e+01 1.69e+00 2.27e+01  -1.0 3.26e+01    -  1.00e+00 1.00e+00f  1
  17  3.1904315e+01 6.64e-02 1.11e+00  -1.0 1.93e-01   1.4 1.00e+00 1.00e+00h  1
  18  2.0735088e+01 3.84e-01 1.76e+00  -1.0 9.22e+01    -  1.00e+00 1.99e-01f  1
  19  1.7114152e+01 5.20e-01 8.02e+00  -1.0 4.71e+01    -  1.00e+00 1.30e-01f  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  20  1.7278457e+01 3.55e-02 1.54e-02  -1.0 4.07e-01    -  1.00e+00 1.00e+00h  1
  21  1.7045230e+01 8.77e-03 6.88e-03  -1.7 4.41e-01    -  1.00e+00 1.00e+00h  1
  22  1.7017006e+01 2.40e-03 2.52e-03  -2.5 3.47e-02    -  1.00e+00 1.00e+00h  1
  23  1.7014119e+01 1.90e-04 1.03e-04  -3.8 6.30e-03    -  1.00e+00 1.00e+00h  1
  24  1.7014020e+01 2.57e-07 3.19e-07  -5.7 3.46e-04    -  1.00e+00 1.00e+00h  1
  25  1.7014017e+01 1.96e-11 2.80e-11  -8.6 3.31e-06    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 25

                                   (scaled)                 (unscaled)
Objective...............:   1.7014017145174137e+01    1.7014017145174137e+01
Dual infeasibility......:   2.7982229154407120e-11    2.7982229154407120e-11
Constraint violation....:   1.9625190361693967e-11    1.9625190361693967e-11
Variable bound violation:   7.6745495514174422e-09    7.6745495514174422e-09
Complementarity.........:   2.5297906848701602e-09    2.5297906848701602e-09
Overall NLP error.......:   2.5297906848701602e-09    2.5297906848701602e-09


Number of objective function evaluations             = 30
Number of objective gradient evaluations             = 26
Number of equality constraint evaluations            = 30
Number of inequality constraint evaluations          = 30
Number of equality constraint Jacobian evaluations   = 26
Number of inequality constraint Jacobian evaluations = 26
Number of Lagrangian Hessian evaluations             = 25
Total seconds in IPOPT                               = 2.357

EXIT: Optimal Solution Found.

julia> value.(all_variables(model))
4-element Vector{Float64}:
 0.9999999923254504
 4.742999641809567
 3.8211499817890435
 1.3794082897520368

julia> print(backend(model))

Minimize Nonlinear:
 var_1 * var_4 * (var_1 + var_2 + var_3) + var_3

Subject to:

VariableIndex-in-Interval{Float64}
 var_1  [1.0, 5.0]
 var_2  [1.0, 5.0]
 var_3  [1.0, 5.0]
 var_4  [1.0, 5.0]

Nonlinear
 var_1 * var_2 * var_3 * var_4 >= 25.0
 var_1 ^ 2.0 + var_2 ^ 2.0 + var_3 ^ 2.0 + var_4 ^ 2.0 == 40.0

@odow
Copy link
Member Author

odow commented Jun 16, 2022

cc @pulsipher here you go. This is probably only suitable for small to medium sized problems. Parsing the nonlinear JSON allocates quite a lot, so it won't be as efficient as .nl files.

@pulsipher
Copy link

Thanks for the fast turn around, I'll forward this on to the Pyomo folks.

@odow
Copy link
Member Author

odow commented Jun 16, 2022

I'll forward this on to the Pyomo folks.

I'd say it's still somewhat experimental performance-wise. I don't think we've had any serious stress-tests of it, so it'd be good to hear feedback.

@odow odow merged commit da49f1c into master Jun 16, 2022
@odow odow deleted the od/mof-nlp branch June 16, 2022 03:50
@odow odow mentioned this pull request Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

FileFormats.MOF: support nonlinear reading

3 participants