Skip to content

Commit

Permalink
Improved code [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Oct 6, 2024
1 parent f75fc13 commit dfc2cac
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions lib/or_tools/solver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dfc2cac

Please sign in to comment.