Class: MIPPeR::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/mipper/model.rb

Direct Known Subclasses

CbcModel, GLPKModel, GurobiModel, LPSolveModel

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeModel



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

#constraintsObject (readonly)

Returns the value of attribute constraints.



3
4
5
# File 'lib/mipper/model.rb', line 3

def constraints
  @constraints
end

#variablesObject (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_IISObject

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_valueObject

The value of the objective function



75
76
77
# File 'lib/mipper/model.rb', line 75

def objective_value
  fail NotImplementedError
end

#optimizeObject

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

#statusObject

Get the status of the model



65
66
67
# File 'lib/mipper/model.rb', line 65

def status
  :unknown
end

#updateObject

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