Skip to content

Commit

Permalink
Handle nlp constraints expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaibhavdixit02 committed Dec 19, 2023
1 parent 08af6c0 commit 75d197b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion lib/OptimizationMOI/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ authors = ["Vaibhav Dixit <[email protected]> and contributors"]
version = "0.1.16"

[deps]
AmplNLWriter = "7c4d4715-977e-5154-bfe0-e096adeac482"
Ipopt_jll = "9cc047cb-c261-5740-88fc-0cf96f7bdcc7"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
Expand Down
6 changes: 3 additions & 3 deletions lib/OptimizationMOI/src/nlp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,13 @@ function MOI.objective_expr(evaluator::MOIOptimizationNLPEvaluator)
end

function MOI.constraint_expr(evaluator::MOIOptimizationNLPEvaluator, i)
# expr has the form f(x,p) == 0 or f(x,p) <= 0
# expr has the form f(x,p) == 0 or f(x,p) <= 0
cons_expr = deepcopy(evaluator.cons_expr[i].args[2])
compop = Symbol(evaluator.cons_expr[i].args[1])

Check warning on line 382 in lib/OptimizationMOI/src/nlp.jl

View check run for this annotation

Codecov / codecov/patch

lib/OptimizationMOI/src/nlp.jl#L381-L382

Added lines #L381 - L382 were not covered by tests
repl_getindex!(cons_expr)
_replace_parameter_indices!(cons_expr, evaluator.p)
_replace_variable_indices!(cons_expr)
lb, ub = Float64(evaluator.lcons[i]), Float64(evaluator.ucons[i])
return :($lb <= $cons_expr <= $ub)
return Expr(:call, compop, cons_expr, 0.0)

Check warning on line 386 in lib/OptimizationMOI/src/nlp.jl

View check run for this annotation

Codecov / codecov/patch

lib/OptimizationMOI/src/nlp.jl#L386

Added line #L386 was not covered by tests
end

function _add_moi_variables!(opt_setup, evaluator::MOIOptimizationNLPEvaluator)
Expand Down

0 comments on commit 75d197b

Please sign in to comment.