-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Description
This is a corner case, where we should probably on the behavior.
We have several ways to access the constraints function: cons!/cons
, cons_nln
and cons_lin
, and objcons
. How should these behave when applied on an unconstrained problems? I see 3 options:
- Business as usual: evaluate cons (hoping it doesn't break in case the NLPModel has not implemented this function - but that's a normal error in this case), and increase counters.
- Increase counters (because the user called the function), but try to skip the evaluation.
function cons!(nlp::AbstractNLPModel, x::AbstractVector, cx::AbstractVector)
@lencheck nlp.meta.nvar x
@lencheck nlp.meta.ncon cx
increment!(nlp, :neval_cons)
nlp.meta.nlin > 0 && cons_lin!(nlp, x, view(cx, nlp.meta.lin))
nlp.meta.nnln > 0 && cons_nln!(nlp, x, view(cx, nlp.meta.nln))
return cx
end
- Ignore completely the call to cons.
function cons!(nlp::AbstractNLPModel, x::AbstractVector, cx::AbstractVector)
@lencheck nlp.meta.nvar x
@lencheck nlp.meta.ncon cx
nlp.meta.ncon > 0 && increment!(nlp, :neval_cons)
nlp.meta.nlin > 0 && cons_lin!(nlp, x, view(cx, nlp.meta.lin))
nlp.meta.nnln > 0 && cons_nln!(nlp, x, view(cx, nlp.meta.nln))
return cx
end
- another option?
A related question is: How should objcons react to this situation?
Connected to JuliaSmoothOptimizers/NLPModelsTest.jl#26 and JuliaSmoothOptimizers/CUTEst.jl#327
Metadata
Metadata
Assignees
Labels
No labels