home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
200-299
/
ff250.lzh
/
ASimplex
/
ASimplex.doc
< prev
next >
Wrap
Text File
|
1989-09-16
|
11KB
|
382 lines
ASimplex Version 1.5
====================
THE AMIGA-Simplex-Program
(c) 07.08.1989 Stefan Foerster
"ASimplex" is placed in the Public Domain. Nevertheless no part of this
program may be sold or used in any commercial program. Private use is free.
This is version 1.5 of "ASimplex". Its new features are:
o I fixed a bug that caused ASimplex 1.2 to stop after phase I with the
message "This problem is not solveable" with some linear programs,
because of numerical instability. This is the main reason of this
update.
o It is now possible to run ASimplex from CLI.
o ASimplex now uses its own window for I/O.
o Some new/improved ASimplex-commands.
I hope that this release is bug-free and bullet-proof. If it is not or
if you have any suggestions or money that you want to send me, here is
my address:
Stefan Foerster
Weinbergstr. 29
8877 Burtenbach
West-Germany
ASimplex is an implementation of the famous simplex-algorithm for solving
linear programs. It was developed as a project in the course "Optimierung I"
held at the university of Augsburg by Prof. Dr. Groetschel. It is written
in C using the Manx Aztec C Compiler V3.6a.
In general, linear programs are of the form
max dx (or min dx), Ax = a, Bx <= b, Cx >= c, l <= x <= u,
where A, B and C are matrices and a,b,c,d,x,l and u are vectors.
dx is called the objective (or cost) function that is to be maximized (or
minimized) subject to the constraints Ax = a, Bx <=b, Cx >=c and l <= x <= u.
For example:
min x1 + x2 - x3
subject to x1 - 4*x2 + 3*x3 <= 6
x1 + 2*x2 - x3 <= 1
x1 + 2*x2 + x3 <= 8
0 <= x1 <= 1
0 <= x2 <= 1
0 <= x3 <= 3
with
/ 1 -4 3 \ / 6 \ / 1 \ / 0 \ / 1 \ / x1 \
B = | 1 2 -1 |, b = | 1 |, d = | 1 |, u = | 0 |, l = | 1 |, x = | x2 |
\ 1 2 1 / \ 8 / \-1 / \ 0 / \ 3 / \ x3 /
Commands of ASimplex:
---------------------
HELP
HELP lets you see all possible commands.
LOAD <file> [-cGOAL] [-bRHS] [-rRANGE] [-uBOUND] [-m] [-fFILE]
With LOAD ASimplex reads the data of a linear program. The data must be
in the standardized MPSX-format (MPSX is a trademark of IBM). A brief
description of this format follows later; now you should only know, that
the data is subdivided into sections and it is possible for some sections
to contain data for different linear programs (e.g. different objective
functions: Data belonging to a certain objective function has a unique
identifier).
<file> The file-name of the file you want to load.
-cGOAL GOAL is the identifier of the objective function you want to use.
if -cGOAL is not specified there are two possible cases: ASimplex
uses the objective function it finds (if there is only one) or it
asks you to choose one.
-bRHS RHS is the identifier of the right hand side you want to use.
(b in the above example).
-rRANGE RANGE is the identifier of the range you want to use.
-uBOUND BOUND is the identifier of the bounds (l and u in the above
example).
-m If -m is specified, ASimplex tries to minimize the objective
functions; otherwise it tries to maximize it. If the global
setting MINIMIZE is ON (see below), then -m means maximize.
-fFILE If -fFILE is specified, ASimplex writes the result to the file
"FILE" (FILE could for example be PRT: to get the results to
the printer).
VERBOSE [N]
VERBOSE is a flag that can be ON or OFF. If it is ON, you get further
information what ASimplex currently does. Default is OFF. You can use
an optional integer [N] to print only every Nth iteration.
INVERT [N]
ASimplex permanently stores the inverse of a special matrix and updates
it every iteration. This leads to numerical errors. Therefore it is possible
to re-invert this matrix from time to time.
INVERT N sets the invert-frequency to N. Default is 50.
INVERT 0 means no re-inversion.
INVERT displays the current invert-frequency.
PRICE [MIXED|CYCL|STEEP]
PRICE sets the pricing-method ASimplex uses to find the pivot-column. I
have implemented two different ones:
- cyclic smallest index rule (CYCL): fast but in most cases leads to
more iterations than the
- steepest ascent rule (STEEP)
- MIXED is a combination of CYCL and STEEP.
MIXED is the default setting.
MINIMIZE
MINIMIZE is a flag that can be ON or OFF. If it is ON and no '-m' is
specified in the LOAD command, ASimplex minimizes the cost function,
otherwise it maximizes it. '-m' always means the opposite of the
MINIMIZE flag.
PRIORITY [N]
PRIORITY N sets the task-priority of ASimplex to N (0<=N<=20).
PRIORITY gives the current task-priority. Default is 0.
DEFAULT
DEFAULT resets everything to its default value.
QUIT
Leave ASimplex.
The MPSX-format
---------------
The data of a linear program is subdivided into sections. The sections are
NAME
ROWS
COLUMNS
RHS
RANGES
BOUNDS
ENDATA
where RANGES and BOUNDS are optional.
i) NAME-section:
The NAME-section determines the name of the linear program. In the
above example you could write
NAME example
ii) ROWS-section:
You have to give every constraint of the linear program a name. This
name and the type of the constraint is determined in the ROWS-section.
The possible types are:
N no constraint, objective function
E "=" equality
L "<=" less than or equal
G ">=" greater than or equal
In the above example you could write:
ROWS
N goal
L constr1
L constr2
L constr3
iii) COLUMNS-section:
The COLUMNS-section determines the variables and the coefficients
for every variable (in the constraints and in the objective function).
If a coefficient is not specified, it is assumed to be 0.
In the above example you could write:
COLUMNS
x1 goal 1
x1 constr1 1
x1 constr2 1
x1 constr3 1
x2 goal 1
x2 constr1 -4
x2 constr2 2
x2 constr3 2
x3 goal -1
x3 constr1 3
x3 constr2 -1
x3 constr3 1
It is possible to use two fields in one line, e.g.
x1 goal 1 constr1 1
iv) RHS-section:
In this section every value of the right hand side is determined.
If a value is missing it is assumed to be 0. Our example:
RHS
b constr1 6 constr2 1
b constr3 8
b is the name of this right hand side. If you want to define a second
right hand side, you could write
b2 constr1 -2 constr2 9
b2 constr3 3.5
It is possible to use two fields in one line.
v) RANGES-section:
Say you have the two constraints 2*x1 + x2 <= 10 and
2*x1 + x2 >= 8 .
You could write them in the form 8 <= 2*x1 + x2 <= 10 .
Then it is possible to define only one constraint in the ROWS-section
and define a range (a left hand side) in the RANGES-section, e.g.:
ROWS
l constr
...
RHS
b constr 10
...
RANGES
r constr 2 ( IMPORTANT: not 8, but 2 = 10-8 !!! )
r is the name of the range. It is possible to have several different
ranges in one RANGES-section and to specify two fields in one line.
The RANGES-section is optional.
vi) BOUNDS-section:
The BOUNDS-section defines the lower and upper bound (l and u) of the
linear program. Missing values in l are assumed to be 0 and missing
values in u are assumed to be "infinite". The BOUNDS-section is
optional. Every line begins with a "UP" (for upper bound) or "LO"
(for lower bound), followed by the name of the bounds. It is possible
to specify more than one bounds-name. Our example:
BOUNDS
UP bound x1 1
UP bound x2 1
UP bound x3 3
vii) ENDATA-section:
ENDATA simply is the end of the data.
Further notes on MPSX:
----------------------
- Identifier are restricted up to 8 characters. They can consist of every
printable character (except of space- and tab-characters). Lowercase
letters are converted to uppercase letters. The identifier after NAME
can have up to 33 characters to be compatible to AmigaDOS.
- Fields don't have to start in special columns (as in the original MPSX-
format coming from hollerith-cards). The only restriction is, that
section names have to start in column 1 the other lines mustn't start in
column 1.
- Lines can have a maximum length of 255 charcters. Every line must have a
new-line-character ('\n') at the end.
Technical notes:
----------------
- ASimplex uses double precision IEEE-arithmetic. "infinite" is represented
as NAN (Not A Number).
- The linear programs can have any size that fits into the memory. The only
"restriction" is that you can't have more than 32767 rows or columns.
But that's not really restricting, because e.g. you'd have a LP with
10000 rows and 20000 columns you'd need 2.2GBytes!
- If you have a PAL-Amiga you can change the size of the I/O-window by
simply replacing the line
#define NTSC 1 with
#define PAL 1
an recompiling ASimplex with the make-utility.
Test-LPs:
---------
I have also included some LPs that I used to test ASimplex. AFIRO,
ADLITTLE, SHARE2B and ISRAEL are four of the standard-test-LPs you
can get via NETLIB from the Bell Laboratories. K_MINTY is a Klee-
Minty-problem as an example that needs a lot of iterations compared
to its size. The other LPs are my creations.
Name Rows Cols Nonzeros Optimal value
-------------------------------------------------------------------
AFIRO 28 32 88 min = -4.6475314285714e+02
ADLITTLE 57 97 465 min = 2.2549496316238e+05
SHARE2B 97 79 730 min = -4.1573224074142e+02
ISRAEL 175 142 2358 min = -8.9664482186305e+05
EXAMPLE 4 3 12 min = -2.25, max = 1.0
K_MINTY 11 10 65 min = 0 , max = 1e+18
A36 3 6 14 min = 0 , max = unbounded
P142 6 3 12 min = 9.313225746e-10
max = 4011719.987
P142DUAL 4 5 14 min = 4011719.987
max = unbounded