diff --git a/lib/or_tools/solver.rb b/lib/or_tools/solver.rb index 296da91..e598447 100644 --- a/lib/or_tools/solver.rb +++ b/lib/or_tools/solver.rb @@ -7,21 +7,17 @@ def sum(arr) def add(expr) left, op, const = Utils.index_constraint(expr) - case op - when :<= - lb = -infinity - ub = const - when :>= - lb = const - ub = infinity - when :== - lb = const - ub = const - else - raise "todo: #{op}" - end - - constraint = constraint(lb, ub) + constraint = + case op + when :<= + self.constraint(-infinity, const) + when :>= + self.constraint(const, infinity) + when :== + self.constraint(const, const) + else + raise "todo: #{op}" + end left.each do |var, c| constraint.set_coefficient(var, c) end