LDLFactorizations tutorial

This tutorial shows how to use the LDLFactorizations.jl linear solver to solve a problem from the CUTEst.jl (see this tutorial) collection with Penelopt.jl.

Extensions

Penelopt.jl uses an extension to load the LDLFactorizations.jl linear solver. Therefore, you need to load LDLFactorizations.jl. Our algorithm will throw a warning and switch to the default MUMPS solver if you try to use LDLFactorizations without loading the required package.

1. Load a CUTEst problem

In this example, we choose a medium size problem MSS1.

using CUTEst

nlp = CUTEstModel("MSS1")

2. Load LDLFactorizations

using LDLFactorizations

3. Solve with Penelopt

using Penelopt

stats = L2Penalty(nlp; linear_solver = "ldlt", print_level = 1)
┌ Info: 
│ This is Penelopt.jl v1.0.0.
│ Running with linear solver LDLFactorizations.jl v0.10.2.
│ 
│ ScaledModel{Float64, Vector{Float64}, CUTEst.CUTEstModel{Float64}, NLPModels.NLPModelMeta{Float64, Vector{Float64}}}
│   Problem name: MSS1 (scaled)
│    All variables: ████████████████████ 90     All constraints: ████████████████████ 73
│             free: ████████████████████ 90                free: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
│            lower: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                lower: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
│            upper: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                upper: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
│          low/upp: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0              low/upp: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
│            fixed: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                fixed: ████████████████████ 73
│           infeas: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               infeas: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
│             nnzh: ( 49.45% sparsity)   2070            linear: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
│                                                     nonlinear: ████████████████████ 73
│                                                          nnzj: ( 94.25% sparsity)   378
│                                                      lin_nnzj: (------% sparsity)
│                                                      nln_nnzj: ( 94.25% sparsity)   378
│ 
│   Counters:
│              obj: ████████████████████ 1                 grad: ████████████████████ 1                 cons: ████████████████████ 1
│         cons_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0             cons_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 jcon: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
│            jgrad: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                  jac: ████████████████████ 1              jac_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
│          jac_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                jprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0            jprod_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
│        jprod_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               jtprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0           jtprod_lin: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
│       jtprod_nln: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0                 hess: ████████████████████ 1                hprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
│            jhess: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0               jhprod: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0
└ 
[ Info: ------------------------------------------------------------------------------------------------------
[ Info: Iter   sIter  Objective       pfeas       dfeas       τ           ptol        dtol        ‖x‖
[ Info: ------------------------------------------------------------------------------------------------------
[ Info: 0      0      -4.0500000e+03  1.80e+02    8.90e+01    1.10e+02    1.00e+00    1.00e+00    9.49e+00
[ Info: 1      0      -4.0500000e+03  8.90e+01    8.79e-14    1.11e+02    1.00e+00    2.70e-06    9.49e+00
[ Info: 2      120    -1.6000000e+01  1.32e-13    1.47e-06    1.11e+02    1.34e-06    2.70e-06    1.00e+00
┌ Info: 
│ Number of Iterations: 2
│ 
│ 
│ Objective...........: -1.600000000000878e+01
│ Primal Feasibility..:  1.321720510816249e-13
│ Dual Feasibility....:  1.468656789074835e-06
│ 
│ 
└ EXIT: first_order.
println("status    : ", stats.status)
println("objective : ", stats.objective)
println("solution  : ", stats.solution)
status    : first_order
objective : -16.000000000008782
solution  : [3.185876942459815e-14, -1.0044588035526747e-14, 0.10993118971949603, 0.20719495998570872, 0.18635822258228427, 0.16664517057175643, 0.10993118972037197, 0.2071949599872283, 0.0764270546647458, -0.04054981379199118, 0.10993118971987298, 0.20719495998563067, 0.07642705466523593, -0.04054981379217408, 0.10993118972088024, 0.20719495998792348, 0.07642705466135316, -0.04054981379024266, 0.18635812676396252, 0.16664527773135085, 7.254805521820233e-14, -3.849181209926393e-14, 1.3937544730895211e-7, -1.558625672850297e-7, 0.07642705466265301, -0.04054981379086371, 0.10993118971895534, 0.2071949599844706, 7.964674651815571e-14, -2.511136334379382e-14, 5.047201691274783e-14, 7.5145577431658e-15, 0.07642705466908004, -0.040549813794325, 0.10993118971948666, 0.20719495998520915, 0.07642705466515202, -0.04054981379217242, 0.10993118971957305, 0.20719495998567866, 5.047201691647028e-14, 7.514557741090106e-15, 0.10993118971964777, 0.2071949599856881, 0.07642705466504435, -0.040549813792141, 7.964674651356434e-14, -2.5111363341613757e-14, 0.10993118971996083, 0.207194959985621, 0.07642705466477215, -0.04054981379212518, 5.047201691460567e-14, 7.514557741969545e-15, 7.964674650659032e-14, -2.51113633376667e-14, 0.07642705466879988, -0.040549813794142076, 0.1099311897195076, 0.20719495998533627, 0.07642705466516442, -0.040549813792178986, 0.10993118971957301, 0.20719495998567858, 5.047201691462571e-14, 7.514557742060468e-15, 0.07642705466511913, -0.040549813792120665, 8.674584228523841e-14, -1.173120373291471e-14, 8.674584228512133e-14, -1.1731203733509657e-14, 2.891529450420064e-14, -3.910410805625394e-15, 0.07642705466486872, -0.04054981379214213, 0.1099311897198027, 0.20719495998567344, 2.891529450463553e-14, -3.910410805851909e-15, 0.10993118971872884, 0.20719495998395607, 0.07642705466357645, -0.04054981379138793, 2.891529450412136e-14, -3.910410805536956e-15, 0.0764270546651957, -0.04054981379218702, 0.1099311897194775, 0.20719495998571758]

4. Finalize the CUTEst model

Once the CUTEst problem has been used, you should finalize it, see the CUTEst documentation.

finalize(nlp)
How To Check?

You can verify that LDLFactorizations.jl is correctly being used by inspecting the output of the solver with the option print_level > 1.