Class: Solver

Inherits:
Object show all
Defined in:
lib/solvers/solvers.rb

Direct Known Subclasses

Cbc, Glpk, PCbc, PScip, Scip

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Solver

Returns a new instance of Solver.

Raises:

  • (StandardError)


2
3
4
5
6
7
# File 'lib/solvers/solvers.rb', line 2

def initialize(filename)
  @filename = filename
  @outfile = get_output_filename
  raise StandardError.new("Couldn't find solver #{executable}!") if `which #{executable}`.length == 0
  @solver_exists = true
end

Class Method Details

.exists?Boolean



25
26
27
# File 'lib/solvers/solvers.rb', line 25

def self.exists?
  return `which #{self.executable}`.length != 0
end

Instance Method Details

#executableObject



17
18
19
# File 'lib/solvers/solvers.rb', line 17

def executable
  self.class.executable
end

#get_output_filenameObject



9
10
11
# File 'lib/solvers/solvers.rb', line 9

def get_output_filename
  "/tmp/rulp-#{Random.rand(0..1000)}.sol"
end

#solver_exists?Boolean



21
22
23
# File 'lib/solvers/solvers.rb', line 21

def solver_exists?
  @solver_exists || false
end

#store_results(variables) ⇒ Object



13
14
15
# File 'lib/solvers/solvers.rb', line 13

def store_results(variables)
  puts "Not yet implemented"
end