Class: Ilp::Objective
- Inherits:
-
Object
- Object
- Ilp::Objective
- Defined in:
- lib/ruby-cbc/ilp/objective.rb
Constant Summary collapse
- MINIMIZE =
:min- MAXIMIZE =
:max
Instance Attribute Summary collapse
-
#objective_function ⇒ Object
readonly
Returns the value of attribute objective_function.
-
#terms ⇒ Object
readonly
Returns the value of attribute terms.
Instance Method Summary collapse
-
#initialize(terms, objective_function = MAXIMIZE) ⇒ Objective
constructor
A new instance of Objective.
- #to_s ⇒ Object
Constructor Details
#initialize(terms, objective_function = MAXIMIZE) ⇒ Objective
Returns a new instance of Objective.
7 8 9 10 11 12 13 14 |
# File 'lib/ruby-cbc/ilp/objective.rb', line 7 def initialize(terms, objective_function = MAXIMIZE) @terms = terms @terms = Ilp::Term.new(@terms) if @terms.is_a? Ilp::Var @terms = Ilp::TermArray.new([@terms]) if @terms.is_a? Ilp::Term @terms.normalize! @terms.send(:pop_constant) @objective_function = objective_function end |
Instance Attribute Details
#objective_function ⇒ Object (readonly)
Returns the value of attribute objective_function.
6 7 8 |
# File 'lib/ruby-cbc/ilp/objective.rb', line 6 def objective_function @objective_function end |
#terms ⇒ Object (readonly)
Returns the value of attribute terms.
6 7 8 |
# File 'lib/ruby-cbc/ilp/objective.rb', line 6 def terms @terms end |
Instance Method Details
#to_s ⇒ Object
16 17 18 |
# File 'lib/ruby-cbc/ilp/objective.rb', line 16 def to_s "#{(@objective_function == :max ? 'Maximize' : 'Minimize')}\n #{terms}" end |