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.
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 LDLFactorizations3. 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.
│
│ Problem name: MSS1
│ 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
│
└
[ Info: ------------------------------------------------------------------------------------------------------
[ Info: Iter sIter Objective pfeas dfeas τ ptol dtol ‖x‖
[ Info: ------------------------------------------------------------------------------------------------------
[ Info: 0 0 -4.0500000e+03 8.90e+01 8.68e-14 1.10e+02 1.00e+00 1.49e-08 9.49e+00
[ Info: 1 0 -4.0500000e+03 8.90e+01 8.68e-14 1.11e+02 1.00e+00 1.49e-08 9.49e+00
[ Info: 2 50 -4.6724476e+01 4.38e-02 4.77e-09 9.43e+02 1.00e+00 1.49e-08 1.02e+00
[ Info: 3 121 -1.6000000e+01 8.88e-15 1.50e-09 9.43e+02 1.34e-06 1.49e-08 1.00e+00
┌ Info:
│ Number of Iterations: 3
│
│
│ Objective...........: -1.600000000000743e+01
│ Primal Feasibility..: 8.881784197001252e-15
│ Dual Feasibility....: 1.500249265096176e-09
│
│
└ EXIT: first_order.println("status : ", stats.status)
println("objective : ", stats.objective)
println("solution : ", stats.solution)status : first_order
objective : -16.000000000007425
solution : [0.12678411327681524, 0.12357703969148132, 1.71154631992831e-14, 5.43952132471714e-15, 0.2499840921314597, -0.0028202271561466553, 0.12319997885376896, -0.12639726694925849, 0.1267841132765345, 0.12357703969133414, 0.12319997885444016, -0.1263972669497315, 0.1267841132761336, 0.1235770396910277, 0.12319997885404643, -0.1263972669494569, 5.68379446079097e-14, -8.1498367286949e-16, 2.8098423817566873e-14, -2.8827438240863957e-14, 0.24998409213078485, -0.002820227227033015, -1.2551479485550346e-12, -1.1250896831912952e-10, 0.12678411327646916, 0.12357703969124237, 0.12319997885390124, -0.12639726694936546, 4.278866942249774e-14, 1.3598812283646613e-14, 0.1231999788540608, -0.1263972669494429, 0.1267841132761889, 0.12357703969105352, 5.6837846145189266e-14, -8.149630272911995e-16, 4.2468142485747995e-14, -1.4821156299815208e-14, 0.12319997885367992, -0.12639726694915276, 0.12678411327646258, 0.12357703969120785, 0.12319997885356637, -0.12639726694910813, 0.126784113276549, 0.12357703969127803, 4.27886449281353e-14, 1.3598855258952615e-14, 4.246815779918758e-14, -1.4821228645975085e-14, 0.12678411327596736, 0.12357703969092189, 0.12319997885413979, -0.12639726694948084, 0.12319997885381169, -0.12639726694924483, 0.1267841132763622, 0.12357703969115215, 5.68378433524078e-14, -8.14909559041204e-16, 0.12678411327659603, 0.1235770396913379, 0.12319997885367995, -0.1263972669491528, 4.246811184048991e-14, -1.4821186169872583e-14, 0.12319997885461796, -0.1263972669498564, 0.12678411327566147, 0.12357703969067997, 4.2788610329638893e-14, 1.359872149747892e-14, 1.8945947941200083e-14, -2.7169160066193e-16, 0.1267841132758026, 0.12357703969081754, 0.1231999788544905, -0.1263972669497256, 1.8945948820693407e-14, -2.716426182634388e-16, 0.12319997885401485, -0.12639726694945325, 0.12678411327642347, 0.12357703969125404, 1.894594882556925e-14, -2.7164259437930544e-16, 0.126784113276355, 0.12357703969115919, 0.12319997885394851, -0.12639726694935646]4. Finalize the CUTEst model
Once the CUTEst problem has been used, you should finalize it, see the CUTEst documentation.
finalize(nlp)