Sha256: 6249f9431b7e4f28989d33a308c33b4b4a4fbf1f991805b4139b68ab5d20ab7b
Contents?: true
Size: 934 Bytes
Versions: 2
Compression:
Stored size: 934 Bytes
Contents
class Gurobi < Solver def solve command = "#{executable} ResultFile=#{@outfile} %s %s %s #{@filename}" command %= [ options[:gap] ? "MipGap=#{options[:gap]}":"", options[:node_limit] ? "NodeLimit=#{options[:node_limit]}":"", ENV['RULP_GUROBI_CMD_ARGS'] ? ENV['RULP_GUROBI_CMD_ARGS'] : '' ] exec(command) end def self.executable :gurobi_cl end def store_results(variables) text = IO.read(@outfile) self.unsuccessful = text.strip.length.zero? || text.downcase.include?('infeasible') unless self.unsuccessful rows = text.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[0].to_s] = cols[1].to_f end variables.each do |var| var.value = vars_by_name[var.to_s].to_f end end return objective_str.to_f end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rulp-0.0.43 | lib/solvers/gurobi.rb |
rulp-0.0.42 | lib/solvers/gurobi.rb |