From 75d197b71273c09880d5ecc830ee416bf36c43ab Mon Sep 17 00:00:00 2001 From: Vaibhav Dixit Date: Tue, 19 Dec 2023 13:40:41 -0500 Subject: [PATCH] Handle nlp constraints expressions --- lib/OptimizationMOI/Project.toml | 1 - lib/OptimizationMOI/src/nlp.jl | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/OptimizationMOI/Project.toml b/lib/OptimizationMOI/Project.toml index a5666dc7a..52fb07202 100644 --- a/lib/OptimizationMOI/Project.toml +++ b/lib/OptimizationMOI/Project.toml @@ -4,7 +4,6 @@ authors = ["Vaibhav Dixit 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" diff --git a/lib/OptimizationMOI/src/nlp.jl b/lib/OptimizationMOI/src/nlp.jl index 9a1bf5cbe..6b2289d8d 100644 --- a/lib/OptimizationMOI/src/nlp.jl +++ b/lib/OptimizationMOI/src/nlp.jl @@ -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]) 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) end function _add_moi_variables!(opt_setup, evaluator::MOIOptimizationNLPEvaluator)