rulp 0.0.41 → 0.0.42

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99f1c57e4bef966b71aa7e9a02e37a9e4a124660
4
- data.tar.gz: ac1527cd28e1fb3218569b76d35ebd65c8dd62be
3
+ metadata.gz: 5bdd34b931ba0a9773f84bdf86fd6c46f5ac16d1
4
+ data.tar.gz: ff6d23c6984b6a54f8e0c92bbe8ca872118ecccd
5
5
  SHA512:
6
- metadata.gz: 39dc348c6558ea3bc0d6f931ba0e88b08ab4e6a3cb94fd30b9f9a55c2e548fbe9c34fd57dfab248228fbdf9a96443787edaf2fcc0d33afddbee306c162cc9ef3
7
- data.tar.gz: bec99ca0718e4b038811d5a24eb6f67933ef877571038861c6b30a1b03ca55d37e69d38fa55763b1ae64e96c8899c36f73c3e7330a6c44508385cc5bac531246
6
+ metadata.gz: e0cae88a9211e35c545e8efb570b269c626b72455b50fabcf770e6fcdb289f556d631ec89aa12c20f49e5c11c85f360b9b1ff02d61cc5e50ead9354b19c7175d
7
+ data.tar.gz: 9f50d5f41b946dd90f00c71eacf6b6b66775c1a01b5be7466b3c424fe23de163507b147109d6fec0c88832b8f259c33b1394b6170b45852557daab71d9bf8952
@@ -185,7 +185,8 @@ module Rulp
185
185
  solver.store_results(@variables)
186
186
 
187
187
  if solver.unsuccessful
188
- raise "Solve failed: solution infeasible" if IO.read(solver.outfile).downcase.include?("infeasible")
188
+ outfile_contents = IO.read(solver.outfile)
189
+ raise "Solve failed: solution infeasible" if outfile_contents.downcase.include?("infeasible") || outfile_contents.strip.length.zero?
189
190
  raise "Solve failed: all units undefined"
190
191
  end
191
192
 
@@ -14,17 +14,20 @@ class Gurobi < Solver
14
14
  end
15
15
 
16
16
  def store_results(variables)
17
- rows = IO.read(@outfile).split("\n")
18
- objective_str = rows[0].split(/\s+/)[-1]
19
- vars_by_name = {}
20
- rows[1..-1].each do |row|
21
- cols = row.strip.split(/\s+/)
22
- vars_by_name[cols[0].to_s] = cols[1].to_f
17
+ text = IO.read(@outfile)
18
+ self.unsuccessful = text.strip.length.zero? || text.downcase.include?('infeasible')
19
+ unless self.unsuccessful
20
+ rows = text.split("\n")
21
+ objective_str = rows[0].split(/\s+/)[-1]
22
+ vars_by_name = {}
23
+ rows[1..-1].each do |row|
24
+ cols = row.strip.split(/\s+/)
25
+ vars_by_name[cols[0].to_s] = cols[1].to_f
26
+ end
27
+ variables.each do |var|
28
+ var.value = vars_by_name[var.to_s].to_f
29
+ end
23
30
  end
24
- variables.each do |var|
25
- var.value = vars_by_name[var.to_s].to_f
26
- end
27
- self.unsuccessful = rows.length.zero?
28
31
  return objective_str.to_f
29
32
  end
30
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rulp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.41
4
+ version: 0.0.42
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wouter Coppieters