Class: MIPPeR::Model
- Inherits:
-
Object
- Object
- MIPPeR::Model
- Defined in:
- lib/mipper/model.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#constraints ⇒ Object
readonly
Returns the value of attribute constraints.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Instance Method Summary collapse
-
#<<(obj) ⇒ Object
Add new objects (variables and constraints) to the model.
-
#compute_IIS ⇒ Object
Compute an irreducible inconsistent subsytem for the model.
-
#initialize ⇒ Model
constructor
A new instance of Model.
-
#objective_value ⇒ Object
The value of the objective function.
-
#optimize ⇒ Object
Optimize the model.
-
#sense=(sense) ⇒ Object
Set the sense of the model.
-
#status ⇒ Object
Get the status of the model.
-
#update ⇒ Object
Update the model.
-
#write_lp(filename) ⇒ Object
Write the model to a file in CPLEX LP format.
-
#write_mps(filename) ⇒ Object
Write the model to a file in MPS format.
Constructor Details
#initialize ⇒ Model
5 6 7 8 9 10 11 12 13 |
# File 'lib/mipper/model.rb', line 5 def initialize @sense = :min @variables = [] @constraints = [] @pending_variables = [] @pending_constraints = [] end |
Instance Attribute Details
#constraints ⇒ Object (readonly)
Returns the value of attribute constraints.
3 4 5 |
# File 'lib/mipper/model.rb', line 3 def constraints @constraints end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
3 4 5 |
# File 'lib/mipper/model.rb', line 3 def variables @variables end |
Instance Method Details
#<<(obj) ⇒ Object
Add new objects (variables and constraints) to the model
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mipper/model.rb', line 16 def <<(obj) case obj when Variable @pending_variables << obj when Constraint @pending_constraints << obj else fail TypeError end end |
#compute_IIS ⇒ Object
Compute an irreducible inconsistent subsytem for the model
70 71 72 |
# File 'lib/mipper/model.rb', line 70 def compute_IIS fail NotImplementedError end |
#objective_value ⇒ Object
The value of the objective function
75 76 77 |
# File 'lib/mipper/model.rb', line 75 def objective_value fail NotImplementedError end |
#optimize ⇒ Object
Optimize the model
60 61 62 |
# File 'lib/mipper/model.rb', line 60 def optimize fail NotImplementedError end |
#sense=(sense) ⇒ Object
Set the sense of the model
55 56 57 |
# File 'lib/mipper/model.rb', line 55 def sense=(sense) fail NotImplementedError end |
#status ⇒ Object
Get the status of the model
65 66 67 |
# File 'lib/mipper/model.rb', line 65 def status :unknown end |
#update ⇒ Object
Update the model
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mipper/model.rb', line 28 def update if @pending_variables.length == 1 add_variable @pending_variables.first elsif @pending_variables.length > 0 add_variables @pending_variables end @pending_variables = [] if @pending_constraints.length == 1 add_constraint @pending_constraints.first elsif @pending_constraints.length > 0 add_constraints @pending_constraints end @pending_constraints = [] end |
#write_lp(filename) ⇒ Object
Write the model to a file in CPLEX LP format
45 46 47 |
# File 'lib/mipper/model.rb', line 45 def write_lp(filename) fail NotImplementedError end |
#write_mps(filename) ⇒ Object
Write the model to a file in MPS format
50 51 52 |
# File 'lib/mipper/model.rb', line 50 def write_mps(filename) fail NotImplementedError end |