rulp 0.0.15 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rulp/expression.rb +14 -10
- data/lib/rulp/rulp.rb +14 -12
- data/lib/rulp/rulp_initializers.rb +2 -1
- 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: 51fa526dd152f836d5b5e6f4658352847828fa8e
|
4
|
+
data.tar.gz: 0858e2314d40ee7d7ac6e085634bfeb064d1d9f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c0fdb11528ae4ce52edf332902b0941fc4c298c2a06d21f41b11da96d8d8216e7f495a96a47587dd0588563981ed656af74468dcc06b9cd7be5f27682fc5363
|
7
|
+
data.tar.gz: 6603c3523a9a755eef88ad563d71ab27282a37cc539edcb733a765cefdf0c4f57e81c74308d57af5b2f7d099e662a95523ed9a511b77e0a15a5495b197b72d6a
|
data/lib/rulp/expression.rb
CHANGED
@@ -13,9 +13,11 @@ class Expressions
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def to_s
|
16
|
-
@expressions.
|
17
|
-
|
18
|
-
|
16
|
+
as_str = @expressions[0].to_s[3..-1]
|
17
|
+
(@expressions.length - 1).times do |i|
|
18
|
+
as_str << @expressions[i + 1].to_s
|
19
|
+
end
|
20
|
+
as_str
|
19
21
|
end
|
20
22
|
|
21
23
|
def variables
|
@@ -100,13 +102,15 @@ class Fragment
|
|
100
102
|
end
|
101
103
|
|
102
104
|
def to_s
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
105
|
+
@as_str ||= begin
|
106
|
+
case @operand
|
107
|
+
when -1
|
108
|
+
" - #{@lv}"
|
109
|
+
when 1
|
110
|
+
" + #{@lv}"
|
111
|
+
else
|
112
|
+
" + #{@operand} #{@lv}"
|
113
|
+
end
|
110
114
|
end
|
111
115
|
end
|
112
116
|
end
|
data/lib/rulp/rulp.rb
CHANGED
@@ -74,9 +74,13 @@ module Rulp
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def [](*constraints)
|
77
|
+
"Got constraints".log(:info)
|
77
78
|
constraints.flatten!
|
79
|
+
"Flattened constraints".log(:info)
|
78
80
|
@constraints.concat(constraints)
|
79
|
-
|
81
|
+
"Joint constraints".log(:info)
|
82
|
+
@variables.merge(constraints.flat_map(&:variables).uniq)
|
83
|
+
"Extracted variables".log(:info)
|
80
84
|
self
|
81
85
|
end
|
82
86
|
|
@@ -98,14 +102,12 @@ module Rulp
|
|
98
102
|
end
|
99
103
|
|
100
104
|
def constraints
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
" #{constraints_str}"
|
108
|
-
end
|
105
|
+
return "0 #{@variables.first} = 0" if @constraints.length == 0
|
106
|
+
constraints_str = " "
|
107
|
+
@constraints.each.with_index{|constraint, i|
|
108
|
+
constraints_str << " c#{i}: #{constraint}\n"
|
109
|
+
}
|
110
|
+
constraints_str
|
109
111
|
end
|
110
112
|
|
111
113
|
def integers
|
@@ -137,10 +139,10 @@ module Rulp
|
|
137
139
|
filename = get_output_filename
|
138
140
|
solver = SOLVERS[type].new(filename, options)
|
139
141
|
|
140
|
-
|
141
|
-
|
142
|
+
"Writing problem".log(:info)
|
143
|
+
IO.write(filename, self)
|
142
144
|
|
143
|
-
|
145
|
+
`open #{filename}` if options[:open_definition]
|
144
146
|
|
145
147
|
"Solving problem".log(:info)
|
146
148
|
_, time = _profile{ solver.solve }
|
@@ -3,6 +3,7 @@ module Rulp
|
|
3
3
|
def initialize(name, args)
|
4
4
|
@name = name
|
5
5
|
@args = args
|
6
|
+
@identifier = "#{self.name}#{self.args.join("_")}"
|
6
7
|
raise StandardError.new("Variable with the name #{self} of a different type (#{LV::names_table[self.to_s].class}) already exists") if LV::names_table[self.to_s]
|
7
8
|
LV::names_table[self.to_s] = self
|
8
9
|
end
|
@@ -22,7 +23,7 @@ module Rulp
|
|
22
23
|
end
|
23
24
|
|
24
25
|
def to_s
|
25
|
-
|
26
|
+
@identifier
|
26
27
|
end
|
27
28
|
end
|
28
29
|
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.16
|
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-07
|
11
|
+
date: 2015-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple Ruby LP description DSL
|
14
14
|
email: wc@pico.net.nz
|