opl 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/opl.rb +20 -27
- metadata +2 -2
data/lib/opl.rb
CHANGED
@@ -1,46 +1,29 @@
|
|
1
1
|
require "rglpk"
|
2
2
|
|
3
|
-
#TODO
|
4
|
-
#unbounded or conflicting bounds messages
|
5
|
-
# e.g.
|
6
|
-
# lp = maximize(
|
7
|
-
# "x",
|
8
|
-
# subject_to([
|
9
|
-
# "x >= 0"
|
10
|
-
# ]))
|
11
|
-
#
|
12
|
-
#should return an error message
|
13
|
-
|
14
|
-
#2.4
|
15
|
-
#catch this error for sum() in forall()
|
16
|
-
#"forall(i in (0..2), sum(j in (0..2), x[i][j] = 1))"
|
17
|
-
#should be:
|
18
|
-
#"forall(i in (0..2), sum(j in (0..2), x[i][j]) = 1)"
|
19
|
-
|
20
3
|
#3.0
|
21
|
-
#
|
22
|
-
#
|
23
|
-
|
24
|
-
#3.1
|
25
|
-
#make sure extreme cases of foralls and sums
|
4
|
+
#Implement more advanced TSPs in order to
|
5
|
+
#make sure extreme cases of foralls and sums
|
26
6
|
#are handled
|
27
7
|
|
28
|
-
#
|
8
|
+
#3.1
|
29
9
|
#absolute value: abs()
|
30
10
|
|
31
|
-
#
|
11
|
+
#3.2
|
32
12
|
#if --> then statements
|
33
13
|
|
34
|
-
#
|
14
|
+
#3.3
|
35
15
|
#or statements
|
36
16
|
|
37
|
-
#4
|
17
|
+
#3.4
|
38
18
|
#piecewise statements
|
39
19
|
|
40
|
-
#
|
20
|
+
#3.5
|
41
21
|
#duals, sensitivity, etc. - I could simply allow
|
42
22
|
#access to the rglpk object wrapper
|
43
23
|
|
24
|
+
#4.0
|
25
|
+
#import excel sheets as data
|
26
|
+
|
44
27
|
$default_epsilon = 0.01
|
45
28
|
|
46
29
|
class String
|
@@ -293,6 +276,8 @@ class OPL
|
|
293
276
|
text = text.sub_paren_with_array
|
294
277
|
if (text.gsub(" ","")).scan(/\]\,/).size != text.scan(/in/).size
|
295
278
|
raise "The following sum() constraint is incorrectly formatted: #{text}. Please see the examples in test.rb for sum() constraints. I suspect you are missing a comma somewhere."
|
279
|
+
elsif (text.gsub(" ","").include?("=") || text.gsub(" ","").include?("<") || text.gsub(" ","").include?(">"))
|
280
|
+
raise "The following sum() constraint cannot have a equalities in it (a.k.a. =, <, >): #{text}"
|
296
281
|
end
|
297
282
|
final_text = ""
|
298
283
|
element = text.split(",")[-1].gsub(" ","")
|
@@ -764,6 +749,7 @@ class OPL
|
|
764
749
|
attr_accessor :matrix_solution
|
765
750
|
attr_accessor :error_message
|
766
751
|
attr_accessor :stop_processing
|
752
|
+
attr_accessor :solution_type
|
767
753
|
|
768
754
|
def keys
|
769
755
|
[:objective, :constraints, :rows, :solution, :formatted_constraints, :rglpk_object, :solver, :matrix, :simplex_message, :mip_message, :data]
|
@@ -1093,5 +1079,12 @@ def optimize(optimization, objective, lp)
|
|
1093
1079
|
lp.rglpk_object = lp.error_message
|
1094
1080
|
lp.objective = lp.error_message
|
1095
1081
|
end
|
1082
|
+
if lp.rglpk_object.status.to_s == "4"
|
1083
|
+
raise "There is no feasible solution."
|
1084
|
+
elsif lp.rglpk_object.status.to_s == "6"
|
1085
|
+
raise "The solution is unbounded."
|
1086
|
+
elsif lp.rglpk_object.status.to_s == "1"
|
1087
|
+
raise "The solution is undefined."
|
1088
|
+
end
|
1096
1089
|
lp
|
1097
1090
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-21 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Built on top of the rglpk gem for linear programming, this gem is meant
|
15
15
|
to give you a beautifully simple way to formulate your linear or mixed integer program.
|