Sha256: df12c4b95c288f66c7610405172aca0508023b2d09288c6f6528127f9393bc75
Contents?: true
Size: 892 Bytes
Versions: 3
Compression:
Stored size: 892 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]}":"" ] exec(command) end def self.executable :cbc end def store_results(variables) rows = IO.read(@outfile).split("\n") objective_str = rows[0].split(/\s+/)[-1] 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 self.unsuccessful = rows[0].downcase.include?('infeasible') return objective_str.to_f end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rulp-0.0.43 | lib/solvers/cbc.rb |
rulp-0.0.42 | lib/solvers/cbc.rb |
rulp-0.0.41 | lib/solvers/cbc.rb |