# The clnlbeam problem

Based on an AMPL model by Hande Y. Benson

Copyright (C) 2001 Princeton University All Rights Reserved

Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that the copyright notice and this permission notice appear in all supporting documentation.

Source: H. Maurer and H.D. Mittelman, "The non-linear beam via optimal control with bound state variables", Optimal Control Applications and Methods 12, pp. 19-31, 1991.

using JuMP
import Ipopt

function example_clnlbeam()
N = 1000
h = 1/N
alpha = 350
model = Model(Ipopt.Optimizer)
@variables(model, begin
-1 <= t[1:(N + 1)] <= 1
-0.05 <= x[1:(N + 1)] <= 0.05
u[1:(N + 1)]
end)
@NLobjective(
model,
Min,
sum(
0.5 * h * (u[i + 1]^2 + u[i]^2) +
0.5 * alpha * h * (cos(t[i + 1]) + cos(t[i]))
for i = 1:N
),
)
@NLconstraint(
model,
[i = 1:N],
x[i + 1] - x[i] - 0.5 * h * (sin(t[i + 1]) + sin(t[i])) == 0,
)
@constraint(
model,
[i = 1:N],
t[i + 1] - t[i] - 0.5 * h * u[i + 1] - 0.5 * h * u[i] == 0,
)
optimize!(model)
println("""
termination_status = $(termination_status(model)) primal_status =$(primal_status(model))
objective_value    = \$(objective_value(model))
""")
return
end

example_clnlbeam()
----------------------------------------------------------------------------
SCS v2.1.2 - Splitting Conic Solver
(c) Brendan O'Donoghue, Stanford University, 2012
----------------------------------------------------------------------------
Lin-sys: sparse-indirect, nnz in A = 3813, CG tol ~ 1/iter^(2.00)
eps = 1.00e-05, alpha = 1.50, max_iters = 5000, normalize = 1, scale = 1.00
acceleration_lookback = 10, rho_x = 1.00e-03
Variables n = 612, constraints m = 1813
Cones:	linear vars: 601
soc vars: 12, soc blks: 1
exp vars: 1200, dual exp vars: 0
Setup time: 6.92e-04s
----------------------------------------------------------------------------
Iter | pri res | dua res | rel gap | pri obj | dua obj | kap/tau | time (s)
----------------------------------------------------------------------------
0| 2.05e+20  5.75e+20  1.00e+00 -2.33e+22  3.63e+22  5.04e+22  6.18e-03
100| 2.20e-07  3.38e-05  8.02e-08  1.02e+02  1.02e+02  1.74e-14  3.31e-01
180| 2.70e-08  7.14e-06  1.27e-08  1.02e+02  1.02e+02  1.40e-14  5.89e-01
----------------------------------------------------------------------------
Status: Solved
Timing: Solve time: 5.89e-01s
Lin-sys: avg # CG iterations: 3.31, avg solve time: 7.42e-05s
Cones: avg projection time: 2.92e-03s
Acceleration: avg step time: 1.95e-04s
----------------------------------------------------------------------------
Error metrics:
dist(s, K) = 1.8426e-16, dist(y, K*) = 8.8818e-16, s'y/|s||y| = -7.8514e-12
primal res: |Ax + s - b|_2 / (1 + |b|_2) = 2.7028e-08
dual res:   |A'y + c|_2 / (1 + |c|_2) = 7.1357e-06
rel gap:    |c'x + b'y| / (1 + |c'x| + |b'y|) = 1.2737e-08
----------------------------------------------------------------------------
c'x = 101.9931, -b'y = 101.9931
============================================================================
----------------------------------------------------------------------------
SCS v2.1.2 - Splitting Conic Solver
(c) Brendan O'Donoghue, Stanford University, 2012
----------------------------------------------------------------------------
Lin-sys: sparse-indirect, nnz in A = 3857, CG tol ~ 1/iter^(2.00)
eps = 1.00e-05, alpha = 1.50, max_iters = 5000, normalize = 1, scale = 1.00
acceleration_lookback = 10, rho_x = 1.00e-03
Variables n = 623, constraints m = 1824
Cones:	linear vars: 624
exp vars: 1200, dual exp vars: 0
Setup time: 7.07e-04s
----------------------------------------------------------------------------
Iter | pri res | dua res | rel gap | pri obj | dua obj | kap/tau | time (s)
----------------------------------------------------------------------------
0| 2.04e+20  7.26e+20  1.00e+00 -3.07e+22  4.05e+22  6.21e+22  6.26e-03
100| 1.02e-06  4.99e-05  2.88e-07  1.18e+02  1.18e+02  1.17e-15  3.60e-01
200| 2.28e-06  5.11e-05  1.40e-06  1.18e+02  1.18e+02  1.07e-14  7.08e-01
220| 9.41e-08  5.93e-06  7.42e-08  1.18e+02  1.18e+02  6.68e-15  7.77e-01
----------------------------------------------------------------------------
Status: Solved
Timing: Solve time: 7.77e-01s
Lin-sys: avg # CG iterations: 5.18, avg solve time: 1.00e-04s
Cones: avg projection time: 3.17e-03s
Acceleration: avg step time: 1.97e-04s
----------------------------------------------------------------------------
Error metrics:
dist(s, K) = 1.1807e-15, dist(y, K*) = 0.0000e+00, s'y/|s||y| = -8.0429e-12
primal res: |Ax + s - b|_2 / (1 + |b|_2) = 9.4084e-08
dual res:   |A'y + c|_2 / (1 + |c|_2) = 5.9292e-06
rel gap:    |c'x + b'y| / (1 + |c'x| + |b'y|) = 7.4215e-08
----------------------------------------------------------------------------
c'x = 117.8507, -b'y = 117.8507
============================================================================
This is Ipopt version 3.13.2, running with linear solver mumps.
NOTE: Other linear solvers might be more efficient (see Ipopt documentation).

Number of nonzeros in equality constraint Jacobian...:     8000
Number of nonzeros in inequality constraint Jacobian.:        0
Number of nonzeros in Lagrangian Hessian.............:     4002

Total number of variables............................:     3003
variables with only lower bounds:        0
variables with lower and upper bounds:     2002
variables with only upper bounds:        0
Total number of equality constraints.................:     2000
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  3.5000000e+02 0.00e+00 0.00e+00  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
1  3.5000000e+02 0.00e+00 0.00e+00  -1.7 0.00e+00    -  1.00e+00 1.00e+00   0
2  3.5000000e+02 0.00e+00 0.00e+00  -3.8 0.00e+00  -2.0 1.00e+00 1.00e+00T  0
3  3.5000000e+02 0.00e+00 0.00e+00  -5.7 0.00e+00   0.2 1.00e+00 1.00e+00T  0
4  3.5000000e+02 0.00e+00 0.00e+00  -8.6 0.00e+00  -0.2 1.00e+00 1.00e+00T  0

Number of Iterations....: 4

(scaled)                 (unscaled)
Objective...............:   3.5000000000000318e+02    3.5000000000000318e+02
Dual infeasibility......:   0.0000000000000000e+00    0.0000000000000000e+00
Constraint violation....:   0.0000000000000000e+00    0.0000000000000000e+00
Complementarity.........:   2.5059035596802450e-09    2.5059035596802450e-09
Overall NLP error.......:   2.5059035596802450e-09    2.5059035596802450e-09

Number of objective function evaluations             = 5
Number of objective gradient evaluations             = 5
Number of equality constraint evaluations            = 5
Number of inequality constraint evaluations          = 0
Number of equality constraint Jacobian evaluations   = 5
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations             = 4
Total CPU secs in IPOPT (w/o function evaluations)   =      0.091
Total CPU secs in NLP function evaluations           =      0.006

EXIT: Optimal Solution Found.
termination_status = LOCALLY_SOLVED
primal_status      = FEASIBLE_POINT
objective_value    = 350.0000000000032

This page was generated using Literate.jl.