relax4 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -98,11 +98,11 @@ An assignment problem:
98
98
  == REQUIREMENTS
99
99
 
100
100
  Has been tested on:
101
- * x86-linux (Ubuntu 10.04) with Ruby 1.8.7p249
102
- * x86-linux (Ubuntu 10.04) with Ruby 1.9.1p378
103
- * x86_64-linux (CentOS) with Ruby 1.8.7p72
101
+ * ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-linux] and [x86_64-linux]
102
+ * ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux] and [x86_64-linux]
104
103
 
105
- The following packages were required to install on Ubuntu 10.04:
104
+ The following packages were required to install with the system ruby on Ubuntu
105
+ 10.04:
106
106
 
107
107
  * ruby, ruby-dev, rubygems
108
108
 
@@ -111,18 +111,16 @@ The bindings were generated with f2c (FORTRAN to C converter) and SWIG
111
111
 
112
112
  == INSTALL
113
113
 
114
- You should be able to install with
115
-
116
114
  gem install relax4
117
115
 
118
- Alternatively, you can get the source with
119
-
120
- git clone http://github.com/jdleesmiller/relax4_ruby.git
116
+ == DEVELOPMENT
121
117
 
122
- and run
118
+ Get the source from github (http://github.com/jdleesmiller/relax4_ruby) and
119
+ use bundler to get the development dependencies:
123
120
 
124
- gem build relax4.gemspec
125
- gem install relax4-<version>.gem
121
+ gem install bundler
122
+ bundle
123
+ rake -T # list development tasks
126
124
 
127
125
  == TODO
128
126
 
@@ -131,6 +129,12 @@ and run
131
129
 
132
130
  == HISTORY
133
131
 
132
+ <em>1.2.0</em> 20110905
133
+ * reorganized gem to be consistent with http://guides.rubygems.org/c-extensions
134
+ * now using gemma 2 for development tasks
135
+ * added major, minor and patch version constants (no other API changes)
136
+ * wrapper regenerated with swig 2.0.4 (was 1.3.38)
137
+
134
138
  <em>1.1.0</em>
135
139
  * added wrappers for transportation and assignment problems
136
140
  * updated docs
File without changes
File without changes
File without changes
@@ -1,6 +1,6 @@
1
1
  /* ----------------------------------------------------------------------------
2
2
  * This file was automatically generated by SWIG (http://www.swig.org).
3
- * Version 1.3.38
3
+ * Version 2.0.4
4
4
  *
5
5
  * This file is not intended to be easily readable and contains a number of
6
6
  * coding conventions designed to improve portability and efficiency. Do not make
@@ -281,7 +281,7 @@
281
281
  /*
282
282
  Flags/methods for returning states.
283
283
 
284
- The SWIG conversion methods, as ConvertPtr, return and integer
284
+ The SWIG conversion methods, as ConvertPtr, return an integer
285
285
  that tells if the conversion was successful or not. And if not,
286
286
  an error code can be returned (see swigerrors.swg for the codes).
287
287
 
@@ -831,6 +831,15 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
831
831
 
832
832
  #include <ruby.h>
833
833
 
834
+ /* Ruby 1.9.1 has a "memoisation optimisation" when compiling with GCC which
835
+ * breaks using rb_intern as an lvalue, as SWIG does. We work around this
836
+ * issue for now by disabling this.
837
+ * https://sourceforge.net/tracker/?func=detail&aid=2859614&group_id=1645&atid=101645
838
+ */
839
+ #ifdef rb_intern
840
+ # undef rb_intern
841
+ #endif
842
+
834
843
  /* Remove global macros defined in Ruby's win32.h */
835
844
  #ifdef write
836
845
  # undef write
@@ -838,6 +847,15 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
838
847
  #ifdef read
839
848
  # undef read
840
849
  #endif
850
+ #ifdef bind
851
+ # undef bind
852
+ #endif
853
+ #ifdef close
854
+ # undef close
855
+ #endif
856
+ #ifdef connect
857
+ # undef connect
858
+ #endif
841
859
 
842
860
 
843
861
  /* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */
@@ -980,7 +998,7 @@ static VALUE _mSWIG = Qnil;
980
998
 
981
999
  /* Define custom exceptions for errors that do not map to existing Ruby
982
1000
  exceptions. Note this only works for C++ since a global cannot be
983
- initialized by a funtion in C. For C, fallback to rb_eRuntimeError.*/
1001
+ initialized by a function in C. For C, fallback to rb_eRuntimeError.*/
984
1002
 
985
1003
  SWIGINTERN VALUE
986
1004
  getNullReferenceError(void) {
@@ -1125,9 +1143,6 @@ void Ruby_Format_OverloadedError(
1125
1143
  }
1126
1144
 
1127
1145
  /* -----------------------------------------------------------------------------
1128
- * See the LICENSE file for information on copyright, usage and redistribution
1129
- * of SWIG, and the README file for authors - http://www.swig.org/release.html.
1130
- *
1131
1146
  * rubytracking.swg
1132
1147
  *
1133
1148
  * This file contains support for tracking mappings from
@@ -1323,9 +1338,6 @@ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) {
1323
1338
 
1324
1339
 
1325
1340
  /* -----------------------------------------------------------------------------
1326
- * See the LICENSE file for information on copyright, usage and redistribution
1327
- * of SWIG, and the README file for authors - http://www.swig.org/release.html.
1328
- *
1329
1341
  * rubyrun.swg
1330
1342
  *
1331
1343
  * This file contains the runtime support for Ruby modules
@@ -1369,7 +1381,7 @@ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) {
1369
1381
  /* Error manipulation */
1370
1382
 
1371
1383
  #define SWIG_ErrorType(code) SWIG_Ruby_ErrorType(code)
1372
- #define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), msg)
1384
+ #define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), "%s", msg)
1373
1385
  #define SWIG_fail goto fail
1374
1386
 
1375
1387
 
@@ -1424,7 +1436,7 @@ static ID swig_call_id = 0;
1424
1436
  ++swig_virtual_calls;
1425
1437
  # define SWIG_RELEASE_STACK --swig_virtual_calls;
1426
1438
  # define Ruby_DirectorTypeMismatchException(x) \
1427
- rb_raise( rb_eTypeError, x ); return c_result;
1439
+ rb_raise( rb_eTypeError, "%s", x ); return c_result;
1428
1440
 
1429
1441
  static unsigned int swig_virtual_calls = 0;
1430
1442
 
@@ -1796,7 +1808,7 @@ static VALUE mRelax4;
1796
1808
  #define SWIG_RUBY_THREAD_END_BLOCK
1797
1809
 
1798
1810
 
1799
- #define SWIGVERSION 0x010338
1811
+ #define SWIGVERSION 0x020004
1800
1812
  #define SWIG_VERSION SWIGVERSION
1801
1813
 
1802
1814
 
@@ -1817,7 +1829,7 @@ SWIG_ruby_failed(void)
1817
1829
  }
1818
1830
 
1819
1831
 
1820
- /*@SWIG:/usr/local/share/swig/1.3.38/ruby/rubyprimtypes.swg,23,%ruby_aux_method@*/
1832
+ /*@SWIG:/home/john/local/share/swig/2.0.4/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
1821
1833
  SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE *args)
1822
1834
  {
1823
1835
  VALUE obj = args[0];
@@ -1882,7 +1894,7 @@ SWIG_From_int (int value)
1882
1894
  }
1883
1895
 
1884
1896
 
1885
- /*@SWIG:/usr/local/share/swig/1.3.38/ruby/rubyprimtypes.swg,23,%ruby_aux_method@*/
1897
+ /*@SWIG:/home/john/local/share/swig/2.0.4/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
1886
1898
  SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args)
1887
1899
  {
1888
1900
  VALUE obj = args[0];
@@ -1935,7 +1947,7 @@ SWIGINTERN int *IntegerArray_cast(IntegerArray *self){
1935
1947
  SWIGINTERN IntegerArray *IntegerArray_frompointer(int *t){
1936
1948
  return (IntegerArray *)(t);
1937
1949
  }
1938
- swig_class cIntegerArray;
1950
+ swig_class SwigClassIntegerArray;
1939
1951
 
1940
1952
  #ifdef HAVE_RB_DEFINE_ALLOC_FUNC
1941
1953
  SWIGINTERN VALUE
@@ -2609,17 +2621,17 @@ SWIGEXPORT void Init_relax4(void) {
2609
2621
 
2610
2622
  SWIG_RubyInitializeTrackings();
2611
2623
 
2612
- cIntegerArray.klass = rb_define_class_under(mRelax4, "IntegerArray", rb_cObject);
2613
- SWIG_TypeClientData(SWIGTYPE_p_IntegerArray, (void *) &cIntegerArray);
2614
- rb_define_alloc_func(cIntegerArray.klass, _wrap_IntegerArray_allocate);
2615
- rb_define_method(cIntegerArray.klass, "initialize", _wrap_new_IntegerArray, -1);
2616
- rb_define_method(cIntegerArray.klass, "[]", _wrap_IntegerArray___getitem__, -1);
2617
- rb_define_method(cIntegerArray.klass, "[]=", _wrap_IntegerArray___setitem__, -1);
2618
- rb_define_method(cIntegerArray.klass, "cast", _wrap_IntegerArray_cast, -1);
2619
- rb_define_singleton_method(cIntegerArray.klass, "frompointer", _wrap_IntegerArray_frompointer, -1);
2620
- cIntegerArray.mark = 0;
2621
- cIntegerArray.destroy = (void (*)(void *)) free_IntegerArray;
2622
- cIntegerArray.trackObjects = 0;
2624
+ SwigClassIntegerArray.klass = rb_define_class_under(mRelax4, "IntegerArray", rb_cObject);
2625
+ SWIG_TypeClientData(SWIGTYPE_p_IntegerArray, (void *) &SwigClassIntegerArray);
2626
+ rb_define_alloc_func(SwigClassIntegerArray.klass, _wrap_IntegerArray_allocate);
2627
+ rb_define_method(SwigClassIntegerArray.klass, "initialize", _wrap_new_IntegerArray, -1);
2628
+ rb_define_method(SwigClassIntegerArray.klass, "[]", _wrap_IntegerArray___getitem__, -1);
2629
+ rb_define_method(SwigClassIntegerArray.klass, "[]=", _wrap_IntegerArray___setitem__, -1);
2630
+ rb_define_method(SwigClassIntegerArray.klass, "cast", _wrap_IntegerArray_cast, -1);
2631
+ rb_define_singleton_method(SwigClassIntegerArray.klass, "frompointer", _wrap_IntegerArray_frompointer, -1);
2632
+ SwigClassIntegerArray.mark = 0;
2633
+ SwigClassIntegerArray.destroy = (void (*)(void *)) free_IntegerArray;
2634
+ SwigClassIntegerArray.trackObjects = 0;
2623
2635
  rb_define_const(mRelax4, "RELAX4_OK", SWIG_From_int((int)(0)));
2624
2636
  rb_define_const(mRelax4, "RELAX4_INFEASIBLE", SWIG_From_int((int)(1)));
2625
2637
  rb_define_const(mRelax4, "RELAX4_FAIL_OUT_OF_MEMORY", SWIG_From_int((int)(2)));
@@ -1,3 +1,6 @@
1
1
  module Relax4
2
- VERSION = '1.1.0'
2
+ VERSION_MAJOR = 1
3
+ VERSION_MINOR = 2
4
+ VERSION_PATCH = 0
5
+ VERSION = [VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH].join('.')
3
6
  end
data/lib/relax4.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'relax4.so'
1
+ require 'relax4/relax4' # the C extension
2
2
 
3
3
  #
4
4
  # Methods for calling the RELAX IV solver.
@@ -7,9 +7,9 @@ require 'relax4.so'
7
7
  #
8
8
  # There are also lower-level methods. Unfortunately, swig and rdoc don't work
9
9
  # very well together, so the best references for these calls are currently the
10
- # source of {Relax4.solve} and the <tt>ext/relax4.h</tt> header file listed
10
+ # source of {Relax4.solve} and the <tt>relax4.h</tt> header file listed
11
11
  # below:
12
- # :include:../ext/relax4.h
12
+ # :include:../ext/relax4/relax4.h
13
13
  #
14
14
  module Relax4
15
15
  #
@@ -41,10 +41,10 @@ module Relax4
41
41
  # an initial feasible solution; this is recommended only for hard problems.
42
42
  #
43
43
  # @option args [Integer] :large (RELAX4_DEFAULT_LARGE) a very large integer to
44
- # represent infinity; see the ext/relax4.h listing above for more info.
44
+ # represent infinity; see the relax4.h listing above for more info.
45
45
  #
46
46
  # @option args [Integer] :max_cost (RELAX4_DEFAULT_MAX_COST) largest allowed
47
- # cost, in order to avoid integer overflow; see the ext/relax4.h listing above
47
+ # cost, in order to avoid integer overflow; see the relax4.h listing above
48
48
  # for more info.
49
49
  #
50
50
  # @return [Array<Integer>] optimal flows for each arc
@@ -338,7 +338,7 @@ module Relax4
338
338
  # Set start_nodes, end_nodes and costs based on cost matrix; nil entries in
339
339
  # the cost matrix are not mapped to arcs.
340
340
  #
341
- # @return Array<Array<Integer>> array of pairs of (zero-based) indices into
341
+ # @return [Array<Array<Integer>>] array of pairs of (zero-based) indices into
342
342
  # costs that correspond to the created arcs; size is <tt>m*n</tt> minus the
343
343
  # number of nil entries in the costs matrix
344
344
  #
File without changes
@@ -1,6 +1,8 @@
1
1
  require "test/unit"
2
2
  require "relax4"
3
3
 
4
+ INPUT_PATH = File.join('test','relax4')
5
+
4
6
  class TestRelax4< Test::Unit::TestCase
5
7
  def test_solve_1
6
8
  # From Figure 7.14 of Bertsimas and Tsitsiklis (1997). Introduction to
@@ -71,7 +73,7 @@ class TestRelax4< Test::Unit::TestCase
71
73
  end
72
74
 
73
75
  def test_solve_3
74
- prob = problem_from_relax4_inp 'test/RELAX4.INP'
76
+ prob = problem_from_relax4_inp File.join(INPUT_PATH, 'RELAX4.INP')
75
77
 
76
78
  flows = Relax4.solve(prob)
77
79
  assert_equal(-26464, problem_cost(prob, flows))
@@ -89,7 +91,7 @@ class TestRelax4< Test::Unit::TestCase
89
91
  # Note that giving this file to the original application works, because it
90
92
  # only reads the first 8 digits of any input number (format I8) -- i.e. it
91
93
  # sets the capacities to 50M not 500M.
92
- prob = problem_from_relax4_inp 'test/test_solve_4.inp'
94
+ prob = problem_from_relax4_inp File.join(INPUT_PATH, 'test_solve_4.inp')
93
95
  prob[:capacities].map! {|x| [x, Relax4::RELAX4_UNCAPACITATED].min}
94
96
  flows = Relax4.solve(prob)
95
97
  assert_equal 1381, problem_cost(prob, flows)
@@ -100,7 +102,7 @@ class TestRelax4< Test::Unit::TestCase
100
102
  # apparent bug in the ascnt2_ routine (out of bounds on the prdcsr array,
101
103
  # which was not long enough to record the number of newly balanced arcs).
102
104
  # This bug affected versions 1.0.3 and earlier.
103
- prob = problem_from_relax4_inp 'test/test_solve_5.inp'
105
+ prob = problem_from_relax4_inp File.join(INPUT_PATH, 'test_solve_5.inp')
104
106
  prob[:capacities].map! {|x| [x, Relax4::RELAX4_UNCAPACITATED].min}
105
107
  flows = Relax4.solve(prob)
106
108
  assert_equal 28759, problem_cost(prob, flows)
@@ -111,7 +113,7 @@ class TestRelax4< Test::Unit::TestCase
111
113
  # reasons as the problem in test_solve_5. The fix for that didn't entirely
112
114
  # resolve the issue; see comments in relax4.c.
113
115
  # This bug affected versions 1.0.4 and earlier.
114
- prob = problem_from_relax4_inp 'test/test_solve_6.inp'
116
+ prob = problem_from_relax4_inp File.join(INPUT_PATH, 'test_solve_6.inp')
115
117
  prob[:capacities].map! {|x| [x, Relax4::RELAX4_UNCAPACITATED].min}
116
118
  flows = Relax4.solve(prob)
117
119
  assert_equal 16925, problem_cost(prob, flows)
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relax4
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
4
+ hash: 31
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 1.1.0
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - John Lees-Miller
@@ -15,10 +15,25 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-30 00:00:00 +01:00
18
+ date: 2011-09-06 00:00:00 +01:00
19
19
  default_executable:
20
- dependencies: []
21
-
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ hash: 15
28
+ segments:
29
+ - 2
30
+ - 0
31
+ - 0
32
+ version: 2.0.0
33
+ version_requirements: *id001
34
+ name: gemma
35
+ prerelease: false
36
+ type: :development
22
37
  description: |
23
38
  Ruby interface for the RELAX IV code by D.P. Bertsekas and P. Tseng.
24
39
 
@@ -27,22 +42,22 @@ email:
27
42
  executables: []
28
43
 
29
44
  extensions:
30
- - ext/extconf.rb
45
+ - ext/relax4/extconf.rb
31
46
  extra_rdoc_files:
32
47
  - README.rdoc
33
48
  files:
34
- - lib/relax4.rb
35
49
  - lib/relax4/version.rb
36
- - test/test_solve_6.inp
37
- - test/test_solve_5.inp
38
- - test/test_solve_4.inp
39
- - test/RELAX4.INP
40
- - ext/extconf.rb
41
- - ext/relax4.c
42
- - ext/relax4.h
43
- - ext/relax4_wrap.c
50
+ - lib/relax4.rb
51
+ - ext/relax4/extconf.rb
52
+ - ext/relax4/relax4_wrap.c
53
+ - ext/relax4/relax4.c
54
+ - ext/relax4/relax4.h
55
+ - test/relax4/test_solve_5.inp
56
+ - test/relax4/test_solve_6.inp
57
+ - test/relax4/test_solve_4.inp
58
+ - test/relax4/RELAX4.INP
44
59
  - README.rdoc
45
- - test/test_relax4.rb
60
+ - test/relax4/relax4_test.rb
46
61
  has_rdoc: true
47
62
  homepage: http://relax4.rubyforge.org/
48
63
  licenses: []
@@ -52,12 +67,11 @@ rdoc_options:
52
67
  - --main
53
68
  - README.rdoc
54
69
  - --title
55
- - relax4-1.1.0
70
+ - relax4-1.2.0
56
71
  - --exclude
57
72
  - ext
58
73
  require_paths:
59
74
  - lib
60
- - ext
61
75
  required_ruby_version: !ruby/object:Gem::Requirement
62
76
  none: false
63
77
  requirements:
@@ -79,9 +93,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
93
  requirements: []
80
94
 
81
95
  rubyforge_project: relax4
82
- rubygems_version: 1.3.7
96
+ rubygems_version: 1.6.2
83
97
  signing_key:
84
98
  specification_version: 3
85
99
  summary: The RELAX IV code for the Minimum Cost Network Flow Problem
86
100
  test_files:
87
- - test/test_relax4.rb
101
+ - test/relax4/relax4_test.rb