/* Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it would be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, this software is distributed without any warranty that it is free of the rightful claim of any third person regarding infringement or the like. Any license provided herein, whether implied or otherwise, applies only to this software file. Patent licenses, if any, provided herein do not apply to combinations of this program with other software, or any other product whatsoever. You should have received a copy of the GNU General Public License along with this program; if not, write the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, Mountain View, CA 94043, or: http://www.sgi.com For further information regarding this notice, see: http://oss.sgi.com/projects/GenInfo/NoticeExplan */ // -*-C++-*- /** *** Description: *** *** SYSTEM_OF_EQUATIONS represents an integer linear system of equations *** of the form (Ale)x <= (ble) and (Aeq)x = (beq). The entries of *** the matrix (upper case) are 32 bit integers, and the entries of *** the vector (lower case) are 64 bit integers. Each row represents *** one equation. During the computation process, 32 bit overflow *** is checked, but 64 bit overflow is not. *** *** The actual system is represented by two IMAT and two arrays of mINT64. *** Extra space is typically allocated to the matrices (as specified in *** the constructor) so that the system can grow. If the system grows *** too much, more space is automatically allocated. *** *** In addition, the system contains a large static work array. *** The work array only contains le constraints. The equality *** constraints from Aeq are subbed into the work array when needed. *** *** The memory pool supplied with the constructor is where all space *** (other than the global work array) needed for this object is allocated. *** *** There are no symbol names, variables etc associated with the colums. *** While each column represents a variable, *which* variable a column *** represents must be indicated elsewhere. *** *** *** Exported Types: *** *** SYSTEM_OF_EQUATIONS *** *** Exported Functions: *** *** SYSTEM_OF_EQUATIONS( *** INT32 eqns_le, *** INT32 eqns_eq, *** INT32 vars, *** MEM_POOL* *** ); *** *** *** Create a SYSTEM_OF_EQUATIONS, space is reserved for *** eqns_le rows in Ale, eqns_eq rows in Aeq and vars columns. *** Num_Eq_Constraints() and Num_Le_Constraints() *** are initialized to 0. As more equations are needed, they are *** added automatically in chunks of 32. *** Num_Vars() is initialized to vars *** *** *** SYSTEM_OF_EQUATIONS(const SYSTEM_OF_EQUATIONS*, MEM_POOL*) *** *** The method used to copy one system of equations to another. *** *** ~SYSTEM_OF_EQUATIONS() *** *** As you would expect. *** *** INT32 Num_Eq_Constraints() const; *** *** How many valid equality constraints are in this system of equations. *** *** INT32 Num_Le_Constraints() const; *** *** How many valid le constraints are in this system of equations. *** *** INT32 Num_Vars() const; *** *** How many valid variables are in this system. *** *** void Add_Vars(const INT32 num_vars) *** *** Add num_vars valid columns to the matrices and vectors. *** If there is space, this basically zeroes the columns of *** the matrices. Otherwise, this may also involve resizing. *** *** void Remove_Last_Vars(INT num_vars) *** *** Get rid of the last num_vars variables. All these columns *** must be zero on entry. *** *** void Add_Eq(const mINT32 row[], INT64 b); *** void Add_Le(const mINT32 row[], INT64 b); *** *** Add an equation to the current system, either as an equals or *** le than condition. *** *** BOOL Add_Le_Non_Redundant(const mINT32 row[], INT64 b); *** *** Like Add_Le, but only adds it if adding it is not redundant. *** Return true if added. *** *** void Add_Eq(INT num_rows); *** void Add_Le(INT num_rows); *** Add num_rows, uninitialized, to the current system. *** *** void Add_Soe(const SYSTEM_OF_EQUATIONS* soe); *** *** Add the passed in system of equations to the current system. *** *** void Zero_Row_Le(INT32 r); *** *** Zero row r in Ale,ble *** *** void Complement_Le(INT32 r); *** *** Makes the row have the complementary equation, which is NOT *** -Ale() <= -b, but rather -Ale() <= -b-1 *** *** INT32 Leftmost_Non_Zero_Le(INT32 r) const; *** *** Returns first c such that Ale()(r,c) is non-zero. Returns *** Num_Vars() if entire row is zero. *** *** void Sort_Le(INT* sort_criteria, BOOL descending = FALSE); *** *** Move rows so that the rows are ordered by sort_criteria. *** Sort the sort_criteria as well. That way, *** sort_criteria[i] < sort_criteria[j] if and only if i