Class: ORTools::MathOpt::Model
- Inherits:
-
Object
- Object
- ORTools::MathOpt::Model
- Defined in:
- lib/or_tools/math_opt/model.rb
Instance Method Summary collapse
- #add_linear_constraint(expr) ⇒ Object
- #maximize(objective) ⇒ Object
- #minimize(objective) ⇒ Object
-
#solve(solver_type = :glop) ⇒ Object
TODO change default for MIP.
Instance Method Details
#add_linear_constraint(expr) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/or_tools/math_opt/model.rb', line 4 def add_linear_constraint(expr) left, op, const = Utils.index_constraint(expr) constraint = _add_linear_constraint left.each do |var, c| _set_coefficient(constraint, var, c) end case op when :<= _set_upper_bound(constraint, const) when :>= _set_lower_bound(constraint, const) when :== _set_lower_bound(constraint, const) _set_upper_bound(constraint, const) else raise ArgumentError, "Supported operations are ==, <=, and >=" end nil end |
#maximize(objective) ⇒ Object
25 26 27 28 |
# File 'lib/or_tools/math_opt/model.rb', line 25 def maximize(objective) set_objective(objective) _set_maximize end |
#minimize(objective) ⇒ Object
30 31 32 33 |
# File 'lib/or_tools/math_opt/model.rb', line 30 def minimize(objective) set_objective(objective) _set_minimize end |
#solve(solver_type = :glop) ⇒ Object
TODO change default for MIP
36 37 38 |
# File 'lib/or_tools/math_opt/model.rb', line 36 def solve(solver_type = :glop) _solve(solver_type) end |