JuliaSmoothOptimizers / FletcherPenaltySolver.jl

Fletcher's penalty method for nonlinear optimization models
Other
9 stars 0 forks source link

Allocations in `FletcherPenaltyNLP` #85

Open tmigot opened 2 years ago

tmigot commented 2 years ago

I used the following script:

using Pkg
Pkg.activate(".")
using LinearAlgebra, NLPModels, FletcherPenaltySolver
using NLPModelsTest # main version of NLPModelsTest

using NLPModelsTest

problems = ["HS6", "MGH01Feas"]
σ, ρ, δ = 1e-5, 1e1, 1e-7
map(
  nlp -> print_nlp_allocations(nlp, test_allocs_nlpmodels(nlp, linear_api = true, exclude = [hess])),
  map(x -> FletcherPenaltyNLP(eval(Symbol(x))(), σ, ρ, δ, Val(1)), problems),
)
map(
  nlp -> print_nlp_allocations(nlp, test_allocs_nlpmodels(nlp, linear_api = true, exclude = [hess])),
  map(x -> FletcherPenaltyNLP(eval(Symbol(x))(), σ, ρ, δ, Val(2)), problems),
)

which returns

  Problem name: Fletcher penalization of HS6_manual
                        obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0
                      grad!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0
                     hprod!: ████████████████████ 5440.0
              hess_op_prod!: ████████████████████ 5440.0

  Problem name: Fletcher penalization of MGH01Feas_manual
                        obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0
                      grad!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0
                     hprod!: ████████████████████ 5648.0
              hess_op_prod!: ████████████████████ 5648.0

  Problem name: Fletcher penalization of HS6_manual
                        obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0
                      grad!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0
                     hprod!: ████████████████████ 288.0
              hess_op_prod!: ████████████████████ 288.0

  Problem name: Fletcher penalization of MGH01Feas_manual
                        obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0
                      grad!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0
                     hprod!: ████████████████████ 320.0
              hess_op_prod!: ████████████████████ 320.0
tmigot commented 2 years ago

After #86 , it is now

  Problem name: Fletcher penalization of HS6_manual
                        obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0
                      grad!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0
                     hprod!: ████████████████████ 5152.0
              hess_op_prod!: ████████████████████ 5152.0

  Problem name: Fletcher penalization of MGH01Feas_manual
                        obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0
                      grad!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0
                     hprod!: ████████████████████ 5328.0
              hess_op_prod!: ████████████████████ 5328.0

  Problem name: Fletcher penalization of HS6_manual
                        obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0
                      grad!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0
                     hprod!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0
              hess_op_prod!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0

  Problem name: Fletcher penalization of MGH01Feas_manual
                        obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0
                      grad!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0
                     hprod!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0
              hess_op_prod!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0

so with the second approximation of the hessian it is 0-allocations! The rest seems to come from the update of the operators...