SoPlex Doxygen Documentation
xternal.cpp
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 /**@mainpage Overview
3  @version 1.7.1
4  @author Roland Wunderling
5  @author Tobias Achterberg
6  @author Timo Berthold
7  @author Andreas Bley
8  @author Ambros Gleixner
9  @author Wei Huang
10  @author Benjamin Hiller
11  @author Thorsten Koch
12  @author Matthias Miltenberger
13  @author Sebastian Orlowski
14  @author Marc Pfetsch
15  @author Eva Ramlow
16  @author Andreas Tuchscherer
17 
18  @section Main The Sequential object-oriented simplex class library.
19 
20  This software has been implemented as a part of Roland Wunderling's
21  Ph.D. thesis "Paralleler und Objektorientierter Simplex-Algorithmus"
22  which can be found at http://www.zib.de/PaperWeb/abstracts/TR-96-09
23  (in German).
24 
25  SoPlex is part of the SCIP Optmization Suite. A tutorial article for
26  getting started with the SCIP Optimization Suite is available as ZIB
27  technical report 12-27 <a href="http://scip.zib.de/doc/ZR-12-27.pdf">here</a>.
28 
29  SoPlex is implemented in C++. The code should be compliant with the
30  current ANSI standard. RTTI and STL (other then iostream) are not used.
31  Everything is in one namespace \em soplex.
32 
33  - \ref RUN "Where does it run"
34 
35  - \ref INST "Installation"
36 
37  - \ref FLAGS "How to use the flags in the example program"
38 
39  - \ref FAQ "Frequently asked questions"
40 
41  - \ref IR "Iterative Refinement"
42 
43  - \ref PROG "Programming with SoPlex"
44 */
45 //-----------------------------------------------------------------------------
46 /**@namespace soplex
47  @brief Everything should be within this namespace.
48 
49  We have put the whole class library in the namespace soplex.
50  If anything here is defined outside, this is a mistake and
51  should be reported.
52 */
53 //-----------------------------------------------------------------------------
54 /**@defgroup Elementary Elementary Classes
55  @brief General purpose classes.
56 
57  Elementary classes are provided for general purpose use in
58  projects way beyond the scope of numerical software or linear
59  programming.
60 */
61 //-----------------------------------------------------------------------------
62 /**@defgroup Algebra Linear Algebra Classes
63  @brief Basic data types for linear algebra computations.
64 
65  Linear algebra classes provide basic data types for (sparse)
66  linear algebra computations. However, their functionality is
67  restricted to simple operations such as addition and scaling.
68  For complex tasks, such as solving linear systems of equations,
69  algorithmic classes are provided instead.
70 */
71 //-----------------------------------------------------------------------------
72 /**@defgroup Algo Algorithmic Classes
73  @brief Implementation of numerical algorithms.
74 
75  Algorithmic classes serve for implementing a variety of
76  algorithms for solving numerical (sub-)problems.
77 */
78 //-----------------------------------------------------------------------------
79 /**@page DataObjects Data Objects
80 
81  \em Data \em objects refer to C++ objects that do not allocate any
82  resources, particularly that do not allocate any memory. This
83  makes them behave just like ordinary C structures, in that both,
84  the copy constructor and assignment operator are equivalent to a
85  memcopy of the memory taken by the object. Examples for data
86  objects are all builtin types such as \c int or \c double or
87  \e simple classes such as \c complex.
88 
89  We distinguish \em data \em objects from general C++ objects that
90  may include some allocation of resources. (Note that for general
91  C++ objects that do allocate resources, this must be respected by
92  providing appropriate copy constructor and assignment operators.)
93  An example for a general C++ class is class DataArray.
94 
95  The distinction between data and general C++ objects becomes
96  relevant when using such objects in container classes such as
97  DataArray or Array.
98 */
99 //-----------------------------------------------------------------------------
100 /**@page RUN On which Platforms is SoPlex running
101 
102  The current release of SoPlex was tested to compile with the following
103  compilers / architectures:
104  <TABLE>
105  <TR><TD>Architecture</TD><TD>CPU </TD><TD>OS </TD><TD>Compiler </TD></TR>
106  <TR><TD>x86 </TD><TD>Pentium 4 3.2 GHz</TD><TD>Suse Linux 10.0 </TD><TD>GCC 4.0.2 </TD></TR>
107  <TR><TD>x86 </TD><TD>Pentium 4 3.8 GHz</TD><TD>Suse Linux 10.0 </TD><TD>Intel 9.0.026 </TD></TR>
108  <TR><TD>x86 </TD><TD>Pentium 4 3.2 GHz</TD><TD>Windows XP SP2 </TD><TD>MS Visual Studio 2003</TD></TR>
109  <TR><TD>x86_64 </TD><TD>AMD Opteron 875 </TD><TD>SLES 9 </TD><TD>GCC 4.0.2 </TD></TR>
110  <TR><TD>PowerPC </TD><TD>G5 2.3 </TD><TD>MacOS-X 10.4.4 </TD><TD>GCC 4.0.0 </TD></TR>
111  <TR><TD>Power4 </TD><TD>Power4 1.7 GHz </TD><TD>AIX 5.1 </TD><TD>VisualAge 6 </TD></TR>
112  <TR><TD>Alpha </TD><TD>21264a 750 MHz </TD><TD>OSF1 V5.1 </TD><TD>Compaq 6.5-39 </TD></TR>
113  <TR><TD>Sparc </TD><TD>Ultra 60 </TD><TD>Solaris 9 </TD><TD>Sun Studio 11 </TD></TR>
114  </TABLE>
115 
116  We expect SoPlex to be compilable using any sufficiently recent compiler.
117  Remember, your mileage may vary.
118  */
119 //-----------------------------------------------------------------------------
120 /**@page INST Installation
121 
122  \section Prerequisites Prerequisites
123  You need the following programs to compile SoPlex:
124 
125  - C++ compiler (e.g. http://www.gnu.org/software/gcc)
126  - gnu make http://www.gnu.org/software/make
127  - gnu awk http://www.gnu.org/software/gawk (if you want the \c check target)
128  - doxygen http://www.doxygen.org (if you want to generate the documentation)
129 
130  After receiving SoPlex you have to uncompress it with \c gzip
131  (http://www.gnu.org/software/gzip) and
132  unpack it with \c tar (http://www.gnu.org/software/tar)
133  into a directory. Then change to that directory.
134 
135  \section Tested Linux/x86, Linux/AXP, Darwin, Tru64, Solaris, IRIX, HP-UX
136  If you are working under one those OSes you should try the following:
137 
138  \c gmake \c COMP=xxx \c OPT=yyy
139 
140  with \c xxx being one of \c gnu, \c intel, \c sun, \c hp, \c sgi, \c compaq
141  or \c ibm
142  and \c yyy one of \c dbg (if you want the debug version) or \c opt
143  (if you want the optimized version).
144 
145  This should generate a binary in the \c bin subdirectory.
146 
147  \section Others If the previous section was not for you
148  First the Makefile tries to find out the OS and the
149  architecture by using the \c uname command.
150  If your OS or architecture is missing, please update the
151  Makefile and submit the change to me.
152 
153  Then a submakefile from \c make/make.OS.ARCH.COMP.OPT is included in
154  the main Makefile. You should adapt the compiler flags as needed.
155  Be especially careful with the \c AR setting since some C++ compilers do
156  not like using the standard \c \c ar program together with code that uses
157  templates.
158 
159  If this all does not work, change to the \c src directory and type
160 
161  \c CC \c *.cpp
162 
163  This should do the trick. Adding \c -DNDEBUG gives you a non debugging
164  version. Add flags as needed.
165 
166  \section Testing Testing the Binary
167  After you compiled the binary you should download the Netlib LP files at
168  http://www.zib.de/Optimization/Software/Soplex/netlib.tar.gz and
169  unpack them in the \c check directory. Then you can try
170 
171  \c gmake \c COMP=xxx \c OPT=dbg \c quick
172 
173  \c gmake \c COMP=xxx \c OPT=opt \c quick
174 
175  \c gmake \c COMP=xxx \c OPT=opt \c check
176 
177  Use the \c check target together with \c OPT=dbg only if you have really
178  a lot of time. \c quick should run in a few minutes and \c check will
179  need between less than one hour and a day, depending on your machine.
180 
181  \c quick should report no fails at all. \c check should report no fails in the
182  \c LC and \c EC columns and in the \c LR and \c ER columns only with
183  the instances greenbea, greenbeb, pilot-ja or pilot87.
184  One or two fails is normal, above four is probably a problem with the
185  compiler. Look how big the error is. Try again with less optimization.
186  Our results are available at
187  http://www.zib.de/Optimization/Software/Soplex/results
188  to compare with.
189 
190  \section Documentation Generating the documentation
191  If you have \c doxygen (and \c dot) installed, you just can say
192 
193  \c gmake \c doc
194 
195  After that the documentation should be in doc/html.
196 
197  \section Installation Installation
198  The binary is in the \c bin directory, the library in \c lib and all
199  headers are in \c src. Feel free to install them at a suitable place.
200 
201  \section Naming Naming of the OPT Variable
202 
203  - dbg (debugging) -DNDEBUG is \b not set. Optimization is mostly off
204  and debugging info is generated.
205 
206  - std (standard) -DNDEBUG is set. All optimizations may be switched on
207  that do \b not \b alter the floating point behaviour or may
208  otherwise by result in wrong code.
209 
210  - opt (optimized) -DNDEBUG is set. All optimizations may be switched on,
211  as long as the code seems to run correctly. The code should run
212  on the relevant architectures. Best is something like -fast that
213  uses the right optimizations for the architecture that is used.
214 
215  - opt-XXX (optimized for XXX) like opt-p4. This includes optimization
216  for a specific processor.
217 
218  - prf (profile) like opt, but generate profile data.
219 
220  - XXX-ld (long-double) same as XXX but with long doubles.
221  */
222 //-----------------------------------------------------------------------------
223 /**@page FAQ Frequently Asked Questions
224  * \htmlinclude faq.inc
225  * \htmlinclude faqcss.inc
226  */
227 //-----------------------------------------------------------------------------
228 /**@page FLAGS How to use the flags in the example program
229 
230  Here are some tips on which flags to use with the example program:
231 
232  If you have more constraints (rows) than variables (cols) it is
233  a good idea to try the \c -r flag to choose a row-wise representation
234  of the basis.
235 
236  Setting the different epsilons to a smaller value like 1e-18 or 1e-20
237  (using \c -zz or \c -zu) might improve the quality of the
238  solution, but may also slow down the program. Setting the epsilons to
239  bigger values may speed up the algorithm, but values greater than 1e-12
240  are definitely a bad idea.
241 
242  Setting \c -d to smaller values like 1e-7 or 1e-8 will improve the
243  quality of the solution, but it will take longer. Values smaller
244  then 1e-9 are not recommended. The \c -d value should be
245  substantial bigger then the \c -z values.
246 
247  If the default settings are too slow, using \c -e eventually together
248  with \c -p1 might improve the running time.
249 */
250 //-----------------------------------------------------------------------------
251 /**@page PROG Programming with SoPlex
252 
253  The SoPlex class library comprises classes that may be categorized into
254  three different types:
255 
256  - Elementary classes are provided for general purpose use in
257  projects way beyond the scope of numerical software or linear
258  programming.
259  - Linear algebra classes provide basic data types for (sparse)
260  linear algebra computations. However, their functionality is
261  restricted to simple operations such as addition and scaling.
262  For complex tasks, such as solving linear systems of equations,
263  algorithmic classes are provided instead.
264  - Algorithmic classes serve for implementing maybe a variety of
265  algorithms for solving numerical (sub-)problems.
266 
267  The following sections are dedicated to users who want to
268  provide own pricers, ratio test, start basis generation codes or
269  LP simplifiers to use with SoPlex or who want to derive own
270  implementations (e.g. parallel versions) using SoPlex.
271 
272  @section Representation Virtualizing the Representation
273  The primal Simplex on the columnwise representation is
274  structurally equivalent to the dual Simplex on the rowwise
275  representation and vice versa (see below). Hence, it is
276  desirable to treat both cases in a very similar manner. This
277  is supported by the programmer's interface of SoPlex which
278  provides access methods for all internal data in two ways: one
279  is relative to the "physical" representation of the LP in
280  rows and columns, while the other is relative to the chosen
281  basis representation. If e.g. a soplex::SPxPricer is
282  written using the second type of methods only (which will
283  generally be the case), the same code can be used for running
284  SoPlex's simplex algorithm for both representations.
285  We will now give two examples for this
286  abstraction from the chosen representation.
287 
288  Methods \c vector() will return a column or a row vector,
289  corresponding to the chosen basis representation.
290  The other "vectors" will be referred to as \em covectors:
291 
292  <TABLE>
293  <TR><TD>&nbsp; </TD><TD>ROW </TD><TD>COLUMN </TD></TR>
294  <TR><TD>vector </TD><TD>rowVector</TD><TD>colVector</TD></TR>
295  <TR><TD>coVector</TD><TD>colVector</TD><TD>rowVector</TD></TR>
296  </TABLE>
297 
298  Whether the soplex::SPxBasis::Desc::Status of a variable indicates that the
299  corresponding vector is in the basis matrix or not also depends on the
300  chosen representation. Hence, methods \c isBasic() are provided to get the
301  correct answer for both representations.
302 
303  @section Simplex Vectors and Bounds
304  The Simplex algorithms keeps three vectors which are associated to each basis.
305  Two of them are required for the pricing, while the third one is needed for
306  detecting feasibility of the basis. For all three vectors, bounds are
307  defined. The Simplex algorithm changes the basis until all three vectors
308  satisfy their bounds, which means that the optimal solution has been found.
309 
310  With each update of the basis, also the three vectors need to be
311  updated. This is best supported by the use of \c UpdateVectors.
312 
313  @subsection Variables
314  The Simplex algorithm works with two types of variables, primals and
315  duals. The primal variables are associated with each column of
316  an LP, whereas the dual variables are associated with each row.
317  However, for each row a slack variable must be added to the set of
318  primals (to represent inequalities), and a reduced cost variable must be
319  added for each column (to represent upper or lower bounds). Note, that
320  mathematically, one dual variable for each bound (upper and lower) should
321  be added. However, this variable would always yield the same value and
322  can, hence, be implemented as one.
323 
324  To summarize, we have a primal variable for each LP column and row
325  (i.e., its slack) as well as a dual variable for each LP row and column
326  (i.e., its bounds). However, not all these values need to be stored and
327  computed, since the structure of the Simplex algorithms allow to
328  keep them implicitly.
329 
330  If the SPxBasis's Status of a row or column is one of \c P_ON_LOWER,
331  \c P_ON_UPPER, \c P_FIXED or \c P_FREE, the value of the corresponding
332  primal variable is the lower, upper or both bound(s) or 0, respectively.
333  The corresponding dual variable needs to be computed. Equivalently, for
334  a Status of \c D_FREE, \c D_ON_UPPER, \c D_ON_LOWER, \c D_ON_BOTH or
335  \c D_UNDEFINED, the corresponding dual variable is 0, whereas the primal
336  one needs to be computed.
337 
338  The following vectors are declared for holding the values to be computed:
339  \c primRhs, \c primVec (with dimension \c nCols()) for the primal
340  variables, and \c dualRhs, \c dualVec (with dimension \c nRows()) for the
341  dual variables. The additional variable \c addvec (with dimension \c coDim())
342  depends on the representation.
343 
344  @subsection Bounds
345  Primal and dual variables are bounded (including \f$\pm\infty\f$ as
346  bounds). If all primal variables are within their bounds, the
347  Simplex basis is said to be primal feasible. Analogously, if all
348  dual variables are within their bounds, its is called dual
349  feasible. If a basis is both, primal and dual feasible, the
350  optimal solution has been found.
351 
352  In the dual Simplex, the basis is maintained dual feasible, while
353  primal feasibility is improved via basis updates. However, for
354  numerical reasons dual feasibility must be relaxed from time to time.
355  Equivalently, primal feasibility will be relaxed to
356  retain numerical stability in the primal Simplex algorithm.
357 
358  Relaxation of (dual or primal) feasibility is achieved by
359  relaxing the bounds of primal or dual variables. However, for each
360  type of Simplex only the corresponding bounds need to be
361  relaxed. Hence, we define only one vector of upper and lower bound
362  for each row and column and initialize it with primal or dual
363  bound, depending on the Simplex type (see \c theURbound,
364  \c theLRbound, \c theUCbound, \c theLCbound).
365 */
366 //-----------------------------------------------------------------------------
367 /**@page IR Iterative Refinement
368 
369  Since version 1.7, SoPlex provides the new feature \em iterative \em refinement that
370  allows for computing extended-precision solutions beyond the limits of
371  standard floating-point arithmetic. It may be particularly helpful for
372  numerically troublesome LPs and applications that require solutions within
373  tight feasibility tolerances.
374 
375  Iterative refinement is still under development and deactivated by default.
376  In the following, we explain in detail how to install and use iterative
377  refinement in SoPlex 1.7. Be aware that the interface may change in future
378  releases.
379 
380  @section IR-Installation Installation
381 
382  For iterative refinement, SoPlex must be built with support for
383  GMP, the GNU Multiple Precision library (http://www.gmplib.org/). Since
384  SoPlex uses the C++ interface of GMP, both libgmp and libgmpxx must be
385  available on your system.
386 
387  When using SoPlex's Makefile build system, it suffices to make with option
388  GMP=true, see the INSTALL file for details. If you use a different build
389  system than the provided Makefile, you need to define the preprocessor flag
390  SOPLEX_WITH_GMP and link with libgmp and libgmpxx.
391 
392  @section IR-Usage Usage
393 
394  SoPlex 1.7 comes with a new parameter called "iterative refinement
395  threshold". At the command line, this threshold can be changed via option
396  -R; the callable library provides the methods \ref soplex::SoPlex::setIrthreshold() and
397  \ref soplex::SPxSolver::setIrthreshold(). By default, this threshold is 1e-12.
398 
399  If GMP support is not available, the primal and dual feasibility tolerance
400  cannot be set below the iterative refinement threshold. With GMP support
401  enabled, as soon as either the primal or dual feasibility tolerance (command
402  line options -f and -o, respectively) is set to a value smaller than this
403  threshold, iterative refinement is performed automatically.
404 
405  For a detailed explanation of the iterative refinement algorithm see the ZIB
406  technical report 12-19 available online at
407 
408  http://opus4.kobv.de/opus4-zib/frontdoor/index/index/docId/1545
409 
410  Vaguely speaking, at each round of the iterative refinement process, SoPlex
411  computes the primal and dual violation of the current solution in exact
412  arithmetic and uses this to set up an LP with modified bounds, sides, and
413  objective function. The solution to this LP is then used to correct the
414  solution and reduce primal and dual violation. This is repeated until the
415  requested feasibility and optimality tolerance is reached.
416 
417  @section IR-Limitations Current limitations
418 
419  Currently, iterative refinement is only implemented for LPs with
420  an optimal solution; unbounded or infeasible LPs cannot be handled, yet.
421  Furthermore, SoPlex supports exact arithmetic only internally. Input and
422  output cannot yet be performed in standard floating-point precision. This
423  leads to the following two limitations.
424 
425  First, SoPlex only accepts LPs in double-precision, hence when parsing an LP
426  or MPS file, roundoff errors may be introduced and hence the LP in SoPlex may
427  be slightly perturbed. Be aware that the result returned by SoPlex hence
428  might apply for a slightly modified problem. In extreme cases, this can even
429  lead to the internally stored LP becoming slightly infeasible. While a
430  standard flaoting-point LP solver would not detect these minimal
431  infeasibilities, the iterative refinement procedure will do so if high
432  feasibility tolerances are used. Because of this, we have currently decided
433  that in case infeasibility is detected at higher rounds of iterative
434  refinement, SoPlex will return the solution of the previous round.
435 
436  Second, SoPlex can currently return only a floating-point rounding of the
437  high-precision solution computed internally. Be aware that even if iterative
438  refinement terminates and claims that the requested tolerances have been
439  reached, this may not hold for the solution returned by the interface, e.g.,
440  the options -x and -y on the command line. Note that the basis information
441  returned by SoPlex (command line option -bw) is exact in any case and tools
442  like PerPlex or QSopt_ex can be used to recompute the corresponding
443  primal-dual solution in exact arithmetic.
444 
445  @section IR-Feedback Feedback
446 
447  These limitations will be overcome in future release. We appreciate any
448  feedback, comments, and questions on this new feature. They can be directed
449  to soplex@zib.de and will help improve the future development of SoPlex.
450  */
451 //-----------------------------------------------------------------------------
452 
453