Sha256: 3ff6b78bdd8a29a802325160459ae0d76b02ba29f71bea6a7c421ca21e365577

Contents?: true

Size: 511 Bytes

Versions: 3

Compression:

Stored size: 511 Bytes

Contents

class Glpk < Solver
  def solve
    command = "#{executable} --lp #{@filename} %s --cuts --write #{@outfile}"
    command %= options[:gap] ? "--mipgap #{options[:gap]}" : ""
    system(command)
  end

  def self.executable
    :glpsol
  end

  def store_results(variables)
    rows = IO.read(@outfile).split("\n")
    variables.zip(rows[-variables.count..-1]).each do |var, row|
      cols = row.split(" ")
      var.value = cols[[1, cols.count - 1].min].to_f
    end
    return rows[1].split(" ")[-1]
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rulp-0.0.16 lib/solvers/glpk.rb
rulp-0.0.15 lib/solvers/glpk.rb
rulp-0.0.14 lib/solvers/glpk.rb