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
Returns the value of attribute objective_function.
-
#terms ⇒ Object
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.
8 9 10 11 12 13 14 15 16 |
# File 'lib/ruby-cbc/ilp/objective.rb', line 8 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! cste = @terms.send(:pop_constant) puts "Removing constant [#{cste}] in objective" if cste != 0 @objective_function = objective_function end |
Instance Attribute Details
#objective_function ⇒ Object
Returns the value of attribute objective_function.
7 8 9 |
# File 'lib/ruby-cbc/ilp/objective.rb', line 7 def objective_function @objective_function end |
#terms ⇒ Object
Returns the value of attribute terms.
7 8 9 |
# File 'lib/ruby-cbc/ilp/objective.rb', line 7 def terms @terms end |
Instance Method Details
#to_s ⇒ Object
18 19 20 21 22 23 |
# File 'lib/ruby-cbc/ilp/objective.rb', line 18 def to_s str = "" str << (@objective_function == :max ? "Maximize" : "Minimize") str << "\n " str << terms.to_s end |