JuliaSmoothOptimizers / JuliaSmoothOptimizers/NLPModels.jl

Constraint evaluation behavior for unconstrained problems

Open
#464 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
191
Forks
38
PR merge metrics
No merged PRs in 30d

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 https://github.com/JuliaSmoothOptimizers/NLPModelsTest.jl/issues/26 and https://github.com/JuliaSmoothOptimizers/CUTEst.jl/pull/327

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.