Skip to content

Commit 428ed32

Browse files
Fix integer bounds error in OptimizationMOI
Fixes #528 - Added Float64 conversion for bounds in MOI.GreaterThan and MOI.LessThan constraints to handle integer constraint vectors properly. Previously, passing integer vectors for lb/ub parameters would cause: ``` MathOptInterface.UnsupportedConstraint{MathOptInterface.VariableIndex, MathOptInterface.GreaterThan{Int64}} ``` Now integer bounds are automatically converted to Float64, matching the behavior in moi.jl and preventing confusing errors. Changes: - Convert evaluator.lb[i] to Float64 in MOI.GreaterThan constraint - Convert evaluator.ub[i] to Float64 in MOI.LessThan constraint 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent c5648ec commit 428ed32

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/OptimizationMOI/src/nlp.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,10 @@ function _add_moi_variables!(opt_setup, evaluator::MOIOptimizationNLPEvaluator)
490490

491491
for i in 1:num_variables
492492
if evaluator.lb !== nothing && evaluator.lb[i] > -Inf
493-
MOI.add_constraint(opt_setup, θ[i], MOI.GreaterThan(evaluator.lb[i]))
493+
MOI.add_constraint(opt_setup, θ[i], MOI.GreaterThan(Float64(evaluator.lb[i])))
494494
end
495495
if evaluator.ub !== nothing && evaluator.ub[i] < Inf
496-
MOI.add_constraint(opt_setup, θ[i], MOI.LessThan(evaluator.ub[i]))
496+
MOI.add_constraint(opt_setup, θ[i], MOI.LessThan(Float64(evaluator.ub[i])))
497497
end
498498
if evaluator.int !== nothing && evaluator.int[i]
499499
if evaluator.lb !== nothing && evaluator.lb[i] == 0 &&

0 commit comments

Comments
 (0)