Scippy

SoPlex

Sequential object-oriented simPlex

xternal.cpp
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the class library */
4/* SoPlex --- the Sequential object-oriented simPlex. */
5/* */
6/* Copyright (c) 1996-2024 Zuse Institute Berlin (ZIB) */
7/* */
8/* Licensed under the Apache License, Version 2.0 (the "License"); */
9/* you may not use this file except in compliance with the License. */
10/* You may obtain a copy of the License at */
11/* */
12/* http://www.apache.org/licenses/LICENSE-2.0 */
13/* */
14/* Unless required by applicable law or agreed to in writing, software */
15/* distributed under the License is distributed on an "AS IS" BASIS, */
16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17/* See the License for the specific language governing permissions and */
18/* limitations under the License. */
19/* */
20/* You should have received a copy of the Apache-2.0 license */
21/* along with SoPlex; see the file LICENSE. If not email to soplex@zib.de. */
22/* */
23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25/**@file xternal.cpp
26 * @brief SoPlex documentation pages
27 * @author Ambros Gleixner
28 * @author Thorsten Koch
29 * @author Matthias Miltenberger
30 * @author Sebastian Orlowski
31 * @author Marc Pfetsch
32 * @author Andreas Tuchscherer
33 */
34
35/**@mainpage Overview
36 *
37 * @section MAIN What is SoPlex?
38 *
39 * SoPlex is an optimization package for solving linear programming problems
40 * (LPs) that can be used standalone via a command line interface and as a
41 * callable library. Its main features are:
42 *
43 * - an advanced implementation of the primal and dual revised simplex
44 * algorithm,
45 *
46 * - an object-oriented software design written in C++,
47 *
48 * - presolving, scaling, exploitation of sparsity, hot-starting from any
49 * regular basis,
50 *
51 * - column- and row-oriented form of the simplex algorithm,
52 *
53 * - a compile-time option to use 80bit extended ("quad") precision for
54 * numerically difficult LPs, and
55 *
56 * - special support for the exact solution of LPs over the rational numbers.
57 *
58 * SoPlex has been used in numerous research and industry projects and is the
59 * standard LP solver linked to the constraint integer programming solver <a
60 * href="http://scipopt.org/">SCIP</a>.
61 *
62 *@section INST Download, License, and Installation
63 *
64 * SoPlex can be downloaded in source code and as precompiled binaries from the
65 * <a href="http://soplex.zib.de">SoPlex</a> web page. It is also distributed
66 * as part of the <a href="http://scipopt.org/">SCIP Optimization Suite</a>.
67 *
68 * SoPlex is distributed under the terms of the \ref LICENSE "Apache 2.0"
69 * See the <a
70 * href="http://soplex.zib.de">SoPlex</a> web page or contact us for more
71 * information.
72 *
73 * For help with the installation please consult the \ref INSTALL "INSTALL" file.
74 *
75 * @section GETTINGSTARTED Getting started
76 *
77 * - \ref FAQ "Frequently Asked Questions"
78 *
79 * - \ref CMD "How to use the SoPlex command line"
80 *
81 * - \ref LIB "How to use SoPlex as a callable library"
82 *
83 * - \ref PARS "Parameters in SoPlex"
84 *
85 * - \ref PROG "Programming with SoPlex"
86 *
87 * - \ref EXACT "How to use SoPlex as an exact LP solver"
88 *
89 * - \ref CHANGELOG "CHANGELOG"
90 *
91 * A tutorial article for getting started with the SCIP Optimization Suite,
92 * which includes SoPlex, is available as <a
93 * href="http://scipopt.org/doc/ZR-12-27.pdf">ZIB-Report 12-27</a>.
94 *
95 * @section AUTHORS Authors
96 *
97 * The initial implementation of SoPlex has been developed by Roland Wunderling
98 * as part of his Ph.D. thesis <a
99 * href="https://opus4.kobv.de/opus4-zib/files/538/TR-96-09.pdf">"Paralleler und
100 * Objektorientierter Simplex-Algorithmus"</a> from 1996. Since then many
101 * developers have maintained and improved the underlying algorithms. See the
102 * <a href="http://soplex.zib.de">SoPlex</a> web page for a comprehensive list
103 * of all contributors.
104 *
105 * @version 7.1.2.0
106 */
107
108
109/**@namespace soplex
110 @brief Everything should be within this namespace.
111
112 We have put the whole class library in the namespace soplex.
113 If anything here is defined outside, this is a mistake and
114 should be reported.
115*/
116
117
118/**@defgroup Elementary Elementary Classes
119 @brief General purpose classes.
120
121 Elementary classes are provided for general purpose use in
122 projects way beyond the scope of numerical software or linear
123 programming.
124*/
125
126/**@defgroup Algebra Linear Algebra Classes
127 @brief Basic data types for linear algebra computations.
128
129 Linear algebra classes provide basic data types for (sparse)
130 linear algebra computations. However, their functionality is
131 restricted to simple operations such as addition and scaling.
132 For complex tasks, such as solving linear systems of equations,
133 algorithmic classes are provided instead.
134*/
135
136/**@defgroup Algo Algorithmic Classes
137 @brief Implementation of numerical algorithms.
138
139 Algorithmic classes serve for implementing a variety of
140 algorithms for solving numerical (sub-)problems.
141*/
142
143/**@page DataObjects Data Objects
144
145 \em Data \em objects refer to C++ objects that do not allocate any
146 resources, particularly that do not allocate any memory. This
147 makes them behave just like ordinary C structures, in that both,
148 the copy constructor and assignment operator are equivalent to a
149 memcopy of the memory taken by the object. Examples for data
150 objects are all builtin types such as \c int or \c double or
151 \e simple classes such as \c complex.
152
153 We distinguish \em data \em objects from general C++ objects that
154 may include some allocation of resources. (Note that for general
155 C++ objects that do allocate resources, this must be respected by
156 providing appropriate copy constructor and assignment operators.)
157 An example for a general C++ class is class DataArray.
158
159 The distinction between data and general C++ objects becomes
160 relevant when using such objects in container classes such as
161 DataArray or Array.
162*/
163
164
165/**@page LICENSE License
166 *
167 * \verbinclude LICENSE
168 */
169
170
171/**@page CHANGELOG CHANGELOG
172 *
173 * \verbinclude CHANGELOG
174 */
175
176
177/**@page FAQ Frequently Asked Questions
178 * \htmlinclude faq.inc
179 */
180
181
182/**@page CMD How to use the SoPlex command line
183 *
184 * Running the command line binary of SoPlex without any arguments displays a
185 * list of options. You can write a parameter file with default parameters by
186 * using option \-\-saveset=FILENAME.set. After changing parameter values in this
187 * file you can use it by with \-\-loadset=FILENAME.set. The most frequently used
188 * parameters have abbreviations.
189*/
190
191
192/**@page LIB How to use SoPlex as a callable library
193 *
194 *@section LIB1 Namespace "soplex"
195 *
196 * The entire SoPlex code is contained in the namespace \ref soplex. Because of
197 * this, either all classes and methods must be qualified by the prefix
198 * "soplex::" or a "using namespace soplex;" must be present.
199 *
200 *@section LIB2 Interface class
201 *
202 * The main interface is given by the class \ref soplex::SoPlex "SoPlex", which
203 * handles the construction and modification of an LP, the solving process,
204 * allows to access and change parameters, and retrieve solution information.
205 *
206 * A basic example on how to construct and solve an LP via the class
207 * \ref soplex::SoPlex "SoPlex" is given in the file \ref example.cpp.
208 *
209 *@section LIB3 Deprecated 1.x interface
210 *
211 * With version 2.0, the SoPlex class has been updated significantly compared to
212 * the 1.x version. Since version 4.0, the old version cannot be used anymore.
213*/
214
215
216/**@page PARS Parameters in SoPlex
217 *
218 * Since SoPlex 2.0, the main interface class \ref soplex::SoPlex "SoPlex" provides an improved management of
219 * parameters. Currently, there are three types of parameters for boolean, integer, and real values. A list of default
220 * parameters is provided \ref PARSLIST "here".
221 *
222 *@section PARS1 Setting parameters at the command line
223 *
224 * When using the command line interface, parameters can be changed with the generic option
225 *
226 * <code>\-\-&lt;type&gt;:&lt;name&gt;=&lt;val&gt;</code>
227 *
228 * where &lt;type&gt; is one of <code>bool</code>, <code>int</code>, or <code>real</code> and name is the name of the
229 * parameter. E.g., in order to deactivate the simplifier, one can use the option <code>\-\-bool:simplifier=0</code>.
230 *
231 *@section PARS2 Setting parameters via the callable library
232 *
233 * When using the callable library via the class \ref soplex::SoPlex "SoPlex" (of version 2.0 and above), parameters can
234 * be changed by the methods \ref soplex::SoPlex::setBoolParam() "setBoolParam()", \ref soplex::SoPlex::setIntParam()
235 * "setIntParam()", and \ref soplex::SoPlex::setRealParam() "setRealParam()". See their documentation for details.
236 */
237
238
239/**@page PARSLIST List of all SoPlex parameters
240 *
241 * This page lists all parameters of the current SoPlex version. This list can
242 * easily be generated by the SoPlex command line interface using:
243 *
244 * <code>soplex \-\-saveset=&lt;file name&gt;.set</code>
245 *
246 * or via the method \ref soplex::SoPlex::saveSettingsFile() "saveSettingsFile(&quot;&lt;file name&gt;.set&quot;, true)" of the class \ref
247 * soplex::SoPlex "SoPlex".
248 *
249 * \verbinclude doc/parameters.set
250 */
251
252
253/**@page PROG Programming with SoPlex
254 *
255 * Besides the main interface class \ref soplex::SoPlex "SoPlex", the classes of
256 * the SoPlex library are categorized into three different types:
257 *
258 * - Elementary classes are provided for general purpose use in projects way
259 * beyond the scope of numerical software or linear programming.
260 *
261 * - Linear algebra classes provide basic data types for (sparse) linear algebra
262 * computations. However, their functionality is restricted to simple
263 * operations such as addition and scaling. For complex tasks, such as
264 * solving linear systems of equations, algorithmic classes are provided
265 * instead.
266 *
267 * - Algorithmic classes serve for implementing maybe a variety of algorithms
268 * for solving numerical (sub-)problems.
269 *
270 * The main class implementing the primal and dual simplex algorithm is the
271 * class \ref soplex::SPxSolver "SPxSolver". The following sections are
272 * dedicated to users who want to provide own components of the simplex
273 * algorithm such as pricers, ratio tests, start basis generators or LP
274 * simplifiers to use with SoPlex's standard floating-point simplex
275 * implementation.
276 *
277 *@section Representation Virtualizing the Representation
278 *
279 * The primal Simplex on the columnwise representation is structurally
280 * equivalent to the dual Simplex on the rowwise representation and vice versa
281 * (see below). Hence, it is desirable to treat both cases in a very similar
282 * manner. This is supported by the programmer's interface of SoPlex which
283 * provides access methods for all internal data in two ways: one is relative to
284 * the "physical" representation of the LP in rows and columns, while the other
285 * is relative to the chosen basis representation.
286 *
287 * If e.g. a \ref soplex::SPxPricer "SPxPricer" is written using the second type
288 * of methods only (which will generally be the case), the same code can be used
289 * for running SoPlex's simplex algorithm for both representations. We will now
290 * give two examples for this abstraction from the chosen representation.
291 *
292 * Methods \c vector() will return a column or a row vector, corresponding to
293 * the chosen basis representation. The other "vectors" will be referred to as
294 * \em covectors:
295 *
296 * <TABLE>
297 * <TR><TD>&nbsp; </TD><TD>ROW </TD><TD>COLUMN </TD></TR>
298 * <TR><TD>vector </TD><TD>rowVector</TD><TD>colVector</TD></TR>
299 * <TR><TD>coVector</TD><TD>colVector</TD><TD>rowVector</TD></TR>
300 * </TABLE>
301 *
302 * Whether the \ref soplex::SPxBasisBase::Desc::Status "SPxBasisBase::Desc::Status" of a
303 * variable indicates that the corresponding vector is in the basis matrix or
304 * not also depends on the chosen representation. Hence, methods \c isBasic()
305 * are provided to get the correct answer for both representations.
306 *
307 *@section Simplex Vectors and Bounds
308 *
309 * The Simplex algorithms keeps three vectors which are associated to each
310 * basis. Two of them are required for the pricing, while the third one is
311 * needed for detecting feasibility of the basis. For all three vectors, bounds
312 * are defined. The Simplex algorithm changes the basis until all three vectors
313 * satisfy their bounds, which means that the optimal solution has been found.
314 *
315 * With each update of the basis, also the three vectors need to be
316 * updated. This is best supported by the use of \c UpdateVectors.
317 *
318 *@subsection Variables
319 *
320 * The Simplex algorithm works with two types of variables, primals and duals.
321 * The primal variables are associated with each column of an LP, whereas the
322 * dual variables are associated with each row. However, for each row a slack
323 * variable must be added to the set of primals (to represent inequalities), and
324 * a reduced cost variable must be added for each column (to represent upper or
325 * lower bounds). Note, that mathematically, one dual variable for each bound
326 * (upper and lower) should be added. However, this variable would always yield
327 * the same value and can, hence, be implemented as one.
328 *
329 * To summarize, we have a primal variable for each LP column and row (i.e., its
330 * slack) as well as a dual variable for each LP row and column (i.e., its
331 * bounds). However, not all these values need to be stored and computed, since
332 * the structure of the Simplex algorithms allow to keep them implicitly.
333 *
334 * If the SPxBasis's Status of a row or column is one of \c P_ON_LOWER, \c
335 * P_ON_UPPER, \c P_FIXED or \c P_FREE, the value of the corresponding primal
336 * variable is the lower, upper or both bound(s) or 0, respectively. The
337 * corresponding dual variable needs to be computed. Equivalently, for a Status
338 * of \c D_FREE, \c D_ON_UPPER, \c D_ON_LOWER, \c D_ON_BOTH or \c D_UNDEFINED,
339 * the corresponding dual variable is 0, whereas the primal one needs to be
340 * computed.
341 *
342 * The following vectors are declared for holding the values to be computed: \c
343 * primRhs, \c primVec (with dimension \c nCols()) for the primal variables, and
344 * \c dualRhs, \c dualVec (with dimension \c nRows()) for the dual
345 * variables. The additional variable \c addvec (with dimension \c coDim())
346 * depends on the representation.
347 *
348 * @subsection Bounds
349 *
350 * Primal and dual variables are bounded (including \f$\pm\infty\f$ as bounds).
351 * If all primal variables are within their bounds, the Simplex basis is said to
352 * be primal feasible. Analogously, if all dual variables are within their
353 * bounds, its is called dual feasible. If a basis is both, primal and dual
354 * feasible, the optimal solution has been found.
355 *
356 * In the dual Simplex, the basis is maintained dual feasible, while primal
357 * feasibility is improved via basis updates. However, for numerical reasons
358 * dual feasibility must be relaxed from time to time. Equivalently, primal
359 * feasibility will be relaxed to retain numerical stability in the primal
360 * Simplex algorithm.
361 *
362 * Relaxation of (dual or primal) feasibility is achieved by relaxing the bounds
363 * of primal or dual variables. However, for each type of Simplex only the
364 * corresponding bounds need to be relaxed. Hence, we define only one vector of
365 * upper and lower bound for each row and column and initialize it with primal
366 * or dual bound, depending on the Simplex type (see \c theURbound, \c
367 * theLRbound, \c theUCbound, \c theLCbound).
368 */
369
370
371/**@page EXACT How to use SoPlex as an exact LP solver
372 *
373 * Since version 1.7, SoPlex implements an \em iterative \em refinement procedure on the level of linear programs, which
374 * allows for computing extended-precision solutions beyond the limits of standard floating-point arithmetic. It may be
375 * particularly helpful for numerically troublesome LPs and applications that require solutions within tight feasibility
376 * tolerances. Since version 2.1 this has been extended to compute exact rational solutions. Since version 7.0, SoPlex
377 * can also use \em incremental precision boosting \em to compute exact rational solutions. By default, SoPlex uses
378 * a combination of an out iterative refinement loop, with precision boosting as a fallback incase of numerical problems.
379 *
380 * By default, SoPlex functions as a standard floating-point LP solver. In order to use SoPlex as an exact LP solver,
381 * you need to compile SoPlex with GMP support (default, see the \ref INSTALL "INSTALL" file) and change the following
382 * parameters from their default value:
383 *
384 * - <code>real:feastol = 0</code>
385 *
386 * - <code>real:opttol = 0</code>
387 *
388 * - <code>int:solvemode = 2</code>
389 *
390 * - <code>int:syncmode = 1</code>
391 *
392 * - <code>int:readmode = 1</code> (optional, activates exact parsing of input files)
393 *
394 * - <code>int:checkmode = 2</code> (optional, activates exact final check of feasibility and optimality at the command
395 * line)
396 *
397 * See \ref PARS "this page" how to change parameters and the \ref PARSLIST "list of all SoPlex parameters" for their
398 * detailed description. A settings file <code>exact.set</code> for exact solving is provided in the directory
399 * <code>settings</code> of the distribution. On the command line, this can be read with option
400 * <code>\-\-loadset=settings/exact.set</code>.
401 *
402 * If you have questions on particularly this feature you can contact <a href="http://www.zib.de/gleixner/">Ambros
403 * Gleixner</a> or post them on the <a href="https://listserv.zib.de/mailman/listinfo/soplex/">SoPlex mailing list</a>.
404 *
405 *
406 *@section EXACT4 References
407 *
408 * The mathematical background of the underlying methods is described in the papers
409 *
410 * - Ambros M. Gleixner, Daniel E. Steffy. <i>Linear programming using limited-precision oracles</i>.
411 * Mathematical Pogramming. 183, pp. 525-554, 2020, available as <a
412 * href="http://nbn-resolving.de/urn:nbn:de:0297-zib-75316">ZIB-Report 19-57</a>.
413 *
414 * - Ambros M. Gleixner, Daniel E. Steffy, Kati Wolter. <i>Iterative Refinement for Linear Programming</i>.
415 * INFORMS Journal on Computing 28 (3). pp. 449-464, available as <a href="http://nbn-resolving.de/urn/resolver.pl?urn:nbn:de:0297-zib-55118">ZIB-Report 15-15</a>.
416 *
417 * <b>When using SoPlex as an exact LP solver, please cite the above papers.</b>
418 */