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 +16 -12
- data/ext/{extconf.rb → relax4/extconf.rb} +0 -0
- data/ext/{relax4.c → relax4/relax4.c} +0 -0
- data/ext/{relax4.h → relax4/relax4.h} +0 -0
- data/ext/{relax4_wrap.c → relax4/relax4_wrap.c} +38 -26
- data/lib/relax4/version.rb +4 -1
- data/lib/relax4.rb +6 -6
- data/test/{RELAX4.INP → relax4/RELAX4.INP} +0 -0
- data/test/{test_relax4.rb → relax4/relax4_test.rb} +6 -4
- data/test/{test_solve_4.inp → relax4/test_solve_4.inp} +0 -0
- data/test/{test_solve_5.inp → relax4/test_solve_5.inp} +0 -0
- data/test/{test_solve_6.inp → relax4/test_solve_6.inp} +0 -0
- metadata +36 -22
data/README.rdoc
CHANGED
@@ -98,11 +98,11 @@ An assignment problem:
|
|
98
98
|
== REQUIREMENTS
|
99
99
|
|
100
100
|
Has been tested on:
|
101
|
-
*
|
102
|
-
*
|
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
|
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
|
-
|
119
|
-
|
120
|
-
git clone http://github.com/jdleesmiller/relax4_ruby.git
|
116
|
+
== DEVELOPMENT
|
121
117
|
|
122
|
-
and
|
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
|
125
|
-
|
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
|
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
|
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
|
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
|
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:/
|
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:/
|
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
|
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
|
-
|
2613
|
-
SWIG_TypeClientData(SWIGTYPE_p_IntegerArray, (void *) &
|
2614
|
-
rb_define_alloc_func(
|
2615
|
-
rb_define_method(
|
2616
|
-
rb_define_method(
|
2617
|
-
rb_define_method(
|
2618
|
-
rb_define_method(
|
2619
|
-
rb_define_singleton_method(
|
2620
|
-
|
2621
|
-
|
2622
|
-
|
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)));
|
data/lib/relax4/version.rb
CHANGED
data/lib/relax4.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'relax4
|
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>
|
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
|
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
|
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 '
|
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 '
|
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 '
|
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 '
|
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:
|
5
|
-
prerelease:
|
4
|
+
hash: 31
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 1.
|
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:
|
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
|
-
-
|
37
|
-
-
|
38
|
-
-
|
39
|
-
-
|
40
|
-
- ext/
|
41
|
-
-
|
42
|
-
-
|
43
|
-
-
|
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/
|
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.
|
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.
|
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/
|
101
|
+
- test/relax4/relax4_test.rb
|