Open tmigot opened 1 year ago
I ran the following script:
using Pkg Pkg.activate(".") using NLPModelsTest, AmplNLReader problems = ["BROWNDEN", "HS5", "HS6", "HS10", "HS11", "HS13", "HS14"] map( nlp -> print_nlp_allocations(nlp, test_allocs_nlpmodels(nlp)), (AmplModel(joinpath("test/problems", lowercase(problem) * ".nl"), safe = true) for problem in problems) )
and it returns the following allocations:
Problem name: test/problems/brownden.nl obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0 hess_coord!: ███████⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 grad!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0 hess_structure!: ████████████████████ 192.0 hprod!: ██████████████⋅⋅⋅⋅⋅⋅ 128.0 hess_op_prod!: ██████████████⋅⋅⋅⋅⋅⋅ 128.0 Problem name: test/problems/hs5.nl obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0 hess_coord!: ████████⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 grad!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0 hess_structure!: ████████████████████ 160.0 hprod!: ████████████████⋅⋅⋅⋅ 128.0 hess_op_prod!: ████████████████⋅⋅⋅⋅ 128.0 Problem name: test/problems/hs6.nl hprod_lag!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 jtprod!: ████████████████████ 1504.0 jprod!: ████████████████████ 1488.0 obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0 jac_op_transpose_prod!: ████████████████████ 1504.0 cons!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0 hess_coord!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 jac_op_prod!: ████████████████████ 1488.0 grad!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0 hess_lag_coord!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 hess_lag_op_prod!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 jac_coord!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 hess_structure!: ██⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 128.0 hprod!: ██⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 128.0 jac_structure!: ████⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 256.0 hess_op_prod!: ██⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 128.0 Problem name: test/problems/hs10.nl hprod_lag!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 jtprod!: ████████████████████ 1504.0 jprod!: ████████████████████ 1488.0 obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0 jac_op_transpose_prod!: ████████████████████ 1504.0 cons!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0 hess_coord!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 jac_op_prod!: ████████████████████ 1488.0 grad!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0 hess_lag_coord!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 hess_lag_op_prod!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 jac_coord!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 hess_structure!: ███⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 160.0 hprod!: ██⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 128.0 jac_structure!: ████⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 256.0 hess_op_prod!: ██⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 128.0 Problem name: test/problems/hs11.nl hprod_lag!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 jtprod!: ████████████████████ 1504.0 jprod!: ████████████████████ 1488.0 obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0 jac_op_transpose_prod!: ████████████████████ 1504.0 cons!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0 hess_coord!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 jac_op_prod!: ████████████████████ 1488.0 grad!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0 hess_lag_coord!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 hess_lag_op_prod!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 jac_coord!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 hess_structure!: ██⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 128.0 hprod!: ██⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 128.0 jac_structure!: ████⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 256.0 hess_op_prod!: ██⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 128.0 Problem name: test/problems/hs13.nl hprod_lag!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 jtprod!: ████████████████████ 1504.0 jprod!: ████████████████████ 1488.0 obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0 jac_op_transpose_prod!: ████████████████████ 1504.0 cons!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0 hess_coord!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 jac_op_prod!: ████████████████████ 1488.0 grad!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0 hess_lag_coord!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 hess_lag_op_prod!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 jac_coord!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 64.0 hess_structure!: ██⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 128.0 hprod!: ██⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 128.0 jac_structure!: ████⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 256.0 hess_op_prod!: ██⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 128.0 Problem name: test/problems/hs14.nl hprod_lag!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 80.0 jtprod!: ████████████████████ 1664.0 jprod!: ████████████████████ 1664.0 obj: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0 jac_op_transpose_prod!: ████████████████████ 1664.0 cons!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0 hess_coord!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 80.0 jac_op_prod!: ████████████████████ 1664.0 grad!: ⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 0.0 hess_lag_coord!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 80.0 hess_lag_op_prod!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 80.0 jac_coord!: █⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 80.0 hess_structure!: ██⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 128.0 hprod!: ██⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 160.0 jac_structure!: ████⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 320.0 hess_op_prod!: ██⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅ 160.0
A list (to be updated) of the things that allocate:
hprod!
hess_coord!
cons
jac_coord!
hess_structure!
jac_structure!
Cint
jprod
jtprod
Also, each call to jac_coord evaluates the constraints and allocates a vector. That would be easy to preallocate.
jac_coord
I ran the following script:
and it returns the following allocations:
A list (to be updated) of the things that allocate:
hprod!
hprod!
andhess_coord!
allocate because of thecons
call here https://github.com/JuliaSmoothOptimizers/AmplNLReader.jl/blob/f47a2f7564c21da7e6c14bc89c244d61fdd387a4/src/ampl_model.jl#L483 and there https://github.com/JuliaSmoothOptimizers/AmplNLReader.jl/blob/f47a2f7564c21da7e6c14bc89c244d61fdd387a4/src/ampl_model.jl#L649jac_coord!
https://github.com/JuliaSmoothOptimizers/AmplNLReader.jl/blob/f47a2f7564c21da7e6c14bc89c244d61fdd387a4/src/ampl_model.jl#L418hess_structure!
andjac_structure!
allocate in this test only because the input vectors are notCint
jprod
andjtprod
evaluate the jacobian matrix