Class: MIPPeR::Model
- Inherits:
-
Object
- Object
- MIPPeR::Model
- Defined in:
- lib/mipper/model.rb
Overview
Stores a linear programming model for a particular solver
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
Get the value of the objective function from a previous solution.
-
#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.
-
#variable_value(var) ⇒ Object
Get the value of a variable from a previous solution.
-
#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
Returns a new instance of Model.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/mipper/model.rb', line 6 def initialize @solution = nil @sense = :min @variables = [] @constraints = [] @pending_variables = [] @pending_constraints = [] end |
Instance Attribute Details
#constraints ⇒ Object (readonly)
Returns the value of attribute constraints.
4 5 6 |
# File 'lib/mipper/model.rb', line 4 def constraints @constraints end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
4 5 6 |
# File 'lib/mipper/model.rb', line 4 def variables @variables end |
Instance Method Details
#<<(obj) ⇒ Object
Add new objects (variables and constraints) to the model
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mipper/model.rb', line 18 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
65 66 67 |
# File 'lib/mipper/model.rb', line 65 def compute_iis fail NotImplementedError end |
#objective_value ⇒ Object
Get the value of the objective function from a previous solution
70 71 72 |
# File 'lib/mipper/model.rb', line 70 def objective_value @solution.objective_value unless @solution.nil? end |
#optimize ⇒ Object
Optimize the model
51 52 53 |
# File 'lib/mipper/model.rb', line 51 def optimize fail NotImplementedError end |
#sense=(_sense) ⇒ Object
Set the sense of the model
46 47 48 |
# File 'lib/mipper/model.rb', line 46 def sense=(_sense) fail NotImplementedError end |
#status ⇒ Object
Get the status of the model
56 57 58 59 60 61 62 |
# File 'lib/mipper/model.rb', line 56 def status if @solution.nil? :unknown else @solution.status end end |
#update ⇒ Object
Update the model
30 31 32 33 |
# File 'lib/mipper/model.rb', line 30 def update update_variables update_constraints end |
#variable_value(var) ⇒ Object
Get the value of a variable from a previous solution
75 76 77 |
# File 'lib/mipper/model.rb', line 75 def variable_value(var) @solution.variable_values[var.index] unless @solution.nil? end |
#write_lp(_filename) ⇒ Object
Write the model to a file in CPLEX LP format
36 37 38 |
# File 'lib/mipper/model.rb', line 36 def write_lp(_filename) fail NotImplementedError end |
#write_mps(_filename) ⇒ Object
Write the model to a file in MPS format
41 42 43 |
# File 'lib/mipper/model.rb', line 41 def write_mps(_filename) fail NotImplementedError end |