rulp 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/helpers/log.rb +9 -0
- data/lib/rulp/rulp.rb +7 -2
- data/lib/solvers/cbc.rb +1 -1
- data/lib/solvers/glpk.rb +1 -1
- data/lib/solvers/gurobi.rb +1 -1
- data/lib/solvers/scip.rb +6 -3
- data/lib/solvers/solver.rb +4 -0
- data/test/test_helper.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94d1b4aeebe550905d47cc889f958df9b241242f
|
4
|
+
data.tar.gz: 2d32d06eac07ad13c4f9efccd4fe7231c7fca44d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbd24354398f8ab0ddedea6340a833f3c5cc3b4c9171e18b98dffa050ac5b4482c93067ad5295efd1416ea662ec5d700b97573977d8616e82651448466116a86
|
7
|
+
data.tar.gz: 61e76aea75b4f67f2a2aa76f8b3c7c21bcfc63af3d7966919386f3cff41d1d1a6f2eac7cd1d2bacf32b2abe49ee2e70489d3e471c779437f5010dd52b173d6c9
|
data/lib/helpers/log.rb
CHANGED
@@ -34,6 +34,14 @@ module Rulp
|
|
34
34
|
@@level || :info
|
35
35
|
end
|
36
36
|
|
37
|
+
def self.print_solver_outputs
|
38
|
+
@@solver_level
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.print_solver_outputs=(value)
|
42
|
+
@@solver_level = value
|
43
|
+
end
|
44
|
+
|
37
45
|
def self.log(level, message)
|
38
46
|
if(LEVELS[level].to_i <= LEVELS[self.level])
|
39
47
|
puts("[#{colorize(level)}] #{message}")
|
@@ -58,6 +66,7 @@ module Rulp
|
|
58
66
|
end
|
59
67
|
|
60
68
|
self.level = :info
|
69
|
+
self.print_solver_outputs = true
|
61
70
|
|
62
71
|
class ::String
|
63
72
|
def log(level)
|
data/lib/rulp/rulp.rb
CHANGED
@@ -64,6 +64,11 @@ module Rulp
|
|
64
64
|
solver_class.exists? if(solver_class)
|
65
65
|
end
|
66
66
|
|
67
|
+
|
68
|
+
def self.exec(command)
|
69
|
+
system("#{command} #{Rulp::Logger.print_solver_outputs ? "" : "&> /dev/null"}")
|
70
|
+
end
|
71
|
+
|
67
72
|
class Problem
|
68
73
|
def initialize(objective, objective_expression)
|
69
74
|
@objective = objective
|
@@ -142,12 +147,12 @@ module Rulp
|
|
142
147
|
"Writing problem".log(:info)
|
143
148
|
IO.write(filename, self)
|
144
149
|
|
145
|
-
|
150
|
+
Rulp.exec("open #{filename}") if options[:open_definition]
|
146
151
|
|
147
152
|
"Solving problem".log(:info)
|
148
153
|
_, time = _profile{ solver.solve }
|
149
154
|
|
150
|
-
|
155
|
+
Rulp.exec("open #{solver.outfile}") if options[:open_solution]
|
151
156
|
|
152
157
|
"Solver took #{time}".log(:debug)
|
153
158
|
|
data/lib/solvers/cbc.rb
CHANGED
data/lib/solvers/glpk.rb
CHANGED
data/lib/solvers/gurobi.rb
CHANGED
data/lib/solvers/scip.rb
CHANGED
@@ -6,11 +6,14 @@ class Scip < Solver
|
|
6
6
|
def solve
|
7
7
|
settings = settings_file
|
8
8
|
if options[:parallel]
|
9
|
-
|
9
|
+
exec("touch /tmp/fscip_params")
|
10
|
+
exec("rm #{@outfile}")
|
11
|
+
command = "fscip /tmp/fscip_params #{@filename} -fsol #{@outfile} -s #{settings}"
|
10
12
|
else
|
11
|
-
|
13
|
+
exec("rm #{@outfile}")
|
14
|
+
command = "#{executable} -f #{@filename} -l #{@outfile} -s #{settings}"
|
12
15
|
end
|
13
|
-
|
16
|
+
exec(command)
|
14
17
|
end
|
15
18
|
|
16
19
|
def settings_file
|
data/lib/solvers/solver.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -4,7 +4,7 @@ gem "minitest"
|
|
4
4
|
require "minitest/autorun"
|
5
5
|
|
6
6
|
Rulp::Logger::level = :off
|
7
|
-
|
7
|
+
Rulp::Logger::print_solver_outputs = false
|
8
8
|
|
9
9
|
def each_solver
|
10
10
|
[:scip, :cbc, :glpk, :gurobi].each do |solver|
|
@@ -12,7 +12,7 @@ def each_solver
|
|
12
12
|
if Rulp::solver_exists?(solver)
|
13
13
|
yield(solver)
|
14
14
|
else
|
15
|
-
|
15
|
+
"Couldn't find solver #{solver}".log(:info)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
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.
|
4
|
+
version: 0.0.17
|
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
|
+
date: 2015-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple Ruby LP description DSL
|
14
14
|
email: wc@pico.net.nz
|