rulp 0.0.18 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rulp/rulp.rb +14 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dfc914f134922ffbd2b34be47672e58c6514f84a
4
- data.tar.gz: ba894b524d2c41bb89fb4049c85f58731fb55695
3
+ metadata.gz: 474a46d10d853dad8b127e9dd19205983123b71a
4
+ data.tar.gz: d62b2a6f88905ecf33384520dbdb7234f3fa6e77
5
5
  SHA512:
6
- metadata.gz: 77a1f2798775302bfc9c3164a1dad65afd6188b64e2cc2f340cdd90ec61b35ca2bc5a7d88d6217dea06715ef234f2a05a79175638d264b69e876f5a3052d4d5a
7
- data.tar.gz: 84dfa8847ff8eea1b2fb2ed39e33807b79abc0012fe7afa8d74bc2b1f518f1432a25269804177413692afe5685dc48b369ae416d241e577d3ca828779061c025
6
+ metadata.gz: 97e3756baae29ca07a12fb8a24256f956a5619175cd0c10825e82b26f49ae64cca8075451a28358e61669147e38056120d8b746eeaf664cba231592127f47b10
7
+ data.tar.gz: 0bf9980ff63b3c72ce0b14792847406d53d08fdf5d1b25c250436a251da0db5e2378956f7b2fecc866a5f1c0baac8c294ec383e21d30a4efe36526058c175424
data/lib/rulp/rulp.rb CHANGED
@@ -66,10 +66,20 @@ module Rulp
66
66
 
67
67
 
68
68
  def self.exec(command)
69
- system("#{command} #{Rulp::Logger.print_solver_outputs ? "" : "> /dev/null 2>&1"}")
69
+ result = ""
70
+ Open3.popen2e("#{command} #{Rulp::Logger.print_solver_outputs ? "" : "> /dev/null 2>&1"}") do | inp, out, thr|
71
+ out.each do |line|
72
+ puts line
73
+ result << line
74
+ end
75
+ end
76
+ return result
70
77
  end
71
78
 
72
79
  class Problem
80
+
81
+ attr_accessor :result, :trace
82
+
73
83
  def initialize(objective, objective_expression)
74
84
  @objective = objective
75
85
  @variables = Set.new
@@ -150,7 +160,7 @@ module Rulp
150
160
  Rulp.exec("open #{filename}") if options[:open_definition]
151
161
 
152
162
  "Solving problem".log(:info)
153
- _, time = _profile{ solver.solve }
163
+ self.trace, time = _profile{ solver.solve }
154
164
 
155
165
  Rulp.exec("open #{solver.outfile}") if options[:open_solution]
156
166
 
@@ -159,10 +169,10 @@ module Rulp
159
169
  "Parsing result".log(:info)
160
170
  solver.store_results(@variables)
161
171
 
162
- result = @objective_expression.evaluate
172
+ self.result = @objective_expression.evaluate
163
173
 
164
174
  "Objective: #{result}\n#{@variables.map{|v|[v.name, "=", v.value].join(' ') if v.value}.compact.join("\n")}".log(:debug)
165
- return result
175
+ return self.result
166
176
  end
167
177
 
168
178
  def inspect
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rulp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wouter Coppieters
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-02 00:00:00.000000000 Z
11
+ date: 2015-11-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple Ruby LP description DSL
14
14
  email: wc@pico.net.nz