rulp 0.0.44 → 0.0.45
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/extensions/extensions.rb +1 -2
- data/lib/extensions/kernel_extensions.rb +7 -9
- data/lib/extensions/object_extensions.rb +7 -7
- data/lib/rulp/lv.rb +11 -6
- data/lib/rulp/version.rb +1 -1
- data/test/test_boolean.rb +2 -2
- data/test/test_infeasible.rb +2 -2
- metadata +7 -9
- data/lib/extensions/array_extensions.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 58a47250456efb480a41ea21a923355242c38c27d1e9eb04d17782493a51b083
|
4
|
+
data.tar.gz: e7b05a98c43d57035049cd1b2537fd3ecb42792e08114d8dd0729229092e96ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d12655f339c1095d9bc5f3c4620829965e3375ae4025fceeaea0438d97e6f334bdc0b727e0ac975d03ef8b688da4775c6c34cc9b56c0885cfa6fe38cd757d2dc
|
7
|
+
data.tar.gz: 9a3bd500cabd00c9118ff81cd79da588d629f5ee5788eae993d986161cd2ce3da715965534491f3d088b202154e53f124f7053dea671df606b028db96e24cdb4
|
@@ -18,17 +18,15 @@ module Kernel
|
|
18
18
|
alias_method :old_method_missing, :method_missing
|
19
19
|
def method_missing(value, *args)
|
20
20
|
method_name = "#{value}" rescue ""
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
when "b"
|
25
|
-
method_name = method_name[0..(method_name[-2] == "_" ? -3 : -2)]
|
21
|
+
if ("A".."Z").cover?(method_name[0])
|
22
|
+
if method_name.end_with?(BV.suffix)
|
23
|
+
method_name = method_name.chomp(BV.suffix).chomp("_")
|
26
24
|
return BV.definition(method_name, args)
|
27
|
-
|
28
|
-
method_name = method_name
|
25
|
+
elsif method_name.end_with?(IV.suffix)
|
26
|
+
method_name = method_name.chomp(IV.suffix).chomp("_")
|
29
27
|
return IV.definition(method_name, args)
|
30
|
-
|
31
|
-
method_name = method_name
|
28
|
+
elsif method_name.end_with?(LV.suffix)
|
29
|
+
method_name = method_name.chomp(LV.suffix).chomp("_")
|
32
30
|
return LV.definition(method_name, args)
|
33
31
|
end
|
34
32
|
end
|
@@ -14,13 +14,13 @@ class << Object
|
|
14
14
|
alias_method :old_const_missing, :const_missing
|
15
15
|
def const_missing(value)
|
16
16
|
method_name = "#{value}".split("::")[-1] rescue ""
|
17
|
-
if (
|
18
|
-
if
|
19
|
-
return BV.definition(method_name
|
20
|
-
elsif
|
21
|
-
return IV.definition(method_name
|
22
|
-
elsif
|
23
|
-
return LV.definition(method_name
|
17
|
+
if ("A".."Z").cover?(method_name[0])
|
18
|
+
if method_name.end_with?(BV.suffix)
|
19
|
+
return BV.definition(method_name.chomp(BV.suffix).chomp("_"))
|
20
|
+
elsif method_name.end_with?(IV.suffix)
|
21
|
+
return IV.definition(method_name.chomp(IV.suffix).chomp("_"))
|
22
|
+
elsif method_name.end_with?(LV.suffix)
|
23
|
+
return LV.definition(method_name.chomp(LV.suffix).chomp("_"))
|
24
24
|
end
|
25
25
|
end
|
26
26
|
old_const_missing(value)
|
data/lib/rulp/lv.rb
CHANGED
@@ -21,8 +21,12 @@ class LV
|
|
21
21
|
"#{self.name}_#{self.suffix}"
|
22
22
|
end
|
23
23
|
|
24
|
+
def self.suffix
|
25
|
+
ENV['RULP_LV_SUFFIX'] || "f"
|
26
|
+
end
|
27
|
+
|
24
28
|
def suffix
|
25
|
-
|
29
|
+
self.class.suffix
|
26
30
|
end
|
27
31
|
|
28
32
|
def self.definition(name, *args)
|
@@ -74,12 +78,13 @@ class LV
|
|
74
78
|
end
|
75
79
|
|
76
80
|
class BV < LV;
|
77
|
-
def suffix
|
78
|
-
"b"
|
81
|
+
def self.suffix
|
82
|
+
ENV['RULP_BV_SUFFIX'] || "b"
|
79
83
|
end
|
80
84
|
end
|
85
|
+
|
81
86
|
class IV < LV;
|
82
|
-
def suffix
|
83
|
-
"i"
|
87
|
+
def self.suffix
|
88
|
+
ENV['RULP_IV_SUFFIX'] || "i"
|
84
89
|
end
|
85
|
-
end
|
90
|
+
end
|
data/lib/rulp/version.rb
CHANGED
data/test/test_boolean.rb
CHANGED
@@ -8,8 +8,8 @@ require_relative 'test_helper'
|
|
8
8
|
class BooleanTest < Minitest::Test
|
9
9
|
def setup
|
10
10
|
@items = 30.times.map(&Shop_Item_b)
|
11
|
-
items_count = @items.
|
12
|
-
@items_costs = @items.map{|item| item * Random.rand(1.0...5.0)}.
|
11
|
+
items_count = @items.inject(:+)
|
12
|
+
@items_costs = @items.map{|item| item * Random.rand(1.0...5.0)}.inject(:+)
|
13
13
|
|
14
14
|
@problem =
|
15
15
|
Rulp::Min( @items_costs ) [
|
data/test/test_infeasible.rb
CHANGED
@@ -8,8 +8,8 @@ require_relative 'test_helper'
|
|
8
8
|
class InfeasibleTest < Minitest::Test
|
9
9
|
def setup
|
10
10
|
@items = 30.times.map(&Shop_Item_b)
|
11
|
-
items_count = @items.
|
12
|
-
@items_costs = @items.map{|item| item * Random.rand(1.0...5.0)}.
|
11
|
+
items_count = @items.inject(:+)
|
12
|
+
@items_costs = @items.map{|item| item * Random.rand(1.0...5.0)}.inject(:+)
|
13
13
|
|
14
14
|
@problem =
|
15
15
|
Rulp::Min( @items_costs ) [
|
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.45
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wouter Coppieters
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-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
|
@@ -18,7 +18,6 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- bin/rulp
|
21
|
-
- lib/extensions/array_extensions.rb
|
22
21
|
- lib/extensions/extensions.rb
|
23
22
|
- lib/extensions/file_extensions.rb
|
24
23
|
- lib/extensions/kernel_extensions.rb
|
@@ -45,10 +44,10 @@ files:
|
|
45
44
|
- test/test_infeasible.rb
|
46
45
|
- test/test_save_to_file.rb
|
47
46
|
- test/test_simple.rb
|
48
|
-
homepage:
|
47
|
+
homepage:
|
49
48
|
licenses: []
|
50
49
|
metadata: {}
|
51
|
-
post_install_message:
|
50
|
+
post_install_message:
|
52
51
|
rdoc_options: []
|
53
52
|
require_paths:
|
54
53
|
- lib
|
@@ -63,9 +62,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
62
|
- !ruby/object:Gem::Version
|
64
63
|
version: '0'
|
65
64
|
requirements: []
|
66
|
-
|
67
|
-
|
68
|
-
signing_key:
|
65
|
+
rubygems_version: 3.5.6
|
66
|
+
signing_key:
|
69
67
|
specification_version: 4
|
70
68
|
summary: Ruby Linear Programming
|
71
69
|
test_files:
|