Austin Schuh | 405fa6c | 2015-09-06 18:13:55 -0700 | [diff] [blame^] | 1 | % The name of this file: cddlibman.tex |
| 2 | % written by by Komei Fukuda |
| 3 | % created March 15, 1999 |
| 4 | % modified February 7, 2008 |
| 5 | % |
| 6 | \documentclass[11pt]{article} |
| 7 | \usepackage{html,amsmath,amssymb} |
| 8 | \renewcommand{\baselinestretch}{1} |
| 9 | \renewcommand{\arraystretch}{1} |
| 10 | \setlength{\oddsidemargin}{0mm} |
| 11 | \setlength{\textwidth}{165mm} |
| 12 | \setlength{\topmargin}{-15mm} |
| 13 | \setlength{\textheight}{232mm} |
| 14 | %\setlength{\headsep}{0in} |
| 15 | %\setlength{\headheight}{0pt} |
| 16 | \pagestyle{plain} |
| 17 | |
| 18 | \newcommand {\0} {{\bf 0}} |
| 19 | \newcommand{\R}{{\Bbb R}} |
| 20 | |
| 21 | \begin{document} |
| 22 | \title{cddlib Reference Manual} |
| 23 | \author{Komei Fukuda\\ |
| 24 | Institute for Operations Research\\ |
| 25 | and Institute of Theoretical Computer Science\\ |
| 26 | ETH Zentrum, CH-8092 Zurich, Switzerland\\ |
| 27 | } |
| 28 | \date{ (cddlib ver. 0.94, manual ver. February 7, 2008)} |
| 29 | |
| 30 | \maketitle |
| 31 | |
| 32 | \tableofcontents |
| 33 | |
| 34 | \begin{abstract} |
| 35 | This is a reference manual for cddlib-094. |
| 36 | The manual describes the library functions and data types implemented |
| 37 | in the cddlib C-library which is to perform fundamental polyhedral |
| 38 | computations such as representation conversions and linear programming |
| 39 | in both floating-point and GMP rational exact arithmetic. |
| 40 | Please read the accompanying README file and test programs to |
| 41 | complement the manual. |
| 42 | |
| 43 | The new functions added in this version include {\tt dd\_MatrixCanonicalize} |
| 44 | to find a non-redundant proper H- or V-representation, |
| 45 | {\tt dd\_FindRelativeInterior} to find a relative interior point |
| 46 | of an H-polyhedron, and {\tt dd\_ExistsRestrictedFace} (Farkas-type |
| 47 | alternative theorem verifier) |
| 48 | to check the existence of a point satisfying a specified system |
| 49 | of linear inequalities possibly including multiple strict inequalities. |
| 50 | |
| 51 | The new functions are particularly important for the development of |
| 52 | related software packages MinkSum (by Ch. Weibel) and Gfan |
| 53 | (by Anders Jensen), |
| 54 | |
| 55 | \end{abstract} |
| 56 | |
| 57 | \section{Introduction} \label{INTRODUCTION} |
| 58 | |
| 59 | The program cddlib is an efficient implementation \cite{fp-ddmr-96} of |
| 60 | the double description Method~\cite{mrtt-ddm-53} |
| 61 | for generating all vertices (i.e. extreme points) |
| 62 | and extreme rays of a general |
| 63 | convex polyhedron given by |
| 64 | a system of linear inequalities: |
| 65 | \[ |
| 66 | P = \{ x=(x_1, x_2, \ldots, x_d)^T \in R^{d}: b - A x \ge 0 \} |
| 67 | \] |
| 68 | where $A$ is a given $m \times d$ real matrix and |
| 69 | $b$ is a given real $m$-vector. In the mathematical |
| 70 | language, the computation is the transformation |
| 71 | of an {\em H-representation\/} of a convex polytope |
| 72 | to an {\em V-representation}. |
| 73 | |
| 74 | cddlib is a C-library version of the previously released C-code cdd/cdd+. |
| 75 | In order to make this library version, a large part of the cdd source |
| 76 | (Version 0.61) has been rewritten. |
| 77 | This library version is more flexible since it can be called from other programs in C/C++. |
| 78 | Unlike cdd/cdd+, cddlib can handle any general input and is more general. |
| 79 | Furtthermore, additional functions have been written to extend its functionality. |
| 80 | |
| 81 | One useful feature of cddlib/cdd/cdd+ is its capability |
| 82 | of handling the dual (reverse) problem without any transformation |
| 83 | of data. The dual transformation problem of a V-representation |
| 84 | to a minimal H-representation and is often called the |
| 85 | {\em (convex) hull problem\/}. More explicitly, |
| 86 | is to obtain a linear inequality representation |
| 87 | of a convex polyhedron given as the Minkowski sum of |
| 88 | the convex hull of a finite set of points and the nonnegative |
| 89 | hull of a finite set of points in $R^{d}$: |
| 90 | \[ |
| 91 | P = conv(v_1,\ldots,v_n) + nonneg(r_{n+1},\ldots,r_{n+s}), |
| 92 | \] |
| 93 | where |
| 94 | the {\em Minkowski sum of two subsets $S$ and $T$} of $R^{d}$ is defined |
| 95 | as |
| 96 | \[ |
| 97 | S + T = \{ s + t \; | s \in S \mbox{ and } t \in T \}. |
| 98 | \] |
| 99 | As we see in this manual, the computation can be done |
| 100 | in straightforward manner. Unlike the earlier versions of |
| 101 | cdd/cdd+ that assume certain regularity conditions for input, |
| 102 | cddlib is designed to do a correct transformation for any general input. |
| 103 | The user must be aware of the fact that in certain cases the |
| 104 | transformation is not unique and there are polyhedra with |
| 105 | infinitely many representations. For example, a line |
| 106 | segment (1-dimensional polytope) in $R^3$ has infinitely |
| 107 | many minimal H-representations, and a halfspace in the same space |
| 108 | has infinitely many minimal V-representations. cddlib generates |
| 109 | merely one minimal representation. |
| 110 | |
| 111 | cddlib comes with an LP code to solve the general |
| 112 | linear programming (LP) problem to maximize (or minimize) a linear |
| 113 | function over polyhedron $P$. It is useful mainly for solving |
| 114 | dense LP's with large $m$ (say, up to few hundred thousands) and small $d$ |
| 115 | (say, up to 100). It implements a revised dual simplex method that |
| 116 | updates $(d+1)\times (d+1)$ matrix for a pivot operation. |
| 117 | |
| 118 | The program cddlib has an I/O routines that read and write files in |
| 119 | {\em Polyhedra format\/} which was defined by David Avis and |
| 120 | the author in 1993, and has been updated in 1997 and 1999. |
| 121 | The program called lrs and lrslib \cite{a-lrshome-01} developed by David Avis is |
| 122 | a C-implementation of the reverse search algorithm~\cite{af-pachv-92} |
| 123 | for the same enumeration purpose, and it conforms to Polyhedra format as well. |
| 124 | Hopefully, this compatibility of the two programs |
| 125 | enables users to use both programs for the same input files |
| 126 | and to choose whichever is useful for their purposes. |
| 127 | From our experiences with relatively large problems, |
| 128 | the two methods are both useful and perhaps complementary |
| 129 | to each other. In general, the program cddlib tends to be |
| 130 | efficient for highly degenerate inputs and the program rs |
| 131 | tends to be efficient for nondegenerate or slightly |
| 132 | degenerate problems. |
| 133 | |
| 134 | Although the program can be used for nondegenerate inputs, |
| 135 | it might not be very efficient. For nondegenerate inputs, |
| 136 | other available programs, such as the reverse search code lrs or |
| 137 | qhull (developed by the Geometry Center), |
| 138 | might be more efficient. See Section~\ref{CODES} |
| 139 | for pointers to these codes. |
| 140 | The paper \cite{abs-hgach-97} contains many interesting results on polyhedral |
| 141 | computation and experimental results on cdd+, lrs, qhull and porta. |
| 142 | |
| 143 | This program can be distributed freely under the GNU GENERAL PUBLIC LICENSE. |
| 144 | Please read the file COPYING carefully before using. |
| 145 | |
| 146 | I will not take any responsibility of any problems you might have |
| 147 | with this program. But I will be glad to receive bug reports or suggestions |
| 148 | at the e-mail addresses above. If cddlib turns out to be useful, |
| 149 | please kindly inform me of what purposes cdd has been used for. |
| 150 | I will be happy to include a list of applications in future |
| 151 | distribution if I receive enough replies. |
| 152 | The most powerful support for free software development |
| 153 | is user's appreciation and collaboration. |
| 154 | |
| 155 | \section{Polyhedra H- and V-Formats (Version 1999)} \label{FORMAT} |
| 156 | \bigskip |
| 157 | Every convex polyhedron has two representations, one as |
| 158 | the intersection of finite halfspaces and the other |
| 159 | as Minkowski sum of the convex hull of finite points |
| 160 | and the nonnegative hull of finite directions. These are |
| 161 | called H-representation and V-representation, respectively. |
| 162 | |
| 163 | Naturally there are two basic Polyhedra formats, |
| 164 | H-format for H-representation and V-format for |
| 165 | V-representation. These two formats are designed |
| 166 | to be almost indistinguishable, and in fact, one can |
| 167 | almost pretend one for the other. There is some asymmetry |
| 168 | arising from the asymmetry of two representations. |
| 169 | |
| 170 | First we start with the H-representation. |
| 171 | Let $A$ be an $m \times d$ matrix, and let $b$ be a column $m$-vector. |
| 172 | The Polyhedra format ({\em H-format} ) of |
| 173 | the system $\; b - A x \ge \0\;$ of $m$ inequalities in $d$ variables |
| 174 | $x =(x_1, x_2, \ldots, x_d)^T$ is |
| 175 | |
| 176 | \begin{tabular}{ccl} |
| 177 | \\ \hline |
| 178 | \multicolumn{3}{l} {various comments}\\ |
| 179 | \multicolumn{3}{l} {{\bf H-representation}}\\ |
| 180 | \multicolumn{3}{l} {{\bf (linearity $t\;$ $i_1\;$ $i_2\;$ $\ldots$ $\;i_t$)}}\\ |
| 181 | \multicolumn{3}{l} {{\bf begin}}\\ |
| 182 | $m$ & $d+1$ & numbertype\\ |
| 183 | $b$ & $-A$ \\ |
| 184 | \multicolumn{3}{l} {{\bf end}}\\ |
| 185 | \multicolumn{3}{l} {various options} \\ \hline |
| 186 | \end{tabular} |
| 187 | |
| 188 | \bigskip |
| 189 | \noindent |
| 190 | where numbertype can be one of integer, rational or real. |
| 191 | When rational type is selected, each component |
| 192 | of $b$ and $A$ can be specified by the usual integer expression |
| 193 | or by the rational expression ``$p / q$'' or ``$-p / q$'' where |
| 194 | $p$ and $q$ are arbitrary long positive integers (see the example |
| 195 | input file rational.ine). In the 1997 format, |
| 196 | we introduced ``H-representation'' which must appear |
| 197 | before ``begin''. |
| 198 | There was one restriction in the old polyhedra format |
| 199 | (before 1997): the last $d$ rows must determine |
| 200 | a vertex of $P$. This is obsolete now. |
| 201 | |
| 202 | In the new 1999 format, we added the possibility of specifying {\bf linearity\/}. |
| 203 | This means that |
| 204 | for H-representation, some of the input rows can be specified as {\bf equalities}: |
| 205 | $b_{i_j} - A_{i_j} x = 0 \;$ for all $j=1,2, \ldots, t$. |
| 206 | The linearity line may be omitted if there are no equalities. |
| 207 | |
| 208 | Option lines can be used to control computation of a specific program. |
| 209 | In particular both cdd and lrs use the option lines to represent |
| 210 | a linear objective function. See the attached LP files, samplelp*.ine. |
| 211 | |
| 212 | \bigskip |
| 213 | Next we define Polyhedra {\em V-format}. Let $P$ be |
| 214 | represented by $n$ gerating points and $s$ generating directions (rays) as |
| 215 | $P = conv(v_1,\ldots,v_n) + nonneg(r_{n+1},\ldots,r_{n+s})$. |
| 216 | Then the Polyhedra V-format for $P$ is |
| 217 | |
| 218 | \begin{tabular}{cll} |
| 219 | \\ \hline |
| 220 | \multicolumn{3}{l} {various comments}\\ |
| 221 | \multicolumn{3}{l} {{\bf V-representation}}\\ |
| 222 | \multicolumn{3}{l} {({\bf linearity $t\;$ $i_1\;$ $i_2\;$ $\ldots$ $\;i_t$ })}\\ |
| 223 | \multicolumn{3}{l} {{\bf begin}}\\ |
| 224 | $n+s$ & $d+1$ & numbertype\\ |
| 225 | $1$ & $v_1$ & \\ |
| 226 | $\vdots$ & $\vdots$ & \\ |
| 227 | $1$ & $v_n$ & \\ |
| 228 | $0$ & $r_{n+1}$ & \\ |
| 229 | $\vdots$ & $\vdots$ & \\ |
| 230 | $0$ & $r_{n+s}$ & \\ |
| 231 | \multicolumn{3}{l} {{\bf end}}\\ |
| 232 | \multicolumn{3}{l} {various options} \\ \hline |
| 233 | \end{tabular} |
| 234 | |
| 235 | \bigskip |
| 236 | \noindent |
| 237 | Here we do not require that |
| 238 | vertices and rays are listed |
| 239 | separately; they can appear mixed in arbitrary |
| 240 | order. |
| 241 | |
| 242 | Linearity for V-representation specifies a subset of generators |
| 243 | whose coefficients are relaxed |
| 244 | to be {\bf free}: for all $j=1,2, \ldots, t$, the $k=i_j$th generator ($v_{k}$ or $r_k$ whichever is the $i_j$th generator) is a free generator. |
| 245 | This means for each such a ray $r_k$, |
| 246 | the line generated by $r_k$ is in the polyhedron, |
| 247 | and for each such a vertex $v_k$, its coefficient is no longer nonnegative |
| 248 | but still the coefficients for all $v_i$'s must sum up to one. |
| 249 | It is highly unlikely that one needs to |
| 250 | use linearity for vertex generators, and it is defined mostly |
| 251 | for formality. |
| 252 | |
| 253 | When the representation statement, either ``H-representation'' |
| 254 | or ``V-representation'', is omitted, the former |
| 255 | ``H-representation'' is assumed. |
| 256 | |
| 257 | It is strongly suggested to use the following rule for naming |
| 258 | H-format files and V-format files: |
| 259 | \begin{description} |
| 260 | \item[(a)] use the filename extension ``.ine'' for H-files (where ine stands for inequalities), and |
| 261 | \item[(b)] use the filename extension ``.ext'' for V-files (where ext stands for extreme points/rays). |
| 262 | \end{description} |
| 263 | |
| 264 | |
| 265 | \section{Basic Object Types (Structures) in cddlib} \label{DATASTR} |
| 266 | |
| 267 | Here are the types (defined in cddtypes.h) that are |
| 268 | important for the cddlib user. The most important one, |
| 269 | {\tt dd\_MatrixType}, |
| 270 | is to store a Polyhedra data in a straightforward manner. |
| 271 | Once the user sets up a (pointer to) {\tt dd\_MatrixType} data, |
| 272 | he/she can load the data to an internal data type ({\tt dd\_PolyhedraType}) |
| 273 | by using functions described in the next section, and apply |
| 274 | the double descrition method to get another representation. |
| 275 | As an option {\tt dd\_MatrixType} can save a linear objective function |
| 276 | to be used by a linear programming solver. |
| 277 | |
| 278 | The two dimensional array data in the structure {\tt dd\_MatrixType} is |
| 279 | {\tt dd\_Amatrix} whose components are of type {\tt mytype\/}. |
| 280 | The type mytype is set to be either the rational type {\tt mpq\_t} of |
| 281 | the GNU MP Library or the C double array of size $1$. |
| 282 | This abstract type allows us to write a single program that can |
| 283 | be compiled with the two or more different arithmetics, see example |
| 284 | programs such as simplecdd.c, testlp*.c and testcdd*.c |
| 285 | in the {\tt src} and {\tt src-gmp} subdirectories of the source |
| 286 | distribution. |
| 287 | |
| 288 | There is another data type that is used very often, {\tt dd\_SetFamilyType}. |
| 289 | This is to store a family of subsets of a finite set. Such a family |
| 290 | can represent the incidence relations between the set of extreme |
| 291 | points and the set of facets of a polyhedron. Also, it can represent a |
| 292 | graph structure by listing the set of vertices adjacent to each vertex (i.e. |
| 293 | the adjacency list). To implement {\tt dd\_SetFamilyType}, |
| 294 | we use a separate set library called {\tt setoper}, that |
| 295 | handles the basic set operations, This library is briefly introduced in |
| 296 | Section~\ref{SetFunctions}. |
| 297 | |
| 298 | |
| 299 | \begin{verbatim} |
| 300 | |
| 301 | #define dd_FALSE 0 |
| 302 | #define dd_TRUE 1 |
| 303 | |
| 304 | typedef long dd_rowrange; |
| 305 | typedef long dd_colrange; |
| 306 | typedef long dd_bigrange; |
| 307 | |
| 308 | typedef set_type dd_rowset; /* set_type defined in setoper.h */ |
| 309 | typedef set_type dd_colset; |
| 310 | typedef long *dd_rowindex; |
| 311 | typedef int *dd_rowflag; |
| 312 | typedef long *dd_colindex; |
| 313 | typedef mytype **dd_Amatrix; /* mytype is either GMP mpq_t or 1-dim double array. */ |
| 314 | typedef mytype *dd_Arow; |
| 315 | typedef set_type *dd_SetVector; |
| 316 | |
| 317 | typedef enum { |
| 318 | dd_Real, dd_Rational, dd_Integer, dd_Unknown |
| 319 | } dd_NumberType; |
| 320 | |
| 321 | typedef enum { |
| 322 | dd_Inequality, dd_Generator, dd_Unspecified |
| 323 | } dd_RepresentationType; |
| 324 | |
| 325 | typedef enum { |
| 326 | dd_MaxIndex, dd_MinIndex, dd_MinCutoff, dd_MaxCutoff, dd_MixCutoff, |
| 327 | dd_LexMin, dd_LexMax, dd_RandomRow |
| 328 | } dd_RowOrderType; |
| 329 | |
| 330 | typedef enum { |
| 331 | dd_InProgress, dd_AllFound, dd_RegionEmpty |
| 332 | } dd_CompStatusType; |
| 333 | |
| 334 | typedef enum { |
| 335 | dd_DimensionTooLarge, dd_ImproperInputFormat, |
| 336 | dd_NegativeMatrixSize, dd_EmptyVrepresentation, |
| 337 | dd_IFileNotFound, dd_OFileNotOpen, dd_NoLPObjective, |
| 338 | dd_NoRealNumberSupport, dd_NoError |
| 339 | } dd_ErrorType; |
| 340 | |
| 341 | typedef enum { |
| 342 | dd_LPnone=0, dd_LPmax, dd_LPmin |
| 343 | } dd_LPObjectiveType; |
| 344 | |
| 345 | typedef enum { |
| 346 | dd_LPSundecided, dd_Optimal, dd_Inconsistent, dd_DualInconsistent, |
| 347 | dd_StrucInconsistent, dd_StrucDualInconsistent, |
| 348 | dd_Unbounded, dd_DualUnbounded |
| 349 | } dd_LPStatusType; |
| 350 | |
| 351 | typedef struct matrixdata *dd_MatrixPtr; |
| 352 | typedef struct matrixdata { |
| 353 | dd_rowrange rowsize; |
| 354 | dd_rowset linset; |
| 355 | /* a subset of rows of linearity (ie, generators of |
| 356 | linearity space for V-representation, and equations |
| 357 | for H-representation. */ |
| 358 | dd_colrange colsize; |
| 359 | dd_RepresentationType representation; |
| 360 | dd_NumberType numbtype; |
| 361 | dd_Amatrix matrix; |
| 362 | dd_LPObjectiveType objective; |
| 363 | dd_Arow rowvec; |
| 364 | } dd_MatrixType; |
| 365 | |
| 366 | typedef struct setfamily *dd_SetFamilyPtr; |
| 367 | typedef struct setfamily { |
| 368 | dd_bigrange famsize; |
| 369 | dd_bigrange setsize; |
| 370 | dd_SetVector set; |
| 371 | } dd_SetFamilyType; |
| 372 | |
| 373 | typedef struct lpsolution *dd_LPSolutionPtr; |
| 374 | typedef struct lpsolution { |
| 375 | dd_DataFileType filename; |
| 376 | dd_LPObjectiveType objective; |
| 377 | dd_LPSolverType solver; |
| 378 | dd_rowrange m; |
| 379 | dd_colrange d; |
| 380 | dd_NumberType numbtype; |
| 381 | |
| 382 | dd_LPStatusType LPS; /* the current solution status */ |
| 383 | mytype optvalue; /* optimal value */ |
| 384 | dd_Arow sol; /* primal solution */ |
| 385 | dd_Arow dsol; /* dual solution */ |
| 386 | dd_colindex nbindex; /* current basis represented by nonbasic indices */ |
| 387 | dd_rowrange re; /* row index as a certificate in the case of inconsistency */ |
| 388 | dd_colrange se; /* col index as a certificate in the case of dual inconsistency */ |
| 389 | long pivots[5]; |
| 390 | /* pivots[0]=setup (to find a basis), pivots[1]=PhaseI or Criss-Cross, |
| 391 | pivots[2]=Phase II, pivots[3]=Anticycling, pivots[4]=GMP postopt */ |
| 392 | long total_pivots; |
| 393 | } dd_LPSolutionType; |
| 394 | |
| 395 | \end{verbatim} |
| 396 | |
| 397 | \section{Library Functions} \label{LIBRARY} |
| 398 | |
| 399 | Here we list some of the most important library functions/procedures. |
| 400 | We use the following convention: |
| 401 | {\tt poly} is of type {\tt dd\_PolyhedraPtr}, |
| 402 | {\tt matrix}, {\tt matrix1} and {\tt matrix2} are of type {\tt dd\_MatrixPtr}, |
| 403 | {\tt matrixP}, of type {\tt dd\_MatrixPtr*}, |
| 404 | {\tt err} is of type {\tt dd\_ErrorType*}, |
| 405 | {\tt ifile} and {\tt ofile} are of type {\tt char*}, |
| 406 | {\tt A} is of type {\tt dd\_Amatrix}, |
| 407 | {\tt point} and {\tt vector} are of type {\tt dd\_Arow}, |
| 408 | {\tt d} is of type {\tt dd\_colrange}, |
| 409 | {\tt m} and {\tt i} are of type {\tt dd\_rowrange}, |
| 410 | {\tt x} is of type {\tt mytype}, |
| 411 | {\tt a} is of type {\tt signed long integer}, |
| 412 | {\tt b} is of type {\tt double}, |
| 413 | {\tt set} is of type {\tt set\_type}. |
| 414 | Also, |
| 415 | {\tt setfam} is of type {\tt dd\_SetFamilyPtr}, |
| 416 | {\tt lp} is of type {\tt dd\_LPPtr}, |
| 417 | {\tt lps} is of type {\tt dd\_LPSolutionPtr}, |
| 418 | {\tt solver} is of type {\tt dd\_LPSolverType}, |
| 419 | {\tt roworder} is of type {\tt dd\_RowOrderType}. |
| 420 | |
| 421 | |
| 422 | \subsection{Library Initialization} \label{Initialization} |
| 423 | |
| 424 | \begin{description} |
| 425 | |
| 426 | \item[{\tt void dd\_set\_global\_constants(void)}]:\\ |
| 427 | This is to set the global constants such as {\tt dd\_zero}, |
| 428 | {\tt dd\_purezero} and |
| 429 | {\tt dd\_one} for sign recognition and basic arithmetic |
| 430 | operations. {Every program to use cddlib must call this function} |
| 431 | before doing any computation. Just call this once. |
| 432 | See Section \ref{constants} for the definitions of |
| 433 | constants. |
| 434 | |
| 435 | \item[{\tt void dd\_free\_global\_constants(void)}]:\\ |
| 436 | This is to free the global constants. This should be called |
| 437 | when one does not use cddlib functions anymore. |
| 438 | \end{description} |
| 439 | |
| 440 | \subsection{Core Functions} \label{CoreLibrary} |
| 441 | |
| 442 | There are two types of core functions in cddlib. The first type |
| 443 | runs the double description (DD) algorithm and does a representation |
| 444 | conversion of a specified polyhedron. The standard header |
| 445 | for this type is {\tt dd\_DD*}. The second type solves |
| 446 | one or more linear programs with no special headers. |
| 447 | Both types of computations are nontrivial |
| 448 | and the users (especially for the DD algorithm) must |
| 449 | know that there is a serous limit in the sizes of problems |
| 450 | that can be practically solved. |
| 451 | Please check *.ext and *.ine files that come with cddlib to get |
| 452 | ideas of tractable problems. |
| 453 | |
| 454 | In addition to previously defined objects, the symbol {\tt roworder} is |
| 455 | of {\tt dd\_RowOrderType}. The symbol {\tt matrixP} is |
| 456 | a pointer to {\bf dd\_MatrixType}. |
| 457 | the arguments {\tt impl\_lin} and {\tt redset} are both a pointer |
| 458 | to {\tt dd\_rowset} type, and {\tt newpos} is a pointer to |
| 459 | {\tt dd\_rowindex} type. |
| 460 | |
| 461 | |
| 462 | \begin{description} |
| 463 | \item[{\tt dd\_PolyhedraPtr dd\_DDMatrix2Poly(matrix, err)}]:\\ |
| 464 | Store the representation given by {\tt matrix} in a polyhedra data, and |
| 465 | generate the second representation of {\tt *poly}. It returns |
| 466 | a pointer to the data. {\tt *err} |
| 467 | returns {\tt dd\_NoError} if the computation terminates normally. Otherwise, |
| 468 | it returns a value according to the error occured. |
| 469 | |
| 470 | \item[{\tt dd\_PolyhedraPtr dd\_DDMatrix2Poly2(matrix, roworder, err)}]:\\ |
| 471 | This is the same function as {\tt dd\_DDMatrix2Poly} except that the insertion |
| 472 | order is specified by the user. The argument {\tt roworder} is of {\tt dd\_RowOrderType} |
| 473 | and takes one of the values: |
| 474 | {\tt dd\_MaxIndex}, {\tt dd\_MinIndex}, {\tt dd\_MinCutoff}, {\tt dd\_MaxCutoff}, {\tt dd\_MixCutoff}, |
| 475 | {\tt dd\_LexMin}, {\tt dd\_LexMax}, {\tt dd\_RandomRow}. In general, {\tt dd\_LexMin} is |
| 476 | the best choice which is in fact chosen in {\tt dd\_DDMatrix2Poly}. If you know that |
| 477 | the input is already sorted in the order you like, use {\tt dd\_MinIndex} or {\tt dd\_MaxIndex}. |
| 478 | If the input contains many redundant rows (say more than $80\%$ redundant), |
| 479 | you might want to try {\tt dd\_MaxCutoff} which might result in much faster termination, |
| 480 | see \cite{abs-hgach-97,fp-ddmr-96} |
| 481 | |
| 482 | \item[{\tt boolean dd\_DDInputAppend(poly, matrix, err)}]:\\ |
| 483 | Modify the input representation in {\tt *poly} |
| 484 | by appending the matrix of {\tt *matrix}, and compute |
| 485 | the second representation. The number of columns in |
| 486 | {\tt *matrix} must be equal to the input representation. |
| 487 | |
| 488 | \item[{\tt boolean dd\_LPSolve(lp, solver, err)}]:\\ |
| 489 | Solve {\tt lp} by the algorithm {\tt solver} and save |
| 490 | the solututions in {\tt *lp}. Unlike the earlier versions |
| 491 | (dplex, cdd+), it can deal with equations and totally zero right |
| 492 | hand sides. It is recommended that {\tt solver} is |
| 493 | {\tt dd\_DualSimplex}, the revised dual simplex method |
| 494 | that updates a $d\times d$ dual basis matrix in each pivot (where |
| 495 | $d$ is the column size of lp). |
| 496 | |
| 497 | The revised dual simplex method is ideal for dense LPs in small number of variables |
| 498 | (i.e. small column size, typically less than $100$) |
| 499 | and many inequality constraints (i.e. large row size, can be a few ten thousands). |
| 500 | If your LP has many variables but only few constraints, solve the dual LP by |
| 501 | this function. |
| 502 | |
| 503 | When it is compiled for GMP rational |
| 504 | arithmetic, it first tries to solve an LP with C double |
| 505 | floating-point arithmetic and verifies whether the output |
| 506 | basis is correct with GMP. If so, the correct solution is |
| 507 | computed with GMP. Otherwise, it (re)solves the LP |
| 508 | from scratch with GMP. This is newly implemented |
| 509 | in the version 093. The original (non-crossover) version of |
| 510 | the same function is still available as {\tt boolean dd\_LPSolve0}. |
| 511 | |
| 512 | \item[{\tt dd\_boolean dd\_Redundant(matrix, i, point, err)}]:\\ |
| 513 | Check whether $i$th data in {\tt matrix} is redundant for the representation. |
| 514 | If it is nonredundant, it returns a certificate. For H-representation, |
| 515 | it is a {\tt point} in $R^d$ which satisfies |
| 516 | all inequalities except for the $i$th inequality. If $i$ is a linearity, |
| 517 | it does nothing and always returns {\tt dd\_FALSE}. |
| 518 | |
| 519 | \item[{\tt dd\_rowset dd\_RedundantRows(matrix, err)}]:\\ |
| 520 | Returns a maximal set of row indices such that the associated rows |
| 521 | can be eliminated without changing the polyhedron. |
| 522 | The function works for both V- and H-representations. |
| 523 | |
| 524 | \item[{\tt dd\_boolean dd\_SRedundant(matrix, i, point, err)}]:\\ |
| 525 | Check whether $i$th data in {\tt matrix} is strongly redundant for the representation. |
| 526 | If $i$ is a linearity, it does nothing and always returns {\tt dd\_FALSE}. |
| 527 | Here, $i$th inequality in H-representation is {\em strongly redundant\/} if it is redundant |
| 528 | and there is no point in the polyhedron satisfying the inequality with equality. |
| 529 | In V-representation, $i$th point is {\em strongly redundant\/} if it is redundant |
| 530 | and it is in the relative interior of the polyhedron. If it is not strongly redundant, it returns a certificate. |
| 531 | |
| 532 | \item[{\tt dd\_boolean dd\_ImplicitLinearity(matrix, i, err)}]:\\ |
| 533 | Check whether $i$th row |
| 534 | in the input is forced to be linearity (equality |
| 535 | for H-representation). |
| 536 | If $i$ is linearity itself, |
| 537 | it does nothing and always returns {\tt dd\_FALSE}. |
| 538 | |
| 539 | \item[{\tt dd\_rowset dd\_ImplicitLinearityRows(matrix, err)}]:\\ |
| 540 | Returns the set of indices of rows that are |
| 541 | implicitly linearity. It simply calls the library function |
| 542 | {\tt dd\_ImplicitLinearity} for each inequality and collects |
| 543 | the row indices for which the answer is {\tt dd\_TRUE}. |
| 544 | |
| 545 | \item[{\tt dd\_boolean dd\_MatrixCanonicalize(matrixP, impl\_lin, redset, newpos, err)}]:\\ |
| 546 | The input is a pointer {\tt matrixP} to a matrix and the function |
| 547 | modifies the matrix by putting a maximally linear independent linearities (basis) |
| 548 | at the top of the matrix, and removing all redundant data. |
| 549 | All implicit linearities and all (removed) redundant rows |
| 550 | in the original matrix will be returned in the corresponding row sets. |
| 551 | The new positions of the original rows are returned by |
| 552 | the array {\tt newpos}. |
| 553 | |
| 554 | The cardinality of the new linearity set {\tt (*matrixP)->linset} is the codimension |
| 555 | of the polyhedron if it is H-polyhedron, and is the dimension of linearity space |
| 556 | if it is V-polyhedron. |
| 557 | |
| 558 | Note that the present version should not be called a canonicalization |
| 559 | because it may generate two different representations of the same |
| 560 | polyhedron. In the future, this function is expected to be correctly |
| 561 | implemented. |
| 562 | |
| 563 | \item[{\tt dd\_boolean dd\_MatrixCanonicalizeLinearity(matrixP, impl\_linset, newpos. err)}]:\\ |
| 564 | It does only the first half of {\tt dd\_boolean dd\_MatrixCanonicalize}, namely, it detects all |
| 565 | implicit linearities and puts a maximally independent linearities |
| 566 | at the top of the matrix. For example, this function can be |
| 567 | used to detect the dimension of an H-polyhedron. |
| 568 | |
| 569 | \item[{\tt dd\_boolean dd\_MatrixRedundancyRemove(matrixP, redset, newpos, err)}]:\\ |
| 570 | It does essentially the second half of {\tt dd\_boolean dd\_MatrixCanonicalize}, |
| 571 | namely, it detects all |
| 572 | redundancies. This function should be used after {\tt dd\_MatrixCanonicalizeLinearity} |
| 573 | has been called. |
| 574 | |
| 575 | |
| 576 | \item[{\tt dd\_boolean dd\_FindRelativeInterior(matrix, impl\_lin, lin\_basis, lps, err)}]:\\ |
| 577 | Computes a point in the relative interior of an H-polyhedron given by matrix, by solving |
| 578 | an LP. The point will be returned by {\tt lps}. |
| 579 | See the sample program allfaces.c that generates all nonempty faces of an H-polyhedron and |
| 580 | a relative interior point for each face. The former returns all implicit linearity rows (implicit equations) |
| 581 | and the latter returns a basis of the union of linearity rows and implicit linearity rows. |
| 582 | This means that the cardinality of {\tt *lin\_basis} is the codimension of the polyhedron. |
| 583 | |
| 584 | |
| 585 | \item[{\tt dd\_boolean dd\_ExistsRestrictedFace(matrix, R, S, err)}]:\\ |
| 586 | Returns the answer to the Farkas' type decision problem as to whether there is a point |
| 587 | in the polyhedron given by matrix satisfying all constraints in {\tt R} with |
| 588 | equality and all constraints in {\tt S} with strict inequality. More precisely, |
| 589 | it is the linear feasibility problem: |
| 590 | \[ |
| 591 | \begin{array}{llllll} |
| 592 | \exists\mbox{?} &x &\mbox{ satisfying } & b_r - A_r x &= 0, \; \forall r \in R\cup L \\ |
| 593 | & & & b_s - A_s x &> 0, \; \forall s \in S \\ |
| 594 | & & & b_t - A_t x &\ge 0, \; \forall t \in T, |
| 595 | \end{array} |
| 596 | \] |
| 597 | where $L$ is the set of linearity rows of {\tt matrix}, and $T$ represents |
| 598 | the set of rows that are not in $R\cup L \cup S$. |
| 599 | Both {\tt R} and {\tt S} are of {\tt dd\_rowset} type. The set $S$ is |
| 600 | supposed to be disjoint from both $R$ and $L$. |
| 601 | If it is not the case, the set $S$ will be considered as $S \setminus (R \cup L)$. |
| 602 | |
| 603 | This function ignores {\tt matrix->representation}, and thus even if it is |
| 604 | set to {\tt dd\_Generator} or {\tt dd\_Unspecified}, it treats the matrix |
| 605 | as if it were inequality representation. |
| 606 | |
| 607 | \item[{\tt dd\_boolean dd\_ExistsRestrictedFace2(matrix, R, S, lps, err)}]:\\ |
| 608 | It is the same as the function {\tt dd\_ExistsRestrictedFace} except that |
| 609 | it returns also a certificate for the answer. The certificate is a solution |
| 610 | to the bounded LP: |
| 611 | \[ |
| 612 | \begin{array}{lllllll} |
| 613 | \mbox{(P)} &\max z &\mbox{ subject to } & b_r - A_r x & & = 0, \; \forall r \in R\cup L \\ |
| 614 | & & & b_s - A_s x &-z &\ge 0, \; \forall s \in S \\ |
| 615 | & & & b_t - A_t x & &\ge 0, \; \forall t \in T \\ |
| 616 | & & & 1 & -z&\ge 0, |
| 617 | \end{array} |
| 618 | \] |
| 619 | where $L$ is the set of linearity rows of {\tt matrix}, and $T$ represents |
| 620 | the set of rows that are not in $R\cup L \cup S$. |
| 621 | The answer for the decision problem is YES if and only if the LP attains |
| 622 | an optimal and the optimal value is positive. The dual solution (either |
| 623 | an optimal solution or a dual unbounded direction) can be considered |
| 624 | as a certificate for the NO answer, if the answer is NO. |
| 625 | |
| 626 | This function ignores {\tt matrix->representation}, and thus even if it is |
| 627 | set to {\tt dd\_Generator} or {\tt dd\_Unspecified}, it treats the matrix |
| 628 | as if it were inequality representation. |
| 629 | |
| 630 | \item[{\tt dd\_SetFamilyPtr dd\_Matrix2Adjacency(matrix, err)}]:\\ |
| 631 | Computes the adjacency list of input rows using |
| 632 | the LP solver and without running the representation conversion. When |
| 633 | the input is H-representation, it gives the facet graph of the polyhedron. |
| 634 | For V-representation, it gives the (vertex) graph of the polyhedron. |
| 635 | It is required that the input matrix is a minimal representation. |
| 636 | Run redundancy removal functions before calling this function, |
| 637 | see the sample code adjacency.c. |
| 638 | |
| 639 | |
| 640 | \item[{\tt dd\_SetFamilyPtr dd\_Matrix2WeakAdjacency(matrix, err)}]:\\ |
| 641 | Computes the weak adjacency list of input rows using |
| 642 | the LP solver and without running the representation conversion. When |
| 643 | the input is H-representation, it gives the graph where its nodes are the facets |
| 644 | two nodes are adjacent if and only if the associated facets have |
| 645 | some intersection. |
| 646 | For V-representation, it gives the graph where its nodes are the vertices |
| 647 | and two nodes are adjacent if and only if the associated vertices |
| 648 | are on a common facet. |
| 649 | It is required that the input matrix is a minimal representation. |
| 650 | Run redundancy removal functions before calling this function, |
| 651 | see the sample code adjacency.c. |
| 652 | |
| 653 | \item[{\tt dd\_MatrixPtr dd\_FourierElimination(matrix, err)}]:\\ |
| 654 | Eliminate the last variable from a system of linear inequalities |
| 655 | given by matrix by using the Fourier's Elimination. If the |
| 656 | input matrix is V-representation, {\tt *err} returns |
| 657 | {\tt dd\_NotAvailForV}. This function does not |
| 658 | remove redundancy and one might want to call |
| 659 | redundancy removal functions afterwards. See the sample code fourier.c. |
| 660 | |
| 661 | \item[{\tt dd\_MatrixPtr dd\_BlockElimination(matrix, set, err)}]:\\ |
| 662 | Eliminate a set of variables from a system of linear inequalities |
| 663 | given by matrix by using the extreme rays of the dual linear system. |
| 664 | See comments in the code cddproj.c for details. This might be |
| 665 | a faster way to eliminate variables than the repeated FourierElimination when |
| 666 | the number of variables to eliminate is large. |
| 667 | If the input matrix is V-representation, {\tt *err} returns {\tt dd\_NotAvailForV}. |
| 668 | This function does not remove redundancy and one might want to call |
| 669 | redundancy removal functions afterwards. See the sample code projection.c. |
| 670 | |
| 671 | |
| 672 | \item[{\tt dd\_rowrange dd\_RayShooting(matrix, point, vector)}]:\\ |
| 673 | Finds the index of a halfspace first left by the ray starting from |
| 674 | {\tt point} toward the direction {\tt vector}. It resolves |
| 675 | tie by a lexicographic perturbation. Those inequalities violated |
| 676 | by {\tt point} will be simply ignored. |
| 677 | |
| 678 | \end{description} |
| 679 | |
| 680 | |
| 681 | \subsection{Data Manipulations} \label{DataLibrary} |
| 682 | |
| 683 | \subsubsection{Number Assignments} |
| 684 | For number assignments, one cannot use such expressions as {\tt x=(mytype)a}. |
| 685 | This is because cddlib uses an abstract number type ({\tt mytype}) |
| 686 | so that it can compute with various |
| 687 | number types such as C double and GMP rational. |
| 688 | User can easily add a new number type by redefining |
| 689 | arithmetic operations in cddmp.h and cddmp.c. |
| 690 | |
| 691 | \begin{description} |
| 692 | |
| 693 | |
| 694 | \item[{\tt void dd\_init(x)}]:\\ |
| 695 | This is to initialize a {\tt mytype} variable {\tt x} and to set it |
| 696 | to zero. This initialization has to be called before |
| 697 | any {\tt mytype} variable to be used. |
| 698 | |
| 699 | \item[{\tt void dd\_clear(x)}]:\\ |
| 700 | This is to free the space allocated to a {\tt mytype} variable {\tt x}. |
| 701 | |
| 702 | \item[{\tt void dd\_set\_si(x, a)}]:\\ |
| 703 | This is to set a {\tt mytype} variable {\tt x} to the |
| 704 | value of signed long integer {\tt a}. |
| 705 | |
| 706 | \item[{\tt void dd\_set\_si2(x, a, b)}]:\\ |
| 707 | This is to set a {\tt mytype} variable {\tt x} to the |
| 708 | value of the rational expression {\tt a/b}, where |
| 709 | {\tt a} is signed long and {\tt b} is unsigned long |
| 710 | integers. |
| 711 | |
| 712 | \item[{\tt void dd\_set\_d(x, b)}]:\\ |
| 713 | This is to set a {\tt mytype} variable {\tt x} to the |
| 714 | value of double {\tt b}. This is available only |
| 715 | when the library is compiled without {\tt -DGMPRATIONAL} |
| 716 | compiler option. |
| 717 | |
| 718 | \end{description} |
| 719 | |
| 720 | |
| 721 | \subsubsection{Arithmetic Operations for {\tt mytype} Numbers} |
| 722 | |
| 723 | Below {\tt x}, {\tt y}, {\tt z} are of type {\tt mytype}. |
| 724 | |
| 725 | \begin{description} |
| 726 | |
| 727 | \item[{\tt void dd\_add(x, y, z)}]:\\ |
| 728 | Set {\tt x} to be the sum of {\tt y} and {\tt z}. |
| 729 | |
| 730 | \item[{\tt void dd\_sub(x, y, z)}]:\\ |
| 731 | Set {\tt x} to be the substraction of {\tt z} from {\tt y}. |
| 732 | |
| 733 | \item[{\tt void dd\_mul(x, y, z)}]:\\ |
| 734 | Set {\tt x} to be the multiplication of {\tt y} and {\tt z}. |
| 735 | |
| 736 | \item[{\tt void dd\_div(x, y, z)}]:\\ |
| 737 | Set {\tt x} to be the division of {\tt y} over {\tt z}. |
| 738 | |
| 739 | \item[{\tt void dd\_inv(x, y)}]:\\ |
| 740 | Set {\tt x} to be the reciplocal of {\tt y}. |
| 741 | |
| 742 | \end{description} |
| 743 | |
| 744 | |
| 745 | \subsubsection{Predefined Constants} \label{constants} |
| 746 | |
| 747 | There are several {\tt mytype} constants defined when {\tt dd\_set\_global\_constants(void)} is called. |
| 748 | Some constants depend on the double constant {\tt dd\_almostzero} which is normally set to $10^{-7}$ in cdd.h. |
| 749 | This value can be modified depending on how numerically delicate your problems are but an extra |
| 750 | caution should be taken. |
| 751 | |
| 752 | \begin{description} |
| 753 | |
| 754 | \item[{\tt mytype dd\_purezero}]:\\ |
| 755 | This represents the mathematical zero $0$. |
| 756 | |
| 757 | \item[{\tt mytype dd\_zero}]:\\ |
| 758 | This represents the largest positive number which should be considered to be zero. In the GMPRATIONAL |
| 759 | mode, it is equal to {\tt dd\_purezero}. In the C double mode, it is set to the value of {\tt dd\_almostzero}. |
| 760 | |
| 761 | \item[{\tt mytype dd\_minuszero}]:\\ |
| 762 | The negative of {\tt dd\_zero}. |
| 763 | |
| 764 | \item[{\tt mytype dd\_one}]:\\ |
| 765 | This represents the mathematical one $1$. |
| 766 | |
| 767 | |
| 768 | \end{description} |
| 769 | |
| 770 | \subsubsection{Sign Evaluation and Comparison for {\tt mytype} Numbers} |
| 771 | |
| 772 | Below {\tt x}, {\tt y}, {\tt z} are of type {\tt mytype}. |
| 773 | |
| 774 | \begin{description} |
| 775 | |
| 776 | \item[{\tt dd\_boolean dd\_Positive(x)}]:\\ |
| 777 | Returns {\tt dd\_TRUE} if {\tt x} is considered positive, and {\tt dd\_FALSE} otherwise. |
| 778 | In the GMPRATIONAL mode, the positivity recognition is exact. In the C double mode, |
| 779 | this means the value is strictly larger than {\tt dd\_zero}. |
| 780 | |
| 781 | {\tt dd\_boolean dd\_Negative(x)} works similarly. |
| 782 | |
| 783 | \item[{\tt dd\_boolean dd\_Nonpositive(x)}]:\\ |
| 784 | Returns the negation of {\tt dd\_Positive(x)}. {\tt dd\_Nonnegative(x)} works similarly. |
| 785 | |
| 786 | \item[{\tt dd\_boolean dd\_EqualToZero(x)}]:\\ |
| 787 | Returns {\tt dd\_TRUE} if {\tt x} is considered zero, and {\tt dd\_FALSE} otherwise. |
| 788 | In the GMPRATIONAL mode, the zero recognition is exact. In the C double mode, |
| 789 | this means the value is inbetween {\tt dd\_minuszero} and {\tt dd\_zero} |
| 790 | inclusive. |
| 791 | |
| 792 | \item[{\tt dd\_boolean dd\_Larger(x, y)}]:\\ |
| 793 | Returns {\tt dd\_TRUE} if {\tt x} is strictly larger than {\tt y}, and {\tt dd\_FALSE} otherwise. |
| 794 | This is implemented as {dd\_Positive(z)} where {\tt z} is the subtraction of {\tt y} |
| 795 | from {\tt x}. |
| 796 | {\tt dd\_Smaller(x, y)} works similarly. |
| 797 | |
| 798 | \item[{\tt dd\_boolean dd\_Equal(x, y)}]:\\ |
| 799 | Returns {\tt dd\_TRUE} if {\tt x} is considered equal to {\tt y}, and {\tt dd\_FALSE} otherwise. |
| 800 | This is implemented as {dd\_EqualToZero(z)} where {\tt z} is the subtraction of {\tt y} |
| 801 | from {\tt x}. |
| 802 | \end{description} |
| 803 | |
| 804 | |
| 805 | |
| 806 | \subsubsection{Polyhedra Data Manipulation} |
| 807 | \begin{description} |
| 808 | |
| 809 | \item[{\tt dd\_MatrixPtr dd\_PolyFile2Matrix (f, err)}]:\\ |
| 810 | Read a Polyhedra data from stream {\tt f} and store it in {\tt matrixdata} |
| 811 | and return a pointer to the data. |
| 812 | |
| 813 | \item[{\tt dd\_MatrixPtr dd\_CopyInequalities(poly)}]:\\ |
| 814 | Copy the inequality representation pointed by poly to {\tt matrixdata} |
| 815 | and return {\tt dd\_MatrixPtr}. |
| 816 | |
| 817 | \item[{\tt dd\_MatrixPtr dd\_CopyGenerators(poly)}]:\\ |
| 818 | Copy the generator representation pointed by poly to {\tt matrixdata} |
| 819 | and return {\tt dd\_MatrixPtr}. |
| 820 | |
| 821 | \item[{\tt dd\_SetFamilyPtr dd\_CopyIncidence(poly)}]:\\ |
| 822 | Copy the incidence representation of the computed representation |
| 823 | pointed by poly to {\tt setfamily} |
| 824 | and return {\tt dd\_SetFamilyPtr}. The computed representation is |
| 825 | {\tt Inequality} if the input is {\tt Generator}, and the vice visa. |
| 826 | |
| 827 | \item[{\tt dd\_SetFamilyPtr dd\_CopyAdjacency(poly)}]:\\ |
| 828 | Copy the adjacency representation of the computed representation |
| 829 | pointed by poly to {\tt setfamily} |
| 830 | and return {\tt dd\_SetFamilyPtr}. The computed representation is |
| 831 | {\tt Inequality} if the input is {\tt Generator}, and the vice visa. |
| 832 | |
| 833 | \item[{\tt dd\_SetFamilyPtr dd\_CopyInputIncidence(poly)}]:\\ |
| 834 | Copy the incidence representation of the input representation |
| 835 | pointed by poly to {\tt setfamily} |
| 836 | and return {\tt d\_SetFamilyPtr}. |
| 837 | |
| 838 | \item[{\tt dd\_SetFamilyPtr dd\_CopyInputAdjacency(poly)}]:\\ |
| 839 | Copy the adjacency representation of the input representation |
| 840 | pointed by poly to {\tt setfamily} |
| 841 | and return {\tt d\_SetFamilyPtr}. |
| 842 | |
| 843 | \item[{\tt void dd\_FreePolyhedra(poly)}]:\\ |
| 844 | Free memory allocated to {\tt poly}. |
| 845 | |
| 846 | \end{description} |
| 847 | |
| 848 | \subsubsection{LP Data Manipulation} |
| 849 | \begin{description} |
| 850 | |
| 851 | \item[{\tt dd\_LPPtr dd\_MakeLPforInteriorFinding(lp)}]:\\ |
| 852 | Set up an LP to find an interior point of the feasible region of {\tt lp} |
| 853 | and return a pointer to the LP. The new LP has one new variable |
| 854 | $x_{d+1}$ and one more constraint: |
| 855 | $\max x_{d+1}$ subject to $b - A x - x_{d+1} \ge 0$ and $x_{d+1} \le K$, |
| 856 | where $K$ is a positive constant. |
| 857 | |
| 858 | \item[{\tt dd\_LPPtr dd\_Matrix2LP(matrix, err)}]:\\ |
| 859 | Load {\tt matrix} to {\tt lpdata} and return a pointer to the data. |
| 860 | |
| 861 | \item[{\tt dd\_LPSolutionPtr dd\_CopyLPSolution(lp)}]:\\ |
| 862 | Load the solutions of {\tt lp} to {\tt lpsolution} and |
| 863 | return a pointer to the data. This replaces the old name |
| 864 | {\tt dd\_LPSolutionLoad(lp)}. |
| 865 | |
| 866 | \item[{\tt void dd\_FreeLPData(lp)}]:\\ |
| 867 | Free memory allocated as an LP data pointed by {\tt lp}. |
| 868 | |
| 869 | \item[{\tt void dd\_FreeLPSolution(lps)}]:\\ |
| 870 | Free memory allocated as an LP solution data pointed by {\tt lps}. |
| 871 | |
| 872 | \end{description} |
| 873 | |
| 874 | \subsubsection{Matrix Manipulation} |
| 875 | \begin{description} |
| 876 | |
| 877 | \item[{\tt dd\_MatrixPtr dd\_CopyMatrix(matrix)}]:\\ |
| 878 | Make a copy of matrixdata pointed by {\tt matrix} and return |
| 879 | a pointer to the copy. |
| 880 | |
| 881 | \item[{\tt dd\_MatrixPtr dd\_AppendMatrix(matrix1, matrix2)}]:\\ |
| 882 | Make a matrixdata by copying {\tt *matrix1} and appending |
| 883 | the matrix in {\tt *matrix2} and return |
| 884 | a pointer to the data. The colsize must be equal in |
| 885 | the two input matrices. It returns a {\tt NULL} pointer |
| 886 | if the input matrices are not appropriate. |
| 887 | Its {\tt rowsize} is set to |
| 888 | the sum of the rowsizes of {\tt matrix1} and {\tt matrix2}. |
| 889 | The new matrixdata inherits everything else |
| 890 | (i.e. numbertype, representation, etc) |
| 891 | from the first matrix. |
| 892 | |
| 893 | \item[{\tt int dd\_MatrixAppendTo(\& matrix1, matrix2)}]:\\ |
| 894 | Same as {\tt dd\_AppendMatrix} except that the first matrix |
| 895 | is modified to take the result. |
| 896 | |
| 897 | \item[{\tt int dd\_MatrixRowRemove(\& matrix, i)}]:\\ |
| 898 | Remove the $i$th row of {\tt matrix}. |
| 899 | |
| 900 | \item[{\tt dd\_MatrixPtr dd\_MatrixSubmatrix(matrix, set)}]:\\ |
| 901 | Generate the submatrix of {\tt matrix} by removing the |
| 902 | rows indexed by {\tt set} and return a matrixdata pointer. |
| 903 | |
| 904 | \item[{\tt dd\_SetFamilyPtr dd\_Matrix2Adjacency(matrix, err)}]:\\ |
| 905 | Return the adjacency list of the representation given by {\tt matrix}. |
| 906 | The computation is done by the built-in LP solver. The representation |
| 907 | should be free of redundancy when this function is called. |
| 908 | See the function {\tt dd\_rowset dd\_RedundantRows} |
| 909 | and the example program adjacency.c. |
| 910 | |
| 911 | \end{description} |
| 912 | |
| 913 | \subsection{Input/Output Functions} \label{IOLibrary} |
| 914 | |
| 915 | \begin{description} |
| 916 | |
| 917 | \item[{\tt dd\_MatrixPtr dd\_PolyFile2Matrix (f, err)}]:\\ |
| 918 | Read a Polyhedra data from stream {\tt f} and store it in {\tt matrixdata} |
| 919 | and return a pointer to the data. |
| 920 | |
| 921 | \item[{\tt boolean dd\_DDFile2File(ifile, ofile, err)}]:\\ |
| 922 | Compute the representation conversion for a polyhedron given |
| 923 | by a Polyhedra file ifile, and write the other representation |
| 924 | in a Polyhedra file ofile. {\tt *err} |
| 925 | returns {\tt dd\_NoError} if the computation terminates normally. Otherwise, |
| 926 | it returns a value according to the error occured. |
| 927 | |
| 928 | \item[{\tt void dd\_WriteMatrix(f, matrix)}]:\\ |
| 929 | Write {\tt matrix} to stream {\tt f}. |
| 930 | |
| 931 | \item[{\tt void dd\_WriteNumber(f, x)}]:\\ |
| 932 | Write {\tt x} to stream {\tt f}. If {\tt x} is of GMP mpq\_t rational $p/q$, |
| 933 | the output is $p/q$. If it is of C double, it is formated as a double float |
| 934 | with a decimal point. |
| 935 | |
| 936 | \item[{\tt void dd\_WritePolyFile(f, poly)}]:\\ |
| 937 | Write {tt poly} to stream {\tt f} in Polyhedra format. |
| 938 | |
| 939 | \item[{\tt void dd\_WriteErrorMessages(f, err)}]:\\ |
| 940 | Write error messages given by {\tt err} to stream {\tt f}. |
| 941 | |
| 942 | \item[{\tt void dd\_WriteSetFamily(f, setfam)}]:\\ |
| 943 | Write the set family pointed by {\tt setfam} to stream {\tt f}. |
| 944 | For each set, it outputs its index, its cardinality, |
| 945 | a colon ``:'' and a ordered list of its elements. |
| 946 | |
| 947 | \item[{\tt void dd\_WriteSetFamilyCompressed(f, setfam)}]:\\ |
| 948 | Write the set family pointed by {\tt setfam} to stream {\tt f}. |
| 949 | For each set, it outputs its index, its cardinality or the |
| 950 | negative of the cardinality, a colon ``:'' |
| 951 | and the elements in the set or its complements whichever is smaller. |
| 952 | Whenever it outputs the complements, the cardinality is negated |
| 953 | so that there is no ambiguity. |
| 954 | This will be considered standard for |
| 955 | outputing incidence (*.icd, *ecd) and adjacency |
| 956 | (*.iad, *.ead) data in cddlib. But there is some minor incompatibility |
| 957 | with cdd/cdd+ standalone codes. |
| 958 | |
| 959 | \item[{\tt void dd\_WriteProgramDescription(f)}]:\\ |
| 960 | Write the cddlib version information to stream {\tt f}. |
| 961 | |
| 962 | \item[{\tt void dd\_WriteDDTimes(f, poly)}]:\\ |
| 963 | Write the representation conversion time information on {\tt poly} |
| 964 | to stream {\tt f}. |
| 965 | |
| 966 | \end{description} |
| 967 | |
| 968 | \subsection{Obsolete Functions} \label{ObsoleteFunctions} |
| 969 | \begin{description} |
| 970 | \item[{\tt boolean dd\_DoubleDescription(poly, err)}]: |
| 971 | (removed in Version 0.90c)\\ |
| 972 | The new function |
| 973 | {\tt dd\_DDMatrix2Poly(matrix, err)} (see Section~\ref{CoreLibrary}) |
| 974 | replaces (and actually combines) both this and |
| 975 | {\tt dd\_Matrix2Poly(matrix, err)}. |
| 976 | |
| 977 | \item[{\tt dd\_PolyhedraPtr dd\_Matrix2Poly(matrix, err)}]: |
| 978 | (removed in Version 0.90c)\\ |
| 979 | See above for the reason for removal. |
| 980 | |
| 981 | \item[{\tt dd\_LPSolutionPtr dd\_LPSolutionLoad(lp)}]: |
| 982 | (renamed in Version 0.90c)\\ |
| 983 | This function is now called {\tt dd\_CopyLPSolution(lp)}. |
| 984 | |
| 985 | \end{description} |
| 986 | |
| 987 | |
| 988 | \subsection{Set Functions in {\tt setoper} library} \label{SetFunctions} |
| 989 | |
| 990 | The cddlib comes with a simple set operation library {\tt setoper}. The key |
| 991 | type defined is {\tt set\_type}. A set is represented by a fixed length |
| 992 | binary strings. Thus, the maximum length of a set must be declared when |
| 993 | it is initialized. |
| 994 | |
| 995 | Below the symbols {\tt a}, {\tt b}, {\tt c} are |
| 996 | of type {\tt set\_type}. The symbols {\tt aP} is a |
| 997 | pointer to type {\tt set\_type}, and {\tt s}, {\tt t} are of type {\tt long}. |
| 998 | Here are some of the functions defined. See {\tt setoper.h} for a |
| 999 | complete listing. |
| 1000 | |
| 1001 | \begin{description} |
| 1002 | |
| 1003 | \item[{\tt void set\_initialize(aP, s)}]:\\ |
| 1004 | Allocate a {\tt set\_type} space of maximum cardinality {\tt s} |
| 1005 | and make it pointed by {\tt aP}. The set is initialized as empty set. |
| 1006 | |
| 1007 | \item[{\tt void set\_free(a)}]:\\ |
| 1008 | Free the {\tt set\_type} space allocated for {\tt a}. |
| 1009 | |
| 1010 | \item[{\tt void set\_copy(a, b))}]:\\ |
| 1011 | Set {\tt a} to be {\tt b}. The set {\tt a} must be pre-initialized |
| 1012 | with the same maximum cardinality as that of {\tt b}. |
| 1013 | |
| 1014 | \item[{\tt void set\_addelem(a, t))}]:\\ |
| 1015 | Add an element {\tt t} to a set {\tt a}. The set {\tt a} stays unchanged |
| 1016 | if it contains the element {\tt t}. |
| 1017 | |
| 1018 | \item[{\tt long set\_card(a))}]:\\ |
| 1019 | Return the cardinality of set {\tt a}. |
| 1020 | |
| 1021 | \item[{\tt int set\_member(t, a))}]:\\ |
| 1022 | Return $1$ if {\tt t} is a member of set {\tt a}, and $0$ otherwise. |
| 1023 | |
| 1024 | |
| 1025 | \item[{\tt void set\_write(a))}]:\\ |
| 1026 | Print out the elements of set {\tt a} to {\tt stdout}. The function {\tt void set\_fwrite(f, a))} output |
| 1027 | to stream {\tt f}. |
| 1028 | |
| 1029 | \end{description} |
| 1030 | |
| 1031 | \section{An Extension of the CDD Library in GMP mode} \label{GMPLIB} |
| 1032 | |
| 1033 | Starting from the version 093, the GMP version of cddlib, {\tt libcddgmp.a}, contains |
| 1034 | all cdd library functions in two arithmetics. All functions with the standard prefix {\tt dd\_} |
| 1035 | are computed with the GMP rational arithmetic as before. The same fuctions with |
| 1036 | the new prefix {\tt ddf\_} are now added to the library {\tt libcddgmp.a} that are based |
| 1037 | on the C double floating-point arithmetic. Thus these functions are equivalent to |
| 1038 | {\tt libcdd.a} functions, except that all functions and variable types are with prefix {\tt ddf\_} and |
| 1039 | the variable type {\tt mytype} is replaced by {\tt myfloat}. |
| 1040 | |
| 1041 | In this sense, {\tt libcdd.a} is a proper subset of {\tt libcddgmp.a} and in principle one can |
| 1042 | do everything with {\tt libcddgmp.a}. See how the new {\tt dd\_LPSolve} is written in |
| 1043 | cddlp.c. |
| 1044 | |
| 1045 | |
| 1046 | \section{Examples} \label{EXAMPLES} |
| 1047 | |
| 1048 | See example codes such as testcdd*.c , testlp*.c, redcheck.c, adjacency.c, allfaces,c |
| 1049 | and simplecdd.c |
| 1050 | in the {\tt src} and {\tt src-gmp} subdirectories of the source |
| 1051 | distribution. |
| 1052 | |
| 1053 | \section{Numerical Accuracy} \label{accuracy} |
| 1054 | A little caution is in order. Many people have observed |
| 1055 | numerical problems of cddlib when the floating version of cddlib |
| 1056 | is used. As we all know, floating-point computation |
| 1057 | might not give a correct answer, especially when an input |
| 1058 | data is very sensitive to a small perturbation. When |
| 1059 | some strange behavior is observed, it is always wise |
| 1060 | to create a rationalization of the input |
| 1061 | (for example, one can replace 0.3333333 with 1/3) |
| 1062 | and to compute it with cddlib compiled with gmp rational |
| 1063 | to see what a correct behavior should be. Whenever the time |
| 1064 | is not important, it is safer to use gmp rational arithmetic. |
| 1065 | |
| 1066 | If you need speedy computation with floating-point arithmetic, |
| 1067 | you might want to ``play with'' the constant {\tt dd\_almostzero} |
| 1068 | defined in cdd.h: |
| 1069 | |
| 1070 | \begin{verbatim} |
| 1071 | #define dd_almostzero 1.0E-7 |
| 1072 | \end{verbatim} |
| 1073 | \noindent |
| 1074 | This number is used to recognize whether a number is zero: |
| 1075 | a number whose absolute value is smaller |
| 1076 | than {\tt dd\_almostzero} is considered zero, and nonzero otherwise. |
| 1077 | You can change this to modify the behavior of cddlib. One might |
| 1078 | consider the default setting is rather large for double |
| 1079 | precision arithmetic. This is because cddlib is made |
| 1080 | to deal with highly degenerate data and it works better |
| 1081 | to treat a relatively large ``epsilon'' as zero. |
| 1082 | |
| 1083 | Another thing one can do is scaling. If the values in one column of |
| 1084 | an input is of smaller magnitude than those in another column, |
| 1085 | scale one so that they become comparable. |
| 1086 | |
| 1087 | \section{Other Useful Codes} \label{CODES} |
| 1088 | There are several other useful codes available for vertex enumeration and/or |
| 1089 | convex hull computation such as lrs, qhull, porta and irisa-polylib. |
| 1090 | The pointers to these codes are available at |
| 1091 | \begin{enumerate} |
| 1092 | \item lrs by D. Avis \cite{a-lrshome-01} (C implementation of the reverse search algorithm |
| 1093 | \cite{af-pachv-92}). |
| 1094 | |
| 1095 | \item qhull by C.B. Barber \cite{bdh-qach-03} (C implementation of |
| 1096 | the beneath-beyond method, see \cite{e-acg-87,m-cg-94}, |
| 1097 | which is the dual of the dd method). |
| 1098 | |
| 1099 | \item porta by T. Christof and A. L{\"o}bel \cite{cl-porta-97} (C implementation |
| 1100 | of the Fourier-Motzkin elimination). |
| 1101 | |
| 1102 | \item IRISA polyhedral library by D.K. Wilde |
| 1103 | \cite{w-ldpo-93b} (C implementation |
| 1104 | of a variation of the dd algorithm). |
| 1105 | |
| 1106 | \item PPL: the Parma Polyhedra Library \cite{b-pplhome} by R. Bagnara (C++ implementation of |
| 1107 | a variation of the dd algorithm). |
| 1108 | |
| 1109 | \item {\tt pd} by A. Marzetta \cite{m-pdcip-97} (C implementation of the primal-dual algorithm |
| 1110 | \cite{bfm-pdmvf-97}). |
| 1111 | |
| 1112 | \item Geometry Center Software List by N. Amenta \cite{a-dcg}. |
| 1113 | |
| 1114 | \item Computational Geometry Pages by J. Erickson \cite{e-cgp}. |
| 1115 | |
| 1116 | \item Linear Programming FAQ by R. Fourer and J. Gregory \cite{fg-lpfaq}. |
| 1117 | |
| 1118 | \item ZIB Berlin polyhedral software list:\\ |
| 1119 | \htmladdnormallink{ftp://elib.zib-berlin.de/pub/mathprog/polyth/index.html} |
| 1120 | {ftp://elib.zib-berlin.de/pub/mathprog/polyth/index.html}. |
| 1121 | |
| 1122 | |
| 1123 | \item Polyhedral Computation FAQ \cite{f-pcfaq-98}. |
| 1124 | \end{enumerate} |
| 1125 | |
| 1126 | \section{Codes Using Cddlib} \label{USERCODES} |
| 1127 | |
| 1128 | There are quite a few nice programs using some functions of cddlib. |
| 1129 | Here are some of them. |
| 1130 | |
| 1131 | |
| 1132 | \begin{enumerate} |
| 1133 | |
| 1134 | \item {\tt LattE} \cite{dhhhty-latte-05} computes the number of lattice points |
| 1135 | in a convex polytope. |
| 1136 | |
| 1137 | \item {\tt Minksum} \cite{w-msv-05} is a program to compute the V-representation |
| 1138 | (i.e. the set of vertices) of the Minkowski addition of several convex polytopes |
| 1139 | given by their V-representation in $\R^d$. It is an implementation in C++ language |
| 1140 | of the reverse search algorithm \cite{f-fzctmacp-04} whose time complexity is |
| 1141 | polynomially bounded by the sizes of input and output. |
| 1142 | |
| 1143 | \item {\tt Gfan} \cite{j-gvum-05} is a program to list all reduced Gr\"obner |
| 1144 | bases of a general polynomial ideal given by a set of generating polynomials |
| 1145 | in $n$-variables. It is an implementation in C++ language |
| 1146 | of the reverse search algorithm \cite{fjt-cgf-05}. |
| 1147 | |
| 1148 | |
| 1149 | \item {\tt TOPCOM} \cite{r-topcom-05} computes the combinatorial structure |
| 1150 | (the oriented matroid) of a point configuration and enumerates all triangulations |
| 1151 | of a point set. It detects the regularlity of a triangulation using cddlib. |
| 1152 | |
| 1153 | \end{enumerate} |
| 1154 | |
| 1155 | |
| 1156 | \section*{Acknowledgements.} |
| 1157 | I am grateful to Tom Liebling who |
| 1158 | provided me with an ideal opportunity to visit EPFL |
| 1159 | for the academic year 1993-1994. Later, Hans-Jakob L\"uthi (ETHZ) and |
| 1160 | Emo Welzl (ETHZ) joined to support the |
| 1161 | the development of cdd codes (cdd, cdd+, cddlib). |
| 1162 | Without their generous and continuing support, the present form of |
| 1163 | this program would not have existed. |
| 1164 | |
| 1165 | There are many other people who helped me to improve cdd, in particular, |
| 1166 | I am indebted to David Avis, |
| 1167 | Alexander Bockmayr, David Bremner, Henry Crapo, Istvan Csabai, |
| 1168 | Francois Margot, Marc Pfetsch, Alain Prodon, J\"org Rambau, Dima Pasechnik, |
| 1169 | Shawn Rusaw, Matthew Saltzman, Masanori Sato, Anders Jensen, |
| 1170 | Ruriko Yoshida, Charles Geyer, Michal Kvasnica, Sven Verdoolaege |
| 1171 | (listed in arbitrary order) and those listed |
| 1172 | in the HISTORY file. |
| 1173 | |
| 1174 | \bibliographystyle{plain} |
| 1175 | |
| 1176 | \bibliography{fukuda1,fukuda2} |
| 1177 | |
| 1178 | \end{document} |
| 1179 | |
| 1180 | |