Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Project: Testing 18.04
Views: 617
Kernel: Julia 1.x
VERSION
v"1.0.3"
using JuMP using Ipopt
m = Model(solver = IpoptSolver()) @variable(m, x, start = 0.0) @variable(m, y, start = 0.0) @NLobjective(m, Min, (1-x)^2 + 100(y-x^2)^2) solve(m) println("x = ", getvalue(x), " y = ", getvalue(y))
****************************************************************************** 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 http://projects.coin-or.org/Ipopt ****************************************************************************** This is Ipopt version 3.12.10, running with linear solver mumps. NOTE: Other linear solvers might be more efficient (see Ipopt documentation). Number of nonzeros in equality constraint Jacobian...: 0 Number of nonzeros in inequality constraint Jacobian.: 0 Number of nonzeros in Lagrangian Hessian.............: 3 Total number of variables............................: 2 variables with only lower bounds: 0 variables with lower and upper bounds: 0 variables with only upper bounds: 0 Total number of equality constraints.................: 0 Total number of inequality constraints...............: 0 inequality constraints with only lower bounds: 0 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 1.0000000e+00 0.00e+00 2.00e+00 -1.0 0.00e+00 - 0.00e+00 0.00e+00 0 1 9.5312500e-01 0.00e+00 1.25e+01 -1.0 1.00e+00 - 1.00e+00 2.50e-01f 3 2 4.8320569e-01 0.00e+00 1.01e+00 -1.0 9.03e-02 - 1.00e+00 1.00e+00f 1 3 4.5708829e-01 0.00e+00 9.53e+00 -1.0 4.29e-01 - 1.00e+00 5.00e-01f 2 4 1.8894205e-01 0.00e+00 4.15e-01 -1.0 9.51e-02 - 1.00e+00 1.00e+00f 1 5 1.3918726e-01 0.00e+00 6.51e+00 -1.7 3.49e-01 - 1.00e+00 5.00e-01f 2 6 5.4940990e-02 0.00e+00 4.51e-01 -1.7 9.29e-02 - 1.00e+00 1.00e+00f 1 7 2.9144630e-02 0.00e+00 2.27e+00 -1.7 2.49e-01 - 1.00e+00 5.00e-01f 2 8 9.8586451e-03 0.00e+00 1.15e+00 -1.7 1.10e-01 - 1.00e+00 1.00e+00f 1 9 2.3237475e-03 0.00e+00 1.00e+00 -1.7 1.00e-01 - 1.00e+00 1.00e+00f 1 iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls 10 2.3797236e-04 0.00e+00 2.19e-01 -1.7 5.09e-02 - 1.00e+00 1.00e+00f 1 11 4.9267371e-06 0.00e+00 5.95e-02 -1.7 2.53e-02 - 1.00e+00 1.00e+00f 1 12 2.8189505e-09 0.00e+00 8.31e-04 -2.5 3.20e-03 - 1.00e+00 1.00e+00f 1 13 1.0095040e-15 0.00e+00 8.68e-07 -5.7 9.78e-05 - 1.00e+00 1.00e+00f 1 14 1.3288608e-28 0.00e+00 2.02e-13 -8.6 4.65e-08 - 1.00e+00 1.00e+00f 1 Number of Iterations....: 14 (scaled) (unscaled) Objective...............: 1.3288608467480825e-28 1.3288608467480825e-28 Dual infeasibility......: 2.0183854587685121e-13 2.0183854587685121e-13 Constraint violation....: 0.0000000000000000e+00 0.0000000000000000e+00 Complementarity.........: 0.0000000000000000e+00 0.0000000000000000e+00 Overall NLP error.......: 2.0183854587685121e-13 2.0183854587685121e-13 Number of objective function evaluations = 36 Number of objective gradient evaluations = 15 Number of equality constraint evaluations = 0 Number of inequality constraint evaluations = 0 Number of equality constraint Jacobian evaluations = 0 Number of inequality constraint Jacobian evaluations = 0 Number of Lagrangian Hessian evaluations = 14 Total CPU secs in IPOPT (w/o function evaluations) = 0.202 Total CPU secs in NLP function evaluations = 0.051 EXIT: Optimal Solution Found. x = 0.9999999999999899 y = 0.9999999999999792
# adding a (linear) constraint @constraint(m, x + y == 10) solve(m) println("x = ", getvalue(x), " y = ", getvalue(y))
This is Ipopt version 3.12.10, running with linear solver mumps. NOTE: Other linear solvers might be more efficient (see Ipopt documentation). Number of nonzeros in equality constraint Jacobian...: 2 Number of nonzeros in inequality constraint Jacobian.: 0 Number of nonzeros in Lagrangian Hessian.............: 3 Total number of variables............................: 2 variables with only lower bounds: 0 variables with lower and upper bounds: 0 variables with only upper bounds: 0 Total number of equality constraints.................: 1 Total number of inequality constraints...............: 0 inequality constraints with only lower bounds: 0 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 1.3288608e-28 8.00e+00 1.56e-13 -1.0 0.00e+00 - 0.00e+00 0.00e+00 0 1 5.0288811e+03 1.78e-15 1.04e+04 -1.0 5.34e+00 - 1.00e+00 1.00e+00h 1 2 2.9288883e+02 0.00e+00 2.25e+03 -1.0 7.07e-01 - 1.00e+00 1.00e+00f 1 3 5.6537755e+00 0.00e+00 2.04e+02 -1.0 2.30e-01 - 1.00e+00 1.00e+00f 1 4 2.8949941e+00 0.00e+00 2.39e+00 -1.0 2.55e-02 - 1.00e+00 1.00e+00f 1 5 2.8946076e+00 0.00e+00 3.43e-04 -1.0 3.07e-04 - 1.00e+00 1.00e+00f 1 6 2.8946076e+00 0.00e+00 7.87e-12 -5.7 4.42e-08 - 1.00e+00 1.00e+00f 1 Number of Iterations....: 6 (scaled) (unscaled) Objective...............: 2.8946075504894604e+00 2.8946075504894604e+00 Dual infeasibility......: 7.8660411517716966e-12 7.8660411517716966e-12 Constraint violation....: 0.0000000000000000e+00 0.0000000000000000e+00 Complementarity.........: 0.0000000000000000e+00 0.0000000000000000e+00 Overall NLP error.......: 7.8660411517716966e-12 7.8660411517716966e-12 Number of objective function evaluations = 7 Number of objective gradient evaluations = 7 Number of equality constraint evaluations = 7 Number of inequality constraint evaluations = 0 Number of equality constraint Jacobian evaluations = 7 Number of inequality constraint Jacobian evaluations = 0 Number of Lagrangian Hessian evaluations = 6 Total CPU secs in IPOPT (w/o function evaluations) = 0.002 Total CPU secs in NLP function evaluations = 0.005 EXIT: Optimal Solution Found. x = 2.7011471240982194 y = 7.2988528759017814

IpOpt test

using Ipopt m = Model(solver=IpoptSolver()) @variable(m, 0 <= x <= 2 ) @variable(m, 0 <= y <= 30 ) @objective(m, Min, x*x+ 2x*y + y*y ) @constraint(m, x + y >= 1 ) print(m) status = solve(m)
Min x² + 2 x*y + y² Subject to x + y ≥ 1 0 ≤ x ≤ 2 0 ≤ y ≤ 30 This is Ipopt version 3.12.10, running with linear solver mumps. NOTE: Other linear solvers might be more efficient (see Ipopt documentation). Number of nonzeros in equality constraint Jacobian...: 0 Number of nonzeros in inequality constraint Jacobian.: 2 Number of nonzeros in Lagrangian Hessian.............: 3 Total number of variables............................: 2 variables with only lower bounds: 0 variables with lower and upper bounds: 2 variables with only upper bounds: 0 Total number of equality constraints.................: 0 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 3.9999920e-04 9.80e-01 6.40e-01 -1.0 0.00e+00 - 0.00e+00 0.00e+00 0 1 3.2681447e-03 9.43e-01 7.36e-01 -1.0 3.92e-01 - 3.28e-02 4.75e-02h 1 2 1.1040193e+00 0.00e+00 1.51e+00 -1.0 7.62e-01 - 6.37e-01 1.00e+00f 1 3 1.1237215e+00 0.00e+00 2.18e-03 -1.0 2.05e-02 - 9.99e-01 1.00e+00f 1 4 1.0015482e+00 0.00e+00 2.83e-08 -2.5 5.93e-02 - 1.00e+00 1.00e+00f 1 5 1.0001417e+00 0.00e+00 1.50e-09 -3.8 3.92e-03 - 1.00e+00 1.00e+00f 1 6 1.0000018e+00 0.00e+00 1.84e-11 -5.7 1.81e-03 - 1.00e+00 1.00e+00f 1 7 9.9999998e-01 0.00e+00 2.49e-14 -8.6 2.00e-04 - 1.00e+00 1.00e+00f 1 Number of Iterations....: 7 (scaled) (unscaled) Objective...............: 9.9999998250465849e-01 9.9999998250465849e-01 Dual infeasibility......: 2.4868995751603507e-14 2.4868995751603507e-14 Constraint violation....: 0.0000000000000000e+00 0.0000000000000000e+00 Complementarity.........: 3.1573161178575155e-09 3.1573161178575155e-09 Overall NLP error.......: 3.1573161178575155e-09 3.1573161178575155e-09 Number of objective function evaluations = 8 Number of objective gradient evaluations = 8 Number of equality constraint evaluations = 0 Number of inequality constraint evaluations = 8 Number of equality constraint Jacobian evaluations = 0 Number of inequality constraint Jacobian evaluations = 8 Number of Lagrangian Hessian evaluations = 7 Total CPU secs in IPOPT (w/o function evaluations) = 0.157 Total CPU secs in NLP function evaluations = 0.144 EXIT: Optimal Solution Found.
:Optimal
print(status)
Optimal
println("x = ", getvalue(x), "and y = ", getvalue(y))
x = 0.27864390938942063and y = 0.7213560818629086