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 +4 -4
- data/lib/rulp/rulp.rb +2 -1
- data/lib/solvers/gurobi.rb +13 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bdd34b931ba0a9773f84bdf86fd6c46f5ac16d1
|
4
|
+
data.tar.gz: ff6d23c6984b6a54f8e0c92bbe8ca872118ecccd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0cae88a9211e35c545e8efb570b269c626b72455b50fabcf770e6fcdb289f556d631ec89aa12c20f49e5c11c85f360b9b1ff02d61cc5e50ead9354b19c7175d
|
7
|
+
data.tar.gz: 9f50d5f41b946dd90f00c71eacf6b6b66775c1a01b5be7466b3c424fe23de163507b147109d6fec0c88832b8f259c33b1394b6170b45852557daab71d9bf8952
|
data/lib/rulp/rulp.rb
CHANGED
@@ -185,7 +185,8 @@ module Rulp
|
|
185
185
|
solver.store_results(@variables)
|
186
186
|
|
187
187
|
if solver.unsuccessful
|
188
|
-
|
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
|
|
data/lib/solvers/gurobi.rb
CHANGED
@@ -14,17 +14,20 @@ class Gurobi < Solver
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def store_results(variables)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
vars_by_name
|
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
|