relax4 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +145 -0
- data/ext/extconf.rb +11 -0
- data/ext/relax4.c +3935 -0
- data/ext/relax4.h +187 -0
- data/ext/relax4_f2c.h +247 -0
- data/ext/relax4_wrap.c +2332 -0
- data/lib/relax4/version.rb +3 -0
- data/lib/relax4.rb +223 -0
- metadata +77 -0
data/README.rdoc
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
= relax4_ruby
|
2
|
+
|
3
|
+
http://relax4.rubyforge.org
|
4
|
+
|
5
|
+
http://github.com/jdleesmiller/relax4_ruby
|
6
|
+
|
7
|
+
== DESCRIPTION
|
8
|
+
|
9
|
+
Ruby interface for the RELAX IV code for the minimum cost network flow problem.
|
10
|
+
In the words of the code's authors:
|
11
|
+
|
12
|
+
PURPOSE - THIS ROUTINE IMPLEMENTS THE RELAXATION METHOD
|
13
|
+
OF BERTSEKAS AND TSENG (SEE [1], [2]) FOR LINEAR
|
14
|
+
COST ORDINARY NETWORK FLOW PROBLEMS.
|
15
|
+
|
16
|
+
[1] BERTSEKAS, D. P., "A UNIFIED FRAMEWORK FOR PRIMAL-DUAL METHODS ..."
|
17
|
+
MATHEMATICAL PROGRAMMING, VOL. 32, 1985, PP. 125-145.
|
18
|
+
[2] BERTSEKAS, D. P., AND TSENG, P., "RELAXATION METHODS FOR
|
19
|
+
MINIMUM COST ..." OPERATIONS RESEARCH, VOL. 26, 1988, PP. 93-114.
|
20
|
+
|
21
|
+
THE RELAXATION METHOD IS ALSO DESCRIBED IN THE BOOKS:
|
22
|
+
|
23
|
+
[3] BERTSEKAS, D. P., "LINEAR NETWORK OPTIMIZATION: ALGORITHMS AND CODES"
|
24
|
+
MIT PRESS, 1991.
|
25
|
+
[4] BERTSEKAS, D. P. AND TSITSIKLIS, J. N., "PARALLEL AND DISTRIBUTED
|
26
|
+
COMPUTATION: NUMERICAL METHODS", PRENTICE-HALL, 1989.
|
27
|
+
|
28
|
+
THIS CODE WAS WRITTEN BY DIMITRI P. BERTSEKAS AND PAUL TSENG,
|
29
|
+
WITH A CONTRIBUTION BY JONATHAN ECKSTEIN IN THE PHASE II INITIALIZATION.
|
30
|
+
THE ROUTINE AUCTION WAS WRITTEN BY DIMITRI P. BERTSEKAS AND IS BASED ON
|
31
|
+
THE METHOD DESCRIBED IN THE PAPER:
|
32
|
+
|
33
|
+
[5] BERTSEKAS, D. P., "AN AUCTION/SEQUENTIAL SHORTEST PATH ALGORITHM
|
34
|
+
FOR THE MINIMUM COST FLOW PROBLEM", LIDS REPORT P-2146, MIT, NOV. 1992.
|
35
|
+
|
36
|
+
The original source can be downloaded from:
|
37
|
+
* http://elib.zib.de/pub/Packages/mathprog/mincost/relax-4/
|
38
|
+
|
39
|
+
See also:
|
40
|
+
* http://www-neos.mcs.anl.gov/neos/solvers/lno:RELAX4/RELAX4.html
|
41
|
+
* http://web.mit.edu/afs/athena.mit.edu/user/d/i/dimitrib/www/RELAX4.txt
|
42
|
+
|
43
|
+
== SYNOPSIS
|
44
|
+
|
45
|
+
require 'rubygems'
|
46
|
+
require 'relax4'
|
47
|
+
|
48
|
+
# From Figure 29.3 of Cormen, Leiserson, Rivest and Stein (2001).
|
49
|
+
# Introduction to Algorithms, 2nd Edition.
|
50
|
+
#
|
51
|
+
# (2) edges are directed ((1,2), (1,3), ...)
|
52
|
+
# / | \ each edge has a cost and a capacity
|
53
|
+
# / | \
|
54
|
+
# (1) | (4) the aim is to find the flow on each edge such that we
|
55
|
+
# \ | / move four units of flow from (1) to (4) at minimum cost
|
56
|
+
# \ | /
|
57
|
+
# (3)
|
58
|
+
#
|
59
|
+
Relax4.solve(
|
60
|
+
:demands => [-4, 0, 0, 4],
|
61
|
+
:start_nodes => [ 1, 1, 2, 2, 3],
|
62
|
+
:end_nodes => [ 2, 3, 3, 4, 4],
|
63
|
+
:costs => [ 2, 5, 3, 7, 1],
|
64
|
+
:capacities => [ 5, 2, 1, 2, 4]) #=> [2, 2, 1, 1, 3]
|
65
|
+
|
66
|
+
A lower-level interface is also available; see the docs for the Relax4 module.
|
67
|
+
|
68
|
+
== REQUIREMENTS
|
69
|
+
|
70
|
+
The following packages were required to install on Ubuntu 10.04:
|
71
|
+
|
72
|
+
* ruby, ruby-dev, rubygems, rake
|
73
|
+
|
74
|
+
The bindings were generated with f2c (FORTRAN to C converter) and SWIG
|
75
|
+
(www.swig.org), but you don't need either to build the gem.
|
76
|
+
|
77
|
+
Has been tested on:
|
78
|
+
* x86-linux (Ubuntu 10.04) with Ruby 1.8.7-p302
|
79
|
+
* x86-linux (Ubuntu 10.04) with Ruby 1.9.2-p0
|
80
|
+
* x86_64-linux (CentOS) with Ruby 1.8.7-p72
|
81
|
+
|
82
|
+
== INSTALL
|
83
|
+
|
84
|
+
You should be able to install with
|
85
|
+
|
86
|
+
gem install relax4
|
87
|
+
|
88
|
+
on an x86_64-linux machine. Otherwise, you'll have to get the source
|
89
|
+
|
90
|
+
git clone http://github.com/jdleesmiller/relax4_ruby.git
|
91
|
+
|
92
|
+
and run
|
93
|
+
|
94
|
+
gem build relax4.gemspec
|
95
|
+
gem install relax4-<version>.gem
|
96
|
+
|
97
|
+
== TODO
|
98
|
+
|
99
|
+
* there are some hard-coded parameters that could be exposed
|
100
|
+
* problem state is global (cf. FORTRAN), so can have only one instance at a time
|
101
|
+
|
102
|
+
== LICENSE
|
103
|
+
|
104
|
+
The authors of RELAX IV (D.P. Bertsekas and P. Tseng) released the code with the
|
105
|
+
following user guidelines:
|
106
|
+
|
107
|
+
THIS ROUTINE IS IN THE PUBLIC DOMAIN TO BE USED ONLY FOR RESEARCH
|
108
|
+
PURPOSES. IT CANNOT BE USED AS PART OF A COMMERCIAL PRODUCT, OR
|
109
|
+
TO SATISFY IN ANY PART COMMERCIAL DELIVERY REQUIREMENTS TO
|
110
|
+
GOVERNMENT OR INDUSTRY, WITHOUT PRIOR AGREEMENT WITH THE AUTHORS.
|
111
|
+
USERS ARE REQUESTED TO ACKNOWLEDGE THE AUTHORSHIP OF THE CODE,
|
112
|
+
AND THE RELAXATION METHOD. THEY SHOULD ALSO REGISTER WITH THE
|
113
|
+
AUTHORS TO RECEIVE UPDATES AND SUBSEQUENT RELEASES.
|
114
|
+
|
115
|
+
The author of the RELAX IV code is:
|
116
|
+
|
117
|
+
DIMITRI P. BERTSEKAS
|
118
|
+
LABORATORY FOR INFORMATION AND DECISION SYSTEMS
|
119
|
+
MASSACHUSETTS INSTITUTE OF TECHNOLOGY
|
120
|
+
CAMBRIDGE, MA 02139
|
121
|
+
(617) 253-7267, DIMITRIB@MIT.EDU
|
122
|
+
|
123
|
+
The code for these Ruby bindings is released under the MIT license.
|
124
|
+
|
125
|
+
Copyright (c) 2010 John Lees-Miller
|
126
|
+
|
127
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
128
|
+
a copy of this software and associated documentation files (the
|
129
|
+
'Software'), to deal in the Software without restriction, including
|
130
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
131
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
132
|
+
permit persons to whom the Software is furnished to do so, subject to
|
133
|
+
the following conditions:
|
134
|
+
|
135
|
+
The above copyright notice and this permission notice shall be
|
136
|
+
included in all copies or substantial portions of the Software.
|
137
|
+
|
138
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
139
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
140
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
141
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
142
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
143
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
144
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
145
|
+
|
data/ext/extconf.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
|
3
|
+
#have_header('f2c.h') or raise 'You must install f2c (FORTRAN to C).'
|
4
|
+
|
5
|
+
# This is slightly nonstandard, because f2c always inserts a function MAIN__
|
6
|
+
# into the translated source, and it won't link unless this function is present.
|
7
|
+
#have_library('f2c','e_rsle') {|src|
|
8
|
+
# src += "\nint MAIN__(void){ }\n"
|
9
|
+
#} or raise 'You must install f2c (FORTRAN to C converter).'
|
10
|
+
|
11
|
+
create_makefile("relax4")
|