Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
41cbf79
Update api.jl
arnavk23 Jul 3, 2025
3d4a109
Update show.jl
arnavk23 Jul 3, 2025
7117f91
Update show.jl
arnavk23 Jul 3, 2025
f32d6d5
Update show.jl
arnavk23 Jul 3, 2025
c627047
Update show.jl
arnavk23 Jul 3, 2025
2bbbaa0
Update show.jl
arnavk23 Jul 3, 2025
9dbdedf
Update show.jl
arnavk23 Jul 3, 2025
1930ea4
Update show.jl
arnavk23 Jul 3, 2025
9162e5d
Update show.jl
arnavk23 Jul 3, 2025
7106d91
Update show.jl
arnavk23 Jul 3, 2025
87e998d
Update show.jl
arnavk23 Jul 3, 2025
ff0d461
Update show.jl
arnavk23 Jul 3, 2025
b5f853e
Update show.jl
arnavk23 Jul 3, 2025
3f97141
Update show.jl
arnavk23 Jul 3, 2025
21ee53f
Update show.jl
arnavk23 Jul 3, 2025
54c2c96
Update show.jl
arnavk23 Jul 3, 2025
e597add
Update show.jl
arnavk23 Jul 3, 2025
122ab79
Update src/nlp/show.jl
arnavk23 Jul 4, 2025
b3c2762
Update src/nlp/show.jl
arnavk23 Jul 4, 2025
64cf0f0
Update show.jl
arnavk23 Jul 4, 2025
d7751ea
Update show.jl
arnavk23 Jul 4, 2025
33c9921
Update show.jl
arnavk23 Jul 4, 2025
b6d2865
Update README.md
arnavk23 Jul 4, 2025
6d6fd7c
Update README.md
arnavk23 Jul 4, 2025
7eb1287
Update show.jl
arnavk23 Jul 4, 2025
6f4c8a5
Update show.jl
arnavk23 Jul 4, 2025
197c940
Update show.jl
arnavk23 Jul 4, 2025
5ebdbb9
Update show.jl
arnavk23 Jul 4, 2025
8f04cb5
Update README.md
arnavk23 Jul 4, 2025
0d459db
Update README.md
arnavk23 Jul 4, 2025
c43bcc3
Update show.jl
arnavk23 Jul 5, 2025
048c7e4
Update show.jl
arnavk23 Jul 5, 2025
686998b
Update src/nlp/show.jl
arnavk23 Jul 5, 2025
11e169d
Update src/nlp/show.jl
arnavk23 Jul 5, 2025
502ceb2
Update show.jl
arnavk23 Jul 5, 2025
5753fb9
Update show.jl
arnavk23 Jul 5, 2025
40e129a
Update show.jl
arnavk23 Jul 5, 2025
e23b911
Update show.jl
arnavk23 Jul 5, 2025
c954994
Update show.jl
arnavk23 Jul 6, 2025
9a7697c
Update show.jl
arnavk23 Jul 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/nlp/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,30 @@ function hess_op!(
return LinearOperator{T}(nlp.meta.nvar, nlp.meta.nvar, true, true, prod!, prod!, prod!)
end

"""
varscale(model::AbstractNLPModel)

Return a vector containing the scaling factors for each variable in the model.
This is typically used to normalize variables for numerical stability in solvers.

By default, the scaling is model-dependent. If not overridden by the model, a vector of ones
is returned. Inspired by the AMPL scaling conventions.
"""
function varscale end

"""
lagscale(model::AbstractNLPModel)

Return a vector of scaling factors for the Lagrange multipliers associated with constraints.
This can be used to improve numerical stability or condition number when solving KKT systems.
"""
function lagscale end

"""
conscale(model::AbstractNLPModel)

Return a vector of constraint scaling factors for the model.
These are typically used to normalize constraints to have similar magnitudes and improve
convergence behavior in nonlinear solvers.
"""
function conscale end
72 changes: 41 additions & 31 deletions src/nlp/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,37 +69,47 @@ end
Describe `meta` for the `show` function.
"""
function lines_of_description(m::AbstractNLPModelMeta)
V = [
length(m.ifree),
length(m.ilow),
length(m.iupp),
length(m.irng),
length(m.ifix),
length(m.iinf),
]
V = [sum(V); V]
S = ["All variables", "free", "lower", "upper", "low/upp", "fixed", "infeas"]
varlines = lines_of_hist(S, V)
push!(varlines, sparsityline("nnzh", m.nnzh, m.nvar * (m.nvar + 1) / 2))

V = [
length(m.jfree),
length(m.jlow),
length(m.jupp),
length(m.jrng),
length(m.jfix),
length(m.jinf),
]
V = [sum(V); V]
S = ["All constraints", "free", "lower", "upper", "low/upp", "fixed", "infeas"]
conlines = lines_of_hist(S, V)
push!(conlines, histline("linear", m.nlin, m.ncon), histline("nonlinear", m.nnln, m.ncon))
push!(conlines, sparsityline("nnzj", m.nnzj, m.nvar * m.ncon))

append!(varlines, repeat([" "^length(varlines[1])], length(conlines) - length(varlines)))
lines = varlines .* conlines

return lines
V = [
length(m.ifree),
length(m.ilow),
length(m.iupp),
length(m.irng),
length(m.ifix),
length(m.iinf),
]
V = [sum(V); V]
S = ["All variables", "free", "lower", "upper", "low/upp", "fixed", "infeas"]
varlines = lines_of_hist(S, V)
push!(varlines, sparsityline("nnzh", m.nnzh, m.nvar * (m.nvar + 1) ÷ 2))

V = [
length(m.jfree),
length(m.jlow),
length(m.jupp),
length(m.jrng),
length(m.jfix),
length(m.jinf),
]
V = [sum(V); V]
S = ["All constraints", "free", "lower", "upper", "low/upp", "fixed", "infeas"]
conlines = lines_of_hist(S, V)

# Extract lin_nnzj and nln_nnzj if available
lin_nnzj = try getfield(m, :lin_nnzj) catch; 0 end
nln_nnzj = try getfield(m, :nln_nnzj) catch; 0 end

append!(conlines, [
histline("linear", m.nlin, m.ncon),
histline("nonlinear", m.nnln, m.ncon),
sparsityline("nnzj", m.nnzj, m.nvar * m.ncon),
sparsityline("lin_nnzj", lin_nnzj, m.nlin * m.nvar),
sparsityline("nln_nnzj", nln_nnzj, m.nnln * m.nvar),
])

append!(varlines, repeat([" "^length(varlines[1])], length(conlines) - length(varlines)))
lines = varlines .* conlines

return lines
end

function Base.show(io::IO, m::AbstractNLPModelMeta)
Expand Down
Loading