rulp 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/extensions/kernel_extensions.rb +6 -6
- data/lib/rulp/lv.rb +21 -16
- data/lib/rulp/rulp_initializers.rb +5 -4
- data/lib/solvers/cbc.rb +1 -1
- data/lib/solvers/scip.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWVhZGY3OGVlMTcyMjUxOWJhMTdiN2FjOWJjMzRmYzBmYjFkZWU1MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MmVkYjg0M2E4NzMxNTU2ZjM5OWUwYzBlOGVjZGNjNDE0MDJjYjBiZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGY1MjkwYmExY2YwYzUwOTM0ZGI5NjM3NDNkZTAwYWRiOTk5MGMwYmE3YzU5
|
10
|
+
YTEyODRkMDVhMTM5YTFkODBhZDQyZjk4ODlmODFiZTliZjhkZWExMWE2ZTBh
|
11
|
+
N2IwMzVmZDMwNGM3OTJhZjQ1NmE3ODQ1ZjI4ODc4NjVmNDFkMWU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjJiOTA5N2NiNGJhOTY4ZmI0MTg2ZjY0MWMxOWQ4NDAzZGMyMWNhNWM3NmQ3
|
14
|
+
NjE4YjFkYjZiNmYzMmRlYzM5ZjhmZWNkOTM0ZWZjODYxZDFhMTViYWRmZDlm
|
15
|
+
ZDQ0NzM0MGYxNmRkNjVlOGVmODBmYjI3ZmMzNzdiZGI3NDhmZmM=
|
@@ -22,14 +22,14 @@ module Kernel
|
|
22
22
|
if (start <= "Z" && start >= "A")
|
23
23
|
case method_name[-1]
|
24
24
|
when "b"
|
25
|
-
method_name = method_name[0..(method_name[-2] == "_" ? -3 : -2)]
|
26
|
-
return BV.send(method_name)
|
25
|
+
method_name = method_name[0..(method_name[-2] == "_" ? -3 : -2)]
|
26
|
+
return BV.send(method_name, args)
|
27
27
|
when "i"
|
28
|
-
method_name = method_name[0..(method_name[-2] == "_" ? -3 : -2)]
|
29
|
-
return IV.send(method_name)
|
28
|
+
method_name = method_name[0..(method_name[-2] == "_" ? -3 : -2)]
|
29
|
+
return IV.send(method_name, args)
|
30
30
|
when "f"
|
31
|
-
method_name = method_name[0..(method_name[-2] == "_" ? -3 : -2)]
|
32
|
-
return LV.send(method_name)
|
31
|
+
method_name = method_name[0..(method_name[-2] == "_" ? -3 : -2)]
|
32
|
+
return LV.send(method_name, args)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
old_method_missing(value, *args)
|
data/lib/rulp/lv.rb
CHANGED
@@ -4,17 +4,17 @@
|
|
4
4
|
# These are constructed dynamically by using the special Capitalised variable declaration syntax.
|
5
5
|
##
|
6
6
|
class LV
|
7
|
-
attr_reader :name
|
7
|
+
attr_reader :name, :args
|
8
8
|
attr_accessor :lt, :lte, :gt, :gte, :value
|
9
9
|
include Rulp::Bounds
|
10
10
|
include Rulp::Initializers
|
11
11
|
|
12
12
|
def to_proc
|
13
|
-
->(index){ send(self.meth
|
13
|
+
->(index){ send(self.meth, index) }
|
14
14
|
end
|
15
15
|
|
16
|
-
def meth
|
17
|
-
"#{self.name}
|
16
|
+
def meth
|
17
|
+
"#{self.name}_#{self.suffix}"
|
18
18
|
end
|
19
19
|
|
20
20
|
def suffix
|
@@ -22,26 +22,31 @@ class LV
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.method_missing(name, *args)
|
25
|
-
return self.definition(
|
25
|
+
return self.definition(name, args)
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.const_missing(name)
|
29
29
|
return self.definition(name)
|
30
30
|
end
|
31
31
|
|
32
|
-
def self.definition(name)
|
33
|
-
|
34
|
-
|
35
|
-
if
|
36
|
-
|
37
|
-
"You are trying to redefine it as a variable of type #{self}")
|
38
|
-
elsif(!defined)
|
39
|
-
self.new(name)
|
32
|
+
def self.definition(name, args)
|
33
|
+
identifier = "#{name}#{args.join("_")}"
|
34
|
+
self.class.send(:define_method, identifier){|index=nil|
|
35
|
+
if index
|
36
|
+
self.definition(name, index)
|
40
37
|
else
|
41
|
-
defined
|
38
|
+
defined = LV::names_table["#{identifier}"]
|
39
|
+
if defined && defined.class != self
|
40
|
+
raise StandardError.new("ERROR:\n#{name} was already defined as a variable of type #{defined.class}."+
|
41
|
+
"You are trying to redefine it as a variable of type #{self}")
|
42
|
+
elsif(!defined)
|
43
|
+
self.new(name, args)
|
44
|
+
else
|
45
|
+
defined
|
46
|
+
end
|
42
47
|
end
|
43
48
|
}
|
44
|
-
return self.send(
|
49
|
+
return self.send(identifier) || self.new(name, args)
|
45
50
|
end
|
46
51
|
|
47
52
|
def * (numeric)
|
@@ -73,7 +78,7 @@ class LV
|
|
73
78
|
end
|
74
79
|
|
75
80
|
def inspect
|
76
|
-
"#{name}(#{suffix})[#{value || 'undefined'}]"
|
81
|
+
"#{name}#{args.join("-")}(#{suffix})[#{value || 'undefined'}]"
|
77
82
|
end
|
78
83
|
end
|
79
84
|
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module Rulp
|
2
2
|
module Initializers
|
3
|
-
def initialize(name)
|
4
|
-
raise StandardError.new("Variable with the name #{name} of a different type (#{LV::names_table[name].class}) already exists") if LV::names_table["#{name}"]
|
5
|
-
LV::names_table["#{name}"] = self
|
3
|
+
def initialize(name, args)
|
6
4
|
@name = name
|
5
|
+
@args = args
|
6
|
+
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
|
+
LV::names_table[self.to_s] = self
|
7
8
|
end
|
8
9
|
|
9
10
|
def self.included(base)
|
@@ -21,7 +22,7 @@ module Rulp
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def to_s
|
24
|
-
"#{self.name}"
|
25
|
+
"#{self.name}#{self.args.join("_")}"
|
25
26
|
end
|
26
27
|
end
|
27
28
|
end
|
data/lib/solvers/cbc.rb
CHANGED
data/lib/solvers/scip.rb
CHANGED
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.6
|
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-03-
|
11
|
+
date: 2015-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple Ruby LP description DSL
|
14
14
|
email: wc@pico.net.nz
|