Skip to content

Commit

Permalink
Add error in slack model for nonsensical constraints (#125)
Browse files Browse the repository at this point in the history
* Add error in slack model for nonsensical constraints
  • Loading branch information
tmigot authored Sep 5, 2024
1 parent 722d517 commit 201fa59
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/slack-model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ function slack_meta(meta::AbstractNLPModelMeta{T, S}; name = meta.name * "-slack
x0 = similar(meta.x0, meta.nvar + ns)
x0[1:(meta.nvar)] .= meta.x0
x0[(meta.nvar + 1):end] .= zero(T)

if (length(x0) != length(lvar)) && any((meta.lcon .== -Inf) .& (meta.ucon .== Inf))
throw(error("NLPModels with constraints of the form -∞ ≤ cᵢ(x) ≤ ∞ are not supported by slack models."))
end

return NLPModelMeta{T, S}(
meta.nvar + ns,
x0 = x0,
Expand Down

0 comments on commit 201fa59

Please sign in to comment.