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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3df4957c76c02dc47894208b573de31ffb70d8e
4
- data.tar.gz: d83b68ff194145a7dd6ab43f34df6480eef6901f
3
+ metadata.gz: ad701722ba6d2ee732f074d86dba521d8f725d46
4
+ data.tar.gz: e00ab9b7c632eb8f8eba0164c0c8c0ed68d5c5bb
5
5
  SHA512:
6
- metadata.gz: 3c2fccdb2cfa9fd3796344c09b1335b460446d1a674034fd9143e3400cede2cc6483b386e297d01028ec64deff57d9a7886ea3fbe86a0863de047d266fb37014
7
- data.tar.gz: f93a8c1ffa8e7ff786ebbcc7fd551deca62506e85bc99d2b5bcc0c14e40c2bf25363c42bb8864b095567c96319f0547491320d376b7329aa13c93842a44550e2
6
+ metadata.gz: 09bb2783869873c9d04a20592b1e3d69856dd09fc032546d85bc8405f8931b953eaba2152e3e2c726fe387727bcc33428055c64399f187851a0aaa6964ed7b30
7
+ data.tar.gz: a7ecfb338d2bc14bf44586217d0cd059c212ed1ee0950b1c17d40cb4dbda6d7d1cf4756087094e99ec167aed8984a02e259de5d1f3b6016029b18913a8e3c671
@@ -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
@@ -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
@@ -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
@@ -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 write(filename)
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
@@ -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 write(filename)
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 write(filename)
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mipper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Mior