Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
60 changes: 30 additions & 30 deletions src/nlp/meta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -273,36 +273,36 @@ NLPModelMeta(nvar::Int; x0::S = zeros(nvar), kwargs...) where {S} =

function NLPModelMeta(
meta::AbstractNLPModelMeta{T, S};
nvar::Int = meta.nvar,
x0::S = meta.x0,
lvar::S = meta.lvar,
uvar::S = meta.uvar,
nlvb = meta.nlvb,
nlvo = meta.nlvo,
nlvc = meta.nlvc,
ncon = meta.ncon,
y0::S = meta.y0,
lcon::S = meta.lcon,
ucon::S = meta.ucon,
nnzo = meta.nnzo,
nnzj = meta.nnzj,
lin_nnzj = meta.lin_nnzj,
nln_nnzj = meta.nln_nnzj,
nnzh = meta.nnzh,
lin = meta.lin,
minimize::Bool = meta.minimize,
islp::Bool = meta.islp,
name = meta.name,
variable_bounds_analysis::Bool = meta.variable_bounds_analysis,
constraint_bounds_analysis::Bool = meta.constraint_bounds_analysis,
sparse_jacobian::Bool = meta.sparse_jacobian,
sparse_hessian::Bool = meta.sparse_hessian,
grad_available::Bool = meta.grad_available,
jac_available::Bool = meta.jac_available,
hess_available::Bool = meta.hess_available,
jprod_available::Bool = meta.jprod_available,
jtprod_available::Bool = meta.jtprod_available,
hprod_available::Bool = meta.hprod_available,
nvar::Int = get_nvar(meta),
x0::S = get_x0(meta),
lvar::S = get_lvar(meta),
uvar::S = get_uvar(meta),
nlvb = get_nlvb(meta),
nlvo = get_nlvo(meta),
nlvc = get_nlvc(meta),
ncon = get_ncon(meta),
y0::S = get_y0(meta),
lcon::S = get_lcon(meta),
ucon::S = get_ucon(meta),
nnzo = get_nnzo(meta),
nnzj = get_nnzj(meta),
lin_nnzj = get_lin_nnzj(meta),
nln_nnzj = get_nln_nnzj(meta),
nnzh = get_nnzh(meta),
lin = get_lin(meta),
minimize::Bool = get_minimize(meta),
islp::Bool = get_islp(meta),
name = get_name(meta),
variable_bounds_analysis::Bool = get_variable_bounds_analysis(meta),
constraint_bounds_analysis::Bool = get_constraint_bounds_analysis(meta),
sparse_jacobian::Bool = get_sparse_jacobian(meta),
sparse_hessian::Bool = get_sparse_hessian(meta),
grad_available::Bool = get_grad_available(meta),
jac_available::Bool = get_jac_available(meta),
hess_available::Bool = get_hess_available(meta),
jprod_available::Bool = get_jprod_available(meta),
jtprod_available::Bool = get_jtprod_available(meta),
hprod_available::Bool = get_hprod_available(meta),
) where {T, S}
NLPModelMeta{T, S}(
nvar,
Expand Down
36 changes: 18 additions & 18 deletions src/nlp/tools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ end
Returns whether the problem has bounds on the variables.
"""
function has_bounds(meta::AbstractNLPModelMeta)
if meta.variable_bounds_analysis
return length(meta.ifree) < meta.nvar
if get_variable_bounds_analysis(meta)
return length(get_ifree(meta)) < get_nvar(meta)
else
return !all(lv -> isinf(lv), meta.lvar) || !all(uv -> isinf(uv), meta.uvar)
return !all(lv -> isinf(lv), get_lvar(meta)) || !all(uv -> isinf(uv), get_uvar(meta))
end
end

Expand All @@ -36,23 +36,23 @@ end

Returns whether the problem has bounds on the variables and no other constraints.
"""
bound_constrained(meta::AbstractNLPModelMeta) = (meta.ncon == 0) && has_bounds(meta)
bound_constrained(meta::AbstractNLPModelMeta) = (get_ncon(meta) == 0) && has_bounds(meta)

"""
unconstrained(nlp)
unconstrained(meta)

Returns whether the problem in unconstrained.
"""
unconstrained(meta::AbstractNLPModelMeta) = (meta.ncon == 0) && !has_bounds(meta)
unconstrained(meta::AbstractNLPModelMeta) = (get_ncon(meta) == 0) && !has_bounds(meta)

"""
linearly_constrained(nlp)
linearly_constrained(meta)

Returns whether the problem's constraints are known to be all linear.
"""
linearly_constrained(meta::AbstractNLPModelMeta) = (meta.ncon > 0) && (meta.nlin == meta.ncon)
linearly_constrained(meta::AbstractNLPModelMeta) = (get_ncon(meta) > 0) && (get_nlin(meta) == get_ncon(meta))

"""
equality_constrained(nlp)
Expand All @@ -62,10 +62,10 @@ Returns whether the problem's constraints are all equalities.
Unconstrained problems return false.
"""
function equality_constrained(meta::AbstractNLPModelMeta)
if meta.constraint_bounds_analysis
return (meta.ncon > 0) && (length(meta.jfix) == meta.ncon)
if get_constraint_bounds_analysis(meta)
return (get_ncon(meta) > 0) && (length(get_jfix(meta)) == get_ncon(meta))
else
return (meta.ncon > 0) && all(x -> x[1] == x[2], zip(meta.lcon, meta.ucon))
return (get_ncon(meta) > 0) && all(x -> x[1] == x[2], zip(get_lcon(meta), get_ucon(meta)))
end
end

Expand All @@ -77,10 +77,10 @@ Returns whether the problem's constraints are all inequalities.
Unconstrained problems return true.
"""
function inequality_constrained(meta::AbstractNLPModelMeta)
if meta.constraint_bounds_analysis
return (meta.ncon > 0) && (length(meta.jfix) == 0)
if get_constraint_bounds_analysis(meta)
return (get_ncon(meta) > 0) && (length(get_jfix(meta)) == 0)
else
return (meta.ncon > 0) && all(x -> x[1] != x[2], zip(meta.lcon, meta.ucon))
return (get_ncon(meta) > 0) && all(x -> x[1] != x[2], zip(get_lcon(meta), get_ucon(meta)))
end
end

Expand All @@ -91,10 +91,10 @@ Returns whether the problem has constraints and at least one of them is an equal
Unconstrained problems return false.
"""
function has_equalities(meta::AbstractNLPModelMeta)
if meta.constraint_bounds_analysis
return (meta.ncon > 0) && (length(meta.jfix) > 0)
if get_constraint_bounds_analysis(meta)
return (get_ncon(meta) > 0) && (length(get_jfix(meta)) > 0)
else
return (meta.ncon > 0) && !all(x -> x[1] != x[2], zip(meta.lcon, meta.ucon))
return (get_ncon(meta) > 0) && !all(x -> x[1] != x[2], zip(get_lcon(meta), get_ucon(meta)))
end
end

Expand All @@ -105,10 +105,10 @@ Returns whether the problem has constraints and at least one of them is an inequ
Unconstrained problems return false.
"""
function has_inequalities(meta::AbstractNLPModelMeta)
if meta.constraint_bounds_analysis
return (meta.ncon > 0) && (meta.ncon > length(meta.jfix))
if get_constraint_bounds_analysis(meta)
return (get_ncon(meta) > 0) && (get_ncon(meta) > length(get_jfix(meta)))
else
return (meta.ncon > 0) && !all(x -> x[1] == x[2], zip(meta.lcon, meta.ucon))
return (get_ncon(meta) > 0) && !all(x -> x[1] == x[2], zip(get_lcon(meta), get_ucon(meta)))
end
end

Expand Down
Loading