Sha256: da4eb654460d2f45c7ed8f7fd1c1bd79be0c67d0737624506b6b25ae64ec8ccd
Contents?: true
Size: 822 Bytes
Versions: 2
Compression:
Stored size: 822 Bytes
Contents
class Cbc < Solver def solve if options[:parallel] command = "#{executable} #{@filename} %s %s threads 8 branch solution #{@outfile}" else command = "#{executable} #{@filename} %s %s branch solution #{@outfile}" end command %= [ options[:gap] ? "ratio #{options[:gap]}":"", options[:node_limit] ? "maxN #{options[:node_limit]}":"" ] system(command) end def self.executable :cbc end def store_results(variables) rows = IO.read(@outfile).split("\n") objective = rows[0].split(/\s+/)[-1].to_f vars_by_name = {} rows[1..-1].each do |row| cols = row.strip.split(/\s+/) vars_by_name[cols[1].to_s] = cols[2].to_f end variables.each do |var| var.value = vars_by_name[var.to_s].to_f end return objective end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rulp-0.0.16 | lib/solvers/cbc.rb |
rulp-0.0.15 | lib/solvers/cbc.rb |