mipper 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mipper/cbc/ext.rb +1 -0
- data/lib/mipper/cbc/model.rb +11 -0
- data/lib/mipper/glpk/ext.rb +1 -0
- data/lib/mipper/glpk/model.rb +8 -2
- data/lib/mipper/gurobi/model.rb +7 -2
- data/lib/mipper/model.rb +7 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad701722ba6d2ee732f074d86dba521d8f725d46
|
4
|
+
data.tar.gz: e00ab9b7c632eb8f8eba0164c0c8c0ed68d5c5bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09bb2783869873c9d04a20592b1e3d69856dd09fc032546d85bc8405f8931b953eaba2152e3e2c726fe387727bcc33428055c64399f187851a0aaa6964ed7b30
|
7
|
+
data.tar.gz: a7ecfb338d2bc14bf44586217d0cd059c212ed1ee0950b1c17d40cb4dbda6d7d1cf4756087094e99ec167aed8984a02e259de5d1f3b6016029b18913a8e3c671
|
data/lib/mipper/cbc/ext.rb
CHANGED
@@ -32,5 +32,6 @@ module MIPPeR
|
|
32
32
|
attach_function :Cbc_isProvenInfeasible, [:pointer], :int
|
33
33
|
attach_function :Cbc_isContinuousUnbounded, [:pointer], :int
|
34
34
|
attach_function :Cbc_setParameter, [:pointer, :string, :string], :void
|
35
|
+
attach_function :Cbc_writeMps, [:pointer, :string], :void
|
35
36
|
end
|
36
37
|
end
|
data/lib/mipper/cbc/model.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'zlib'
|
2
|
+
|
1
3
|
module MIPPeR
|
2
4
|
class CbcModel < Model
|
3
5
|
attr_reader :ptr
|
@@ -14,6 +16,15 @@ module MIPPeR
|
|
14
16
|
Cbc.Cbc_setParameter @ptr, 'logLevel', '0'
|
15
17
|
end
|
16
18
|
|
19
|
+
# Write the model to a file in MPS format
|
20
|
+
def write_mps(filename)
|
21
|
+
Cbc.Cbc_writeMps @ptr, File.join(File.dirname(filename),
|
22
|
+
File.basename(filename, '.mps'))
|
23
|
+
contents = Zlib::GzipReader.open(filename + '.gz').read
|
24
|
+
File.delete(filename + '.gz')
|
25
|
+
File.open(filename, 'w').write contents
|
26
|
+
end
|
27
|
+
|
17
28
|
# Set the sense of the model
|
18
29
|
def sense=(sense)
|
19
30
|
@sense = sense
|
data/lib/mipper/glpk/ext.rb
CHANGED
@@ -38,6 +38,7 @@ module MIPPeR
|
|
38
38
|
attach_function :glp_mip_row_val, [:pointer, :int], :double
|
39
39
|
attach_function :glp_mip_col_val, [:pointer, :int], :double
|
40
40
|
attach_function :glp_write_lp, [:pointer, :int, :string], :int
|
41
|
+
attach_function :glp_write_mps, [:pointer, :int, :string, :string], :int
|
41
42
|
attach_function :glp_term_out, [:int], :int
|
42
43
|
end
|
43
44
|
end
|
data/lib/mipper/glpk/model.rb
CHANGED
@@ -21,12 +21,18 @@ module MIPPeR
|
|
21
21
|
GLPK.method(:glp_delete_prob)
|
22
22
|
end
|
23
23
|
|
24
|
-
# Write the model to a file
|
25
|
-
def
|
24
|
+
# Write the model to a file in CPLEX LP format
|
25
|
+
def write_lp(filename)
|
26
26
|
ret = GLPK.glp_write_lp @ptr, 0, filename
|
27
27
|
fail if ret != 0
|
28
28
|
end
|
29
29
|
|
30
|
+
# Write the model to a file in MPS format
|
31
|
+
def write_mps(filename)
|
32
|
+
ret = GLPK.glp_write_mps @ptr, GLPK::GLP_MPS_FILE, nil, filename
|
33
|
+
fail if ret != 0
|
34
|
+
end
|
35
|
+
|
30
36
|
# Set the sense of the model
|
31
37
|
def sense=(sense)
|
32
38
|
@sense = sense
|
data/lib/mipper/gurobi/model.rb
CHANGED
@@ -26,8 +26,13 @@ module MIPPeR
|
|
26
26
|
fail if ret != 0
|
27
27
|
end
|
28
28
|
|
29
|
-
# Write the model to a file
|
30
|
-
def
|
29
|
+
# Write the model to a file in CPLEX LP format
|
30
|
+
def write_lp(filename)
|
31
|
+
Gurobi.GRBwrite @ptr, filename
|
32
|
+
end
|
33
|
+
|
34
|
+
# Write the model to a file in MPS format
|
35
|
+
def write_mps(filename)
|
31
36
|
Gurobi.GRBwrite @ptr, filename
|
32
37
|
end
|
33
38
|
|
data/lib/mipper/model.rb
CHANGED
@@ -41,8 +41,13 @@ module MIPPeR
|
|
41
41
|
@pending_constraints = []
|
42
42
|
end
|
43
43
|
|
44
|
-
# Write the model to a file
|
45
|
-
def
|
44
|
+
# Write the model to a file in CPLEX LP format
|
45
|
+
def write_lp(filename)
|
46
|
+
fail NotImplementedError
|
47
|
+
end
|
48
|
+
|
49
|
+
# Write the model to a file in MPS format
|
50
|
+
def write_mps(filename)
|
46
51
|
fail NotImplementedError
|
47
52
|
end
|
48
53
|
|