Skip to content

Commit

Permalink
Reapply "Attempted fix"
Browse files Browse the repository at this point in the history
This reverts commit 7999d74.
  • Loading branch information
ankane committed Oct 6, 2024
1 parent 7999d74 commit bb1ea5d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/or-tools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
require_relative "or_tools/comparison"
require_relative "or_tools/comparison_operators"
require_relative "or_tools/bool_var"
require_relative "or_tools/constant"
require_relative "or_tools/cp_model"
require_relative "or_tools/cp_solver"
require_relative "or_tools/cp_solver_solution_callback"
require_relative "or_tools/int_var"
require_relative "or_tools/knapsack_solver"
require_relative "or_tools/linear_constraint"
require_relative "or_tools/linear_expr"
require_relative "or_tools/constant"
require_relative "or_tools/mp_variable"
require_relative "or_tools/product_cst"
require_relative "or_tools/routing_index_manager"
Expand Down
4 changes: 3 additions & 1 deletion lib/or_tools/constant.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module ORTools
class Constant < LinearExpr
class Constant
include LinearExprUtils

def initialize(val)
@val = val
end
Expand Down
6 changes: 5 additions & 1 deletion lib/or_tools/linear_expr.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module ORTools
class LinearExpr
module LinearExprUtils
def solution_value
coeffs.sum { |var, coeff| var.solution_value * coeff }
end
Expand Down Expand Up @@ -82,4 +82,8 @@ def coerce(other)
end
end
end

class LinearExpr
include LinearExprUtils
end
end
4 changes: 3 additions & 1 deletion lib/or_tools/product_cst.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module ORTools
class ProductCst < LinearExpr
class ProductCst
include LinearExprUtils

attr_reader :expr, :coef

def initialize(expr, coef)
Expand Down
4 changes: 3 additions & 1 deletion lib/or_tools/sum_array.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module ORTools
class SumArray < LinearExpr
class SumArray
include LinearExprUtils

attr_reader :array

def initialize(array)
Expand Down

0 comments on commit bb1ea5d

Please sign in to comment.