Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinKaisermayer committed Dec 9, 2022
1 parent 7e70255 commit 8de3788
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/OptimizationMOI/src/moi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ function SciMLBase.__solve(cache::MOIOptimizationCache)
MOI.ObjectiveSense(),
cache.sense === Optimization.MaxSense ? MOI.MAX_SENSE : MOI.MIN_SENSE)

c_index = MOI.ConstraintIndex[]
if !isnothing(cache.cons_expr)
for cons_expr in cache.cons_expr
expr = _replace_parameter_indices!(deepcopy(cons_expr.args[2]), # f(x) == 0 or f(x) <= 0
Expand All @@ -176,9 +177,11 @@ function SciMLBase.__solve(cache::MOIOptimizationCache)
end
end
if is_eq(cons_expr)
MOI.add_constraint(opt_setup, func, MOI.EqualTo(Float64(-c)))
push!(c_index,
MOI.add_constraint(opt_setup, func, MOI.EqualTo(Float64(-c))))
elseif is_leq(cons_expr)
MOI.add_constraint(opt_setup, func, MOI.LessThan(Float64(-c)))
push!(c_index,
MOI.add_constraint(opt_setup, func, MOI.LessThan(Float64(-c))))
else
throw(MalformedExprException("$expr"))
end
Expand Down Expand Up @@ -213,7 +216,7 @@ function SciMLBase.__solve(cache::MOIOptimizationCache)
cache.opt,
minimizer,
minimum;
original = opt_setup,
original = (opt_setup = opt_setup, c_index = c_index),
retcode = opt_ret)
end

Expand Down

0 comments on commit 8de3788

Please sign in to comment.