-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added experimental support for MathOpt, and unified expression buildi…
…ng across linear, constraint, routing, and MathOpt
- Loading branch information
Showing
27 changed files
with
488 additions
and
416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
module ORTools | ||
class Comparison | ||
attr_reader :operator, :left, :right | ||
attr_reader :left, :op, :right | ||
|
||
def initialize(operator, left, right) | ||
@operator = operator | ||
@left = left | ||
@right = right | ||
end | ||
|
||
def to_s | ||
"#{left} #{operator} #{right}" | ||
def initialize(left, op, right) | ||
@left = Expression.to_expression(left) | ||
@op = op | ||
@right = Expression.to_expression(right) | ||
end | ||
|
||
def inspect | ||
"#<#{self.class.name} #{to_s}>" | ||
"#{@left.inspect} #{@op} #{@right.inspect}" | ||
end | ||
alias_method :to_s, :inspect | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,26 @@ | ||
module ORTools | ||
class Constant < LinearExpr | ||
def initialize(val) | ||
@val = val | ||
class Constant < Expression | ||
attr_reader :value | ||
|
||
def initialize(value) | ||
@value = value | ||
end | ||
|
||
def to_s | ||
@val.to_s | ||
# simplify Ruby sum | ||
def +(other) | ||
@value == 0 ? other : super | ||
end | ||
|
||
def add_self_to_coeff_map_or_stack(coeffs, multiplier, stack) | ||
coeffs[OFFSET_KEY] += @val * multiplier | ||
def inspect | ||
@value.to_s | ||
end | ||
end | ||
|
||
class FakeMPVariableRepresentingTheConstantOffset | ||
def solution_value | ||
1 | ||
def -@ | ||
Constant.new(-value) | ||
end | ||
end | ||
|
||
OFFSET_KEY = FakeMPVariableRepresentingTheConstantOffset.new | ||
def vars | ||
@vars ||= [] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.