1 | /* $Id: CoinAbcBaseFactorization.hpp 1448 2011-06-19 15:34:41Z stefan $ */ |
---|
2 | // Copyright (C) 2002, International Business Machines |
---|
3 | // Corporation and others, Copyright (C) 2012, FasterCoin. All Rights Reserved. |
---|
4 | // This code is licensed under the terms of the Eclipse Public License (EPL). |
---|
5 | |
---|
6 | /* |
---|
7 | Authors |
---|
8 | |
---|
9 | John Forrest |
---|
10 | |
---|
11 | */ |
---|
12 | /** This deals with Factorization and Updates |
---|
13 | |
---|
14 | I am assuming that 32 bits is enough for number of rows or columns, but CoinBigIndex |
---|
15 | may be redefined to get 64 bits. |
---|
16 | */ |
---|
17 | |
---|
18 | #include "AbcCommon.hpp" |
---|
19 | #include "CoinAbcHelperFunctions.hpp" |
---|
20 | #if ABC_PARALLEL |
---|
21 | #define FACTOR_CPU 4 |
---|
22 | #else |
---|
23 | #define FACTOR_CPU 1 |
---|
24 | #endif |
---|
25 | #define LARGE_SET COIN_INT_MAX-10 |
---|
26 | #define LARGE_UNSET (LARGE_SET+1) |
---|
27 | |
---|
28 | class CoinAbcTypeFactorization : public |
---|
29 | CoinAbcAnyFactorization |
---|
30 | { |
---|
31 | friend void CoinAbcFactorizationUnitTest( const std::string & mpsDir ); |
---|
32 | |
---|
33 | public: |
---|
34 | |
---|
35 | /**@name Constructors and destructor and copy */ |
---|
36 | //@{ |
---|
37 | /// Default constructor |
---|
38 | CoinAbcTypeFactorization ( ); |
---|
39 | /// Copy constructor |
---|
40 | CoinAbcTypeFactorization ( const CoinAbcTypeFactorization &other); |
---|
41 | /// Copy constructor |
---|
42 | CoinAbcTypeFactorization ( const CoinFactorization &other); |
---|
43 | |
---|
44 | /// Destructor |
---|
45 | virtual ~CoinAbcTypeFactorization ( ); |
---|
46 | /// Clone |
---|
47 | virtual CoinAbcAnyFactorization * clone() const ; |
---|
48 | /// Delete all stuff (leaves as after CoinAbcFactorization()) |
---|
49 | void almostDestructor(); |
---|
50 | /// Debug show object (shows one representation) |
---|
51 | void show_self ( ) const; |
---|
52 | /// Debug - sort so can compare |
---|
53 | void sort ( ) const; |
---|
54 | /// = copy |
---|
55 | CoinAbcTypeFactorization & operator = ( const CoinAbcTypeFactorization & other ); |
---|
56 | //@} |
---|
57 | |
---|
58 | /**@name Do factorization */ |
---|
59 | //@{ |
---|
60 | /// Condition number - product of pivots after factorization |
---|
61 | CoinSimplexDouble conditionNumber() const; |
---|
62 | |
---|
63 | //@} |
---|
64 | |
---|
65 | /**@name general stuff such as permutation or status */ |
---|
66 | //@{ |
---|
67 | /// Returns address of permute region |
---|
68 | inline CoinSimplexInt *permute ( ) const { |
---|
69 | return NULL; //permute_.array(); |
---|
70 | } |
---|
71 | /// Returns array to put basis indices in |
---|
72 | virtual inline CoinSimplexInt * indices() const |
---|
73 | { return indexRowU_.array();} |
---|
74 | /// Returns address of pivotColumn region (also used for permuting) |
---|
75 | virtual inline CoinSimplexInt *pivotColumn ( ) const { |
---|
76 | return pivotColumn_.array(); |
---|
77 | } |
---|
78 | /// Returns address of pivot region |
---|
79 | virtual inline CoinFactorizationDouble *pivotRegion ( ) const { |
---|
80 | return pivotRegionAddress_; |
---|
81 | } |
---|
82 | #if ABC_SMALL<2 |
---|
83 | /// Start of each row in L |
---|
84 | inline CoinBigIndex * startRowL() const |
---|
85 | { return startRowL_.array();} |
---|
86 | #endif |
---|
87 | |
---|
88 | /// Start of each column in L |
---|
89 | inline CoinBigIndex * startColumnL() const |
---|
90 | { return startColumnL_.array();} |
---|
91 | |
---|
92 | #if ABC_SMALL<2 |
---|
93 | /// Index of column in row for L |
---|
94 | inline CoinSimplexInt * indexColumnL() const |
---|
95 | { return indexColumnL_.array();} |
---|
96 | #endif |
---|
97 | |
---|
98 | /// Row indices of L |
---|
99 | inline CoinSimplexInt * indexRowL() const |
---|
100 | { return indexRowL_.array();} |
---|
101 | |
---|
102 | #if ABC_SMALL<2 |
---|
103 | /// Elements in L (row copy) |
---|
104 | inline CoinFactorizationDouble * elementByRowL() const |
---|
105 | { return elementByRowL_.array();} |
---|
106 | #endif |
---|
107 | /** |
---|
108 | Forward and backward linked lists (numberRows_+2) |
---|
109 | **/ |
---|
110 | inline CoinSimplexInt * pivotLinkedBackwards() const |
---|
111 | { return firstCount_.array()+numberRows_+1;} |
---|
112 | inline CoinSimplexInt * pivotLinkedForwards() const |
---|
113 | { return firstCount_.array()+2*numberRows_+3;} |
---|
114 | inline CoinSimplexInt * pivotLOrder() const |
---|
115 | { return firstCount_.array();} |
---|
116 | #if ABC_SMALL<0 |
---|
117 | #define ABC_USE_FUNCTION_POINTERS 0 |
---|
118 | #define SMALL_PERMUTE |
---|
119 | #endif |
---|
120 | #ifdef ABC_USE_FUNCTION_POINTERS |
---|
121 | typedef void (*scatterUpdate) (int,CoinFactorizationDouble,const CoinFactorizationDouble *, CoinFactorizationDouble *); |
---|
122 | #if ABC_USE_FUNCTION_POINTERS |
---|
123 | typedef struct { |
---|
124 | scatterUpdate functionPointer; |
---|
125 | CoinBigIndex offset; |
---|
126 | int number; |
---|
127 | } scatterStruct; |
---|
128 | #else |
---|
129 | typedef struct { |
---|
130 | CoinBigIndex offset; |
---|
131 | int number; |
---|
132 | } scatterStruct; |
---|
133 | #endif |
---|
134 | /// Array of function pointers PLUS for U Column |
---|
135 | inline scatterStruct * scatterUColumn() const |
---|
136 | { return scatterPointersUColumnAddress_;} |
---|
137 | #endif |
---|
138 | |
---|
139 | /// For equal counts in factorization |
---|
140 | /** First Row/Column with count of k, |
---|
141 | can tell which by offset - Rows then Columns |
---|
142 | actually comes before nextCount*/ |
---|
143 | inline CoinSimplexInt * firstCount() const |
---|
144 | { return firstCount_.array();} |
---|
145 | |
---|
146 | /// Next Row/Column with count |
---|
147 | inline CoinSimplexInt * nextCount() const |
---|
148 | { return firstCount_.array()+numberRows_+2;} |
---|
149 | |
---|
150 | /// Previous Row/Column with count |
---|
151 | inline CoinSimplexInt * lastCount() const |
---|
152 | { return firstCount_.array()+3*numberRows_+2;} |
---|
153 | |
---|
154 | /// Number of Rows after iterating |
---|
155 | inline CoinSimplexInt numberRowsExtra ( ) const { |
---|
156 | return numberRowsExtra_; |
---|
157 | } |
---|
158 | /// Number in L |
---|
159 | inline CoinBigIndex numberL() const |
---|
160 | { return numberL_;} |
---|
161 | |
---|
162 | /// Base of L |
---|
163 | inline CoinBigIndex baseL() const |
---|
164 | { return baseL_;} |
---|
165 | /// Maximum of Rows after iterating |
---|
166 | inline CoinSimplexInt maximumRowsExtra ( ) const { |
---|
167 | return maximumRowsExtra_; |
---|
168 | } |
---|
169 | /// Total number of elements in factorization |
---|
170 | virtual inline CoinBigIndex numberElements ( ) const { |
---|
171 | return totalElements_; |
---|
172 | } |
---|
173 | /// Length of FT vector |
---|
174 | inline CoinSimplexInt numberForrestTomlin ( ) const { |
---|
175 | return numberInColumn_.array()[numberRowsExtra_]; |
---|
176 | } |
---|
177 | /// Returns areaFactor but adjusted for dense |
---|
178 | CoinSimplexDouble adjustedAreaFactor() const; |
---|
179 | /// Level of detail of messages |
---|
180 | inline CoinSimplexInt messageLevel ( ) const { |
---|
181 | return messageLevel_ ; |
---|
182 | } |
---|
183 | void messageLevel ( CoinSimplexInt value ); |
---|
184 | /// Set maximum pivots |
---|
185 | virtual void maximumPivots ( CoinSimplexInt value ); |
---|
186 | |
---|
187 | #if ABC_SMALL<4 |
---|
188 | /// Gets dense threshold |
---|
189 | inline CoinSimplexInt denseThreshold() const |
---|
190 | { return denseThreshold_;} |
---|
191 | /// Sets dense threshold |
---|
192 | inline void setDenseThreshold(CoinSimplexInt value) |
---|
193 | { denseThreshold_ = value;} |
---|
194 | #endif |
---|
195 | /// Returns maximum absolute value in factorization |
---|
196 | CoinSimplexDouble maximumCoefficient() const; |
---|
197 | #if 0 |
---|
198 | /// true if Forrest Tomlin update, false if PFI |
---|
199 | inline bool forrestTomlin() const |
---|
200 | { return doForrestTomlin_;} |
---|
201 | inline void setForrestTomlin(bool value) |
---|
202 | { doForrestTomlin_=value;} |
---|
203 | #endif |
---|
204 | /// True if FT update and space |
---|
205 | inline bool spaceForForrestTomlin() const |
---|
206 | { |
---|
207 | CoinBigIndex start = lastEntryByColumnU_; |
---|
208 | CoinBigIndex space = lengthAreaU_ - ( start + numberRowsExtra_ ); |
---|
209 | return (space>=0); //&&doForrestTomlin_; |
---|
210 | } |
---|
211 | //@} |
---|
212 | |
---|
213 | /**@name some simple stuff */ |
---|
214 | //@{ |
---|
215 | |
---|
216 | |
---|
217 | /// Returns number in U area |
---|
218 | inline CoinBigIndex numberElementsU ( ) const { |
---|
219 | return lengthU_; |
---|
220 | } |
---|
221 | /// Setss number in U area |
---|
222 | inline void setNumberElementsU(CoinBigIndex value) |
---|
223 | { lengthU_ = value; } |
---|
224 | /// Returns length of U area |
---|
225 | inline CoinBigIndex lengthAreaU ( ) const { |
---|
226 | return lengthAreaU_; |
---|
227 | } |
---|
228 | /// Returns number in L area |
---|
229 | inline CoinBigIndex numberElementsL ( ) const { |
---|
230 | return lengthL_; |
---|
231 | } |
---|
232 | /// Returns length of L area |
---|
233 | inline CoinBigIndex lengthAreaL ( ) const { |
---|
234 | return lengthAreaL_; |
---|
235 | } |
---|
236 | /// Returns number in R area |
---|
237 | inline CoinBigIndex numberElementsR ( ) const { |
---|
238 | return lengthR_; |
---|
239 | } |
---|
240 | /// Number of compressions done |
---|
241 | inline CoinBigIndex numberCompressions() const |
---|
242 | { return numberCompressions_;} |
---|
243 | /// Returns pivot row |
---|
244 | //virtual CoinSimplexInt * pivotRow() const; |
---|
245 | /// Returns work area |
---|
246 | //virtual CoinFactorizationDouble * workArea() const; |
---|
247 | /// Returns CoinSimplexInt work area |
---|
248 | //virtual CoinSimplexInt * intWorkArea() const; |
---|
249 | /// Returns array to put basis starts in |
---|
250 | virtual inline CoinBigIndex * starts() const |
---|
251 | { return startColumnU_.array();} |
---|
252 | /// Number of entries in each row |
---|
253 | virtual inline CoinSimplexInt * numberInRow() const |
---|
254 | { return numberInRow_.array();} |
---|
255 | /// Number of entries in each column |
---|
256 | virtual inline CoinSimplexInt * numberInColumn() const |
---|
257 | { return numberInColumn_.array();} |
---|
258 | /// Returns array to put basis elements in |
---|
259 | virtual inline CoinFactorizationDouble * elements() const |
---|
260 | { return elementU_.array();} |
---|
261 | /// Start of columns for R |
---|
262 | inline CoinBigIndex * startColumnR() const |
---|
263 | {return reinterpret_cast<CoinBigIndex *>(firstCount_.array()+3*numberRows_+4);} |
---|
264 | /// Elements of U |
---|
265 | inline CoinFactorizationDouble * elementU() const |
---|
266 | { return elementU_.array();} |
---|
267 | /// Row indices of U |
---|
268 | inline CoinSimplexInt * indexRowU() const |
---|
269 | { return indexRowU_.array();} |
---|
270 | /// Start of each column in U |
---|
271 | inline CoinBigIndex * startColumnU() const |
---|
272 | { return startColumnU_.array();} |
---|
273 | #if COIN_BIG_DOUBLE==1 |
---|
274 | /// To a work array and associate vector |
---|
275 | void toLongArray(CoinIndexedVector * vector,int which) const; |
---|
276 | /// From a work array and dis-associate vector |
---|
277 | void fromLongArray(CoinIndexedVector * vector) const; |
---|
278 | /// From a work array and dis-associate vector |
---|
279 | void fromLongArray(int which) const; |
---|
280 | /// Returns long double * associated with vector |
---|
281 | long double * denseVector(CoinIndexedVector * vector) const; |
---|
282 | /// Returns long double * associated with vector |
---|
283 | long double * denseVector(CoinIndexedVector & vector) const; |
---|
284 | /// Returns long double * associated with vector |
---|
285 | const long double * denseVector(const CoinIndexedVector * vector) const; |
---|
286 | /// Returns long double * associated with vector |
---|
287 | const long double * denseVector(const CoinIndexedVector & vector) const; |
---|
288 | /// Scans region to find nonzeros |
---|
289 | void scan(CoinIndexedVector * vector) const; |
---|
290 | /// Clear all hidden arrays |
---|
291 | void clearHiddenArrays(); |
---|
292 | #else |
---|
293 | /// Returns double * associated with vector |
---|
294 | inline double * denseVector(CoinIndexedVector * vector) const |
---|
295 | {return vector->denseVector();} |
---|
296 | inline double * denseVector(CoinIndexedVector & vector) const |
---|
297 | {return vector.denseVector();} |
---|
298 | /// Returns double * associated with vector |
---|
299 | inline const double * denseVector(const CoinIndexedVector * vector) const |
---|
300 | {return vector->denseVector();} |
---|
301 | inline const double * denseVector(const CoinIndexedVector & vector) const |
---|
302 | {return vector.denseVector();} |
---|
303 | /// To a work array and associate vector |
---|
304 | inline void toLongArray(CoinIndexedVector * vector,int which) const {} |
---|
305 | /// From a work array and dis-associate vector |
---|
306 | inline void fromLongArray(CoinIndexedVector * vector) const {} |
---|
307 | /// From a work array and dis-associate vector |
---|
308 | inline void fromLongArray(int which) const {} |
---|
309 | /// Scans region to find nonzeros |
---|
310 | inline void scan(CoinIndexedVector * vector) const |
---|
311 | {vector->scan(0,numberRows_,zeroTolerance_);} |
---|
312 | #endif |
---|
313 | #ifdef ABC_ORDERED_FACTORIZATION |
---|
314 | /// Permute in for Ftran |
---|
315 | void permuteInForFtran(CoinIndexedVector & regionSparse,bool full=false) const ; |
---|
316 | /// Permute in for Btran and multiply by pivot Region |
---|
317 | void permuteInForBtranAndMultiply(CoinIndexedVector & regionSparse, bool full=false) const ; |
---|
318 | /// Permute out for Btran |
---|
319 | void permuteOutForBtran(CoinIndexedVector & regionSparse) const ; |
---|
320 | #endif |
---|
321 | /** Array persistence flag |
---|
322 | If 0 then as now (delete/new) |
---|
323 | 1 then only do arrays if bigger needed |
---|
324 | 2 as 1 but give a bit extra if bigger needed |
---|
325 | */ |
---|
326 | //inline CoinSimplexInt persistenceFlag() const |
---|
327 | //{ return persistenceFlag_;} |
---|
328 | //@} |
---|
329 | |
---|
330 | /**@name rank one updates which do exist */ |
---|
331 | //@{ |
---|
332 | #if 0 |
---|
333 | /** Checks if can replace one Column to basis, |
---|
334 | returns 0=OK, 1=Probably OK, 2=singular, 3=no room, 5 max pivots |
---|
335 | Fills in region for use later |
---|
336 | partial update already in U */ |
---|
337 | virtual int checkReplace ( const AbcSimplex * model, |
---|
338 | CoinIndexedVector * regionSparse, |
---|
339 | int pivotRow, |
---|
340 | CoinSimplexDouble & pivotCheck, |
---|
341 | double acceptablePivot = 1.0e-8); |
---|
342 | /** Replaces one Column to basis, |
---|
343 | returns 0=OK, 1=Probably OK, 2=singular, 3=no room |
---|
344 | If skipBtranU is false will do btran part |
---|
345 | partial update already in U */ |
---|
346 | virtual CoinSimplexInt replaceColumn ( CoinIndexedVector * regionSparse, |
---|
347 | CoinSimplexInt pivotRow, |
---|
348 | CoinSimplexDouble pivotCheck , |
---|
349 | bool skipBtranU=false, |
---|
350 | CoinSimplexDouble acceptablePivot=1.0e-8); |
---|
351 | #endif |
---|
352 | /** Checks if can replace one Column to basis, |
---|
353 | returns update alpha |
---|
354 | Fills in region for use later |
---|
355 | partial update already in U */ |
---|
356 | virtual |
---|
357 | #ifdef ABC_LONG_FACTORIZATION |
---|
358 | long |
---|
359 | #endif |
---|
360 | double checkReplacePart1 ( CoinIndexedVector * regionSparse, |
---|
361 | int pivotRow); |
---|
362 | /** Checks if can replace one Column to basis, |
---|
363 | returns update alpha |
---|
364 | Fills in region for use later |
---|
365 | partial update in vector */ |
---|
366 | virtual |
---|
367 | #ifdef ABC_LONG_FACTORIZATION |
---|
368 | long |
---|
369 | #endif |
---|
370 | double checkReplacePart1 ( CoinIndexedVector * regionSparse, |
---|
371 | CoinIndexedVector * partialUpdate, |
---|
372 | int pivotRow); |
---|
373 | #ifdef MOVE_REPLACE_PART1A |
---|
374 | /** Checks if can replace one Column to basis, |
---|
375 | returns update alpha |
---|
376 | Fills in region for use later |
---|
377 | partial update already in U */ |
---|
378 | virtual void checkReplacePart1a ( CoinIndexedVector * regionSparse, |
---|
379 | int pivotRow); |
---|
380 | virtual |
---|
381 | #ifdef ABC_LONG_FACTORIZATION |
---|
382 | long |
---|
383 | #endif |
---|
384 | double checkReplacePart1b ( CoinIndexedVector * regionSparse, |
---|
385 | int pivotRow); |
---|
386 | #endif |
---|
387 | /** Checks if can replace one Column to basis, |
---|
388 | returns 0=OK, 1=Probably OK, 2=singular, 3=no room, 5 max pivots */ |
---|
389 | virtual int checkReplacePart2 ( int pivotRow, |
---|
390 | CoinSimplexDouble btranAlpha, |
---|
391 | double ftranAlpha, |
---|
392 | #ifdef ABC_LONG_FACTORIZATION |
---|
393 | long |
---|
394 | #endif |
---|
395 | double ftAlpha, |
---|
396 | double acceptablePivot = 1.0e-8); |
---|
397 | /** Replaces one Column to basis, |
---|
398 | partial update already in U */ |
---|
399 | virtual void replaceColumnPart3 ( const AbcSimplex * model, |
---|
400 | CoinIndexedVector * regionSparse, |
---|
401 | CoinIndexedVector * tableauColumn, |
---|
402 | int pivotRow, |
---|
403 | #ifdef ABC_LONG_FACTORIZATION |
---|
404 | long |
---|
405 | #endif |
---|
406 | double alpha ); |
---|
407 | /** Replaces one Column to basis, |
---|
408 | partial update in vector */ |
---|
409 | virtual void replaceColumnPart3 ( const AbcSimplex * model, |
---|
410 | CoinIndexedVector * regionSparse, |
---|
411 | CoinIndexedVector * tableauColumn, |
---|
412 | CoinIndexedVector * partialUpdate, |
---|
413 | int pivotRow, |
---|
414 | #ifdef ABC_LONG_FACTORIZATION |
---|
415 | long |
---|
416 | #endif |
---|
417 | double alpha ); |
---|
418 | #ifdef EARLY_FACTORIZE |
---|
419 | /// 0 success, -1 can't +1 accuracy problems |
---|
420 | virtual int replaceColumns ( const AbcSimplex * model, |
---|
421 | CoinIndexedVector & stuff, |
---|
422 | int firstPivot,int lastPivot,bool cleanUp); |
---|
423 | #endif |
---|
424 | /// Update partial Ftran by R update |
---|
425 | void updatePartialUpdate(CoinIndexedVector & partialUpdate); |
---|
426 | /// Returns true if wants tableauColumn in replaceColumn |
---|
427 | inline virtual bool wantsTableauColumn() const |
---|
428 | {return false;} |
---|
429 | /** Combines BtranU and store which elements are to be deleted |
---|
430 | returns number to be deleted |
---|
431 | */ |
---|
432 | int replaceColumnU ( CoinIndexedVector * regionSparse, |
---|
433 | CoinBigIndex * deletedPosition, |
---|
434 | CoinSimplexInt * deletedColumns, |
---|
435 | CoinSimplexInt pivotRow); |
---|
436 | //@} |
---|
437 | |
---|
438 | /**@name various uses of factorization (return code number elements) |
---|
439 | which user may want to know about */ |
---|
440 | /// Later take out return codes (apart from +- 1 on FT) |
---|
441 | //@{ |
---|
442 | /** Updates one column (FTRAN) from regionSparse2 |
---|
443 | Tries to do FT update |
---|
444 | number returned is negative if no room |
---|
445 | regionSparse starts as zero and is zero at end. |
---|
446 | Note - if regionSparse2 packed on input - will be packed on output |
---|
447 | */ |
---|
448 | virtual CoinSimplexInt updateColumnFT ( CoinIndexedVector & regionSparse); |
---|
449 | virtual int updateColumnFTPart1 ( CoinIndexedVector & regionSparse) ; |
---|
450 | virtual void updateColumnFTPart2 ( CoinIndexedVector & regionSparse) ; |
---|
451 | /** Updates one column (FTRAN) |
---|
452 | Tries to do FT update |
---|
453 | puts partial update in vector */ |
---|
454 | virtual void updateColumnFT ( CoinIndexedVector & regionSparseFT, |
---|
455 | CoinIndexedVector & partialUpdate, |
---|
456 | int which); |
---|
457 | /** This version has same effect as above with FTUpdate==false |
---|
458 | so number returned is always >=0 */ |
---|
459 | virtual CoinSimplexInt updateColumn ( CoinIndexedVector & regionSparse) const; |
---|
460 | /** Updates one column (FTRAN) from region2 |
---|
461 | Tries to do FT update |
---|
462 | number returned is negative if no room. |
---|
463 | Also updates region3 |
---|
464 | region1 starts as zero and is zero at end */ |
---|
465 | virtual CoinSimplexInt updateTwoColumnsFT ( CoinIndexedVector & regionFT, |
---|
466 | CoinIndexedVector & regionOther); |
---|
467 | /** Updates one column (BTRAN) from regionSparse2 |
---|
468 | regionSparse starts as zero and is zero at end |
---|
469 | Note - if regionSparse2 packed on input - will be packed on output |
---|
470 | */ |
---|
471 | virtual CoinSimplexInt updateColumnTranspose ( CoinIndexedVector & regionSparse) const; |
---|
472 | /** Updates one full column (FTRAN) */ |
---|
473 | virtual void updateFullColumn ( CoinIndexedVector & regionSparse) const; |
---|
474 | /** Updates one full column (BTRAN) */ |
---|
475 | virtual void updateFullColumnTranspose ( CoinIndexedVector & regionSparse) const; |
---|
476 | /** Updates one column for dual steepest edge weights (FTRAN) */ |
---|
477 | virtual void updateWeights ( CoinIndexedVector & regionSparse) const; |
---|
478 | /** Updates one column (FTRAN) */ |
---|
479 | virtual void updateColumnCpu ( CoinIndexedVector & regionSparse,int whichCpu) const; |
---|
480 | /** Updates one column (BTRAN) */ |
---|
481 | virtual void updateColumnTransposeCpu ( CoinIndexedVector & regionSparse,int whichCpu) const; |
---|
482 | void unpack ( CoinIndexedVector * regionFrom, |
---|
483 | CoinIndexedVector * regionTo) const; |
---|
484 | void pack ( CoinIndexedVector * regionFrom, |
---|
485 | CoinIndexedVector * regionTo) const; |
---|
486 | /** makes a row copy of L for speed and to allow very sparse problems */ |
---|
487 | inline void goSparse() {} |
---|
488 | void goSparse2(); |
---|
489 | #ifndef NDEBUG |
---|
490 | virtual void checkMarkArrays() const; |
---|
491 | #endif |
---|
492 | #if ABC_SMALL<2 |
---|
493 | /** get sparse threshold */ |
---|
494 | inline CoinSimplexInt sparseThreshold ( ) const |
---|
495 | { return sparseThreshold_;} |
---|
496 | #endif |
---|
497 | /** set sparse threshold */ |
---|
498 | void sparseThreshold ( CoinSimplexInt value ); |
---|
499 | //@} |
---|
500 | /// *** Below this user may not want to know about |
---|
501 | |
---|
502 | /**@name various uses of factorization (return code number elements) |
---|
503 | which user may not want to know about (left over from my LP code) */ |
---|
504 | //@{ |
---|
505 | /// Get rid of all memory |
---|
506 | inline void clearArrays() |
---|
507 | { gutsOfDestructor();} |
---|
508 | //@} |
---|
509 | /**@name used by ClpFactorization */ |
---|
510 | /// See if worth going sparse |
---|
511 | void checkSparse(); |
---|
512 | /// The real work of constructors etc 0 just scalars, 1 bit normal |
---|
513 | void gutsOfDestructor(CoinSimplexInt type=1); |
---|
514 | /// 1 bit - tolerances etc, 2 more, 4 dummy arrays |
---|
515 | void gutsOfInitialize(CoinSimplexInt type); |
---|
516 | void gutsOfCopy(const CoinAbcTypeFactorization &other); |
---|
517 | |
---|
518 | /// Reset all sparsity etc statistics |
---|
519 | void resetStatistics(); |
---|
520 | void printRegion(const CoinIndexedVector & vector, const char * where) const; |
---|
521 | |
---|
522 | //@} |
---|
523 | |
---|
524 | /**@name used by factorization */ |
---|
525 | /// Gets space for a factorization, called by constructors |
---|
526 | virtual void getAreas ( CoinSimplexInt numberRows, |
---|
527 | CoinSimplexInt numberColumns, |
---|
528 | CoinBigIndex maximumL, |
---|
529 | CoinBigIndex maximumU ); |
---|
530 | |
---|
531 | /// PreProcesses column ordered copy of basis |
---|
532 | virtual void preProcess ( ); |
---|
533 | void preProcess (CoinSimplexInt ); |
---|
534 | /// Return largest element |
---|
535 | double preProcess3 ( ); |
---|
536 | void preProcess4 ( ); |
---|
537 | /// Does most of factorization |
---|
538 | virtual CoinSimplexInt factor (AbcSimplex * model); |
---|
539 | #ifdef EARLY_FACTORIZE |
---|
540 | /// Returns -2 if can't, -1 if singular, -99 memory, 0 OK |
---|
541 | virtual int factorize (AbcSimplex * model, CoinIndexedVector & stuff); |
---|
542 | #endif |
---|
543 | /// Does post processing on valid factorization - putting variables on correct rows |
---|
544 | virtual void postProcess(const CoinSimplexInt * sequence, CoinSimplexInt * pivotVariable); |
---|
545 | /// Makes a non-singular basis by replacing variables |
---|
546 | virtual void makeNonSingular(CoinSimplexInt * sequence); |
---|
547 | protected: |
---|
548 | /** Does sparse phase of factorization |
---|
549 | return code is <0 error, 0= finished */ |
---|
550 | CoinSimplexInt factorSparse ( ); |
---|
551 | /** Does dense phase of factorization |
---|
552 | return code is <0 error, 0= finished */ |
---|
553 | CoinSimplexInt factorDense ( ); |
---|
554 | |
---|
555 | /// Pivots when just one other row so faster? |
---|
556 | bool pivotOneOtherRow ( CoinSimplexInt pivotRow, |
---|
557 | CoinSimplexInt pivotColumn ); |
---|
558 | /// Does one pivot on Row Singleton in factorization |
---|
559 | bool pivotRowSingleton ( CoinSimplexInt pivotRow, |
---|
560 | CoinSimplexInt pivotColumn ); |
---|
561 | /// Does one pivot on Column Singleton in factorization (can't return false) |
---|
562 | void pivotColumnSingleton ( CoinSimplexInt pivotRow, |
---|
563 | CoinSimplexInt pivotColumn ); |
---|
564 | /// After pivoting |
---|
565 | void afterPivot( CoinSimplexInt pivotRow, |
---|
566 | CoinSimplexInt pivotColumn ); |
---|
567 | /// After pivoting - returns true if need to go dense |
---|
568 | int wantToGoDense(); |
---|
569 | |
---|
570 | /** Gets space for one Column with given length, |
---|
571 | may have to do compression (returns True if successful), |
---|
572 | also moves existing vector, |
---|
573 | extraNeeded is over and above present */ |
---|
574 | bool getColumnSpace ( CoinSimplexInt iColumn, |
---|
575 | CoinSimplexInt extraNeeded ); |
---|
576 | |
---|
577 | /** Reorders U so contiguous and in order (if there is space) |
---|
578 | Returns true if it could */ |
---|
579 | bool reorderU(); |
---|
580 | /** getColumnSpaceIterateR. Gets space for one extra R element in Column |
---|
581 | may have to do compression (returns true) |
---|
582 | also moves existing vector */ |
---|
583 | bool getColumnSpaceIterateR ( CoinSimplexInt iColumn, CoinFactorizationDouble value, |
---|
584 | CoinSimplexInt iRow); |
---|
585 | /** getColumnSpaceIterate. Gets space for one extra U element in Column |
---|
586 | may have to do compression (returns true) |
---|
587 | also moves existing vector. |
---|
588 | Returns -1 if no memory or where element was put |
---|
589 | Used by replaceRow (turns off R version) */ |
---|
590 | CoinBigIndex getColumnSpaceIterate ( CoinSimplexInt iColumn, CoinFactorizationDouble value, |
---|
591 | CoinSimplexInt iRow); |
---|
592 | /** Gets space for one Row with given length, |
---|
593 | may have to do compression (returns True if successful), |
---|
594 | also moves existing vector */ |
---|
595 | bool getRowSpace ( CoinSimplexInt iRow, CoinSimplexInt extraNeeded ); |
---|
596 | |
---|
597 | /** Gets space for one Row with given length while iterating, |
---|
598 | may have to do compression (returns True if successful), |
---|
599 | also moves existing vector */ |
---|
600 | bool getRowSpaceIterate ( CoinSimplexInt iRow, |
---|
601 | CoinSimplexInt extraNeeded ); |
---|
602 | /// Checks that row and column copies look OK |
---|
603 | void checkConsistency ( ); |
---|
604 | //#define CHECK_LINKS |
---|
605 | #ifdef CHECK_LINKS |
---|
606 | void checkLinks(int x=0); |
---|
607 | #else |
---|
608 | # define checkLinks(x) |
---|
609 | #endif |
---|
610 | /// Adds a link in chain of equal counts |
---|
611 | inline void addLink ( CoinSimplexInt index, CoinSimplexInt count ) { |
---|
612 | CoinSimplexInt * COIN_RESTRICT nextCount = nextCountAddress_; |
---|
613 | CoinSimplexInt * COIN_RESTRICT firstCount = this->firstCount(); |
---|
614 | CoinSimplexInt * COIN_RESTRICT lastCount = lastCountAddress_; |
---|
615 | CoinSimplexInt next = firstCount[count]; |
---|
616 | firstCount[count] = index; |
---|
617 | nextCount[index] = next; |
---|
618 | lastCount[index] = count-numberRows_-2; // points to firstCount[count] |
---|
619 | if (next>=0) |
---|
620 | lastCount[next] = index; |
---|
621 | } |
---|
622 | /// Deletes a link in chain of equal counts |
---|
623 | inline void deleteLink ( CoinSimplexInt index ) { |
---|
624 | CoinSimplexInt * COIN_RESTRICT nextCount = nextCountAddress_; |
---|
625 | CoinSimplexInt * COIN_RESTRICT lastCount = lastCountAddress_; |
---|
626 | CoinSimplexInt next = nextCount[index]; |
---|
627 | CoinSimplexInt last = lastCount[index]; |
---|
628 | assert (next!=index); |
---|
629 | assert (last!=index); |
---|
630 | if (next>=0) |
---|
631 | lastCount[next] = last; |
---|
632 | if (last>=0) { |
---|
633 | nextCount[last] = next; |
---|
634 | } else { |
---|
635 | int count=last+numberRows_+2; |
---|
636 | CoinSimplexInt * COIN_RESTRICT firstCount = this->firstCount(); |
---|
637 | firstCount[count]=next; |
---|
638 | } |
---|
639 | } |
---|
640 | /// Modifies links in chain of equal counts |
---|
641 | inline void modifyLink ( CoinSimplexInt index, CoinSimplexInt count ) { |
---|
642 | CoinSimplexInt * COIN_RESTRICT nextCount = nextCountAddress_; |
---|
643 | CoinSimplexInt * COIN_RESTRICT lastCount = lastCountAddress_; |
---|
644 | CoinSimplexInt * COIN_RESTRICT firstCount = this->firstCount(); |
---|
645 | CoinSimplexInt next2 = firstCount[count]; |
---|
646 | if (next2==index) |
---|
647 | return; |
---|
648 | firstCount[count] = index; |
---|
649 | CoinSimplexInt next = nextCount[index]; |
---|
650 | CoinSimplexInt last = lastCount[index]; |
---|
651 | assert (next!=index); |
---|
652 | assert (last!=index); |
---|
653 | nextCount[index] = next2; |
---|
654 | lastCount[index] = count-numberRows_-2; // points to firstCount[count] |
---|
655 | if (next>=0) |
---|
656 | lastCount[next] = last; |
---|
657 | if (next2>=0) |
---|
658 | lastCount[next2] = index; |
---|
659 | if (last>=0) { |
---|
660 | nextCount[last] = next; |
---|
661 | } else { |
---|
662 | int count=last+numberRows_+2; |
---|
663 | firstCount[count]=next; |
---|
664 | } |
---|
665 | } |
---|
666 | /// Separate out links with same row/column count |
---|
667 | void separateLinks(); |
---|
668 | void separateLinks(CoinSimplexInt,CoinSimplexInt); |
---|
669 | /// Cleans up at end of factorization |
---|
670 | void cleanup ( ); |
---|
671 | /// Set up addresses from arrays |
---|
672 | void doAddresses(); |
---|
673 | |
---|
674 | /// Updates part of column (FTRANL) |
---|
675 | void updateColumnL ( CoinIndexedVector * region |
---|
676 | #if ABC_SMALL<2 |
---|
677 | , CoinAbcStatistics & statistics |
---|
678 | #endif |
---|
679 | #if ABC_PARALLEL |
---|
680 | ,int whichSparse=0 |
---|
681 | #endif |
---|
682 | ) const; |
---|
683 | /// Updates part of column (FTRANL) when densish |
---|
684 | void updateColumnLDensish ( CoinIndexedVector * region ) const; |
---|
685 | /// Updates part of column (FTRANL) when dense (i.e. do as inner products) |
---|
686 | void updateColumnLDense ( CoinIndexedVector * region ) const; |
---|
687 | /// Updates part of column (FTRANL) when sparse |
---|
688 | void updateColumnLSparse ( CoinIndexedVector * region |
---|
689 | #if ABC_PARALLEL |
---|
690 | ,int whichSparse |
---|
691 | #endif |
---|
692 | ) const; |
---|
693 | |
---|
694 | /// Updates part of column (FTRANR) without FT update |
---|
695 | void updateColumnR ( CoinIndexedVector * region |
---|
696 | #if ABC_SMALL<2 |
---|
697 | , CoinAbcStatistics & statistics |
---|
698 | #endif |
---|
699 | #if ABC_PARALLEL |
---|
700 | ,int whichSparse=0 |
---|
701 | #endif |
---|
702 | ) const; |
---|
703 | /// Store update after doing L and R - retuns false if no room |
---|
704 | bool storeFT( |
---|
705 | #if ABC_SMALL<3 |
---|
706 | const |
---|
707 | #endif |
---|
708 | CoinIndexedVector * regionFT); |
---|
709 | /// Updates part of column (FTRANU) |
---|
710 | void updateColumnU ( CoinIndexedVector * region |
---|
711 | #if ABC_SMALL<2 |
---|
712 | , CoinAbcStatistics & statistics |
---|
713 | #endif |
---|
714 | #if ABC_PARALLEL |
---|
715 | ,int whichSparse=0 |
---|
716 | #endif |
---|
717 | ) const; |
---|
718 | |
---|
719 | /// Updates part of column (FTRANU) when sparse |
---|
720 | void updateColumnUSparse ( CoinIndexedVector * regionSparse |
---|
721 | #if ABC_PARALLEL |
---|
722 | ,int whichSparse |
---|
723 | #endif |
---|
724 | ) const; |
---|
725 | /// Updates part of column (FTRANU) |
---|
726 | void updateColumnUDensish ( CoinIndexedVector * regionSparse) const; |
---|
727 | /// Updates part of column (FTRANU) when dense (i.e. do as inner products) |
---|
728 | void updateColumnUDense ( CoinIndexedVector * regionSparse) const; |
---|
729 | /// Updates part of 2 columns (FTRANU) real work |
---|
730 | void updateTwoColumnsUDensish ( |
---|
731 | CoinSimplexInt & numberNonZero1, |
---|
732 | CoinFactorizationDouble * COIN_RESTRICT region1, |
---|
733 | CoinSimplexInt * COIN_RESTRICT index1, |
---|
734 | CoinSimplexInt & numberNonZero2, |
---|
735 | CoinFactorizationDouble * COIN_RESTRICT region2, |
---|
736 | CoinSimplexInt * COIN_RESTRICT index2) const; |
---|
737 | /// Updates part of column PFI (FTRAN) (after rest) |
---|
738 | void updateColumnPFI ( CoinIndexedVector * regionSparse) const; |
---|
739 | /// Updates part of column transpose PFI (BTRAN) (before rest) |
---|
740 | void updateColumnTransposePFI ( CoinIndexedVector * region) const; |
---|
741 | /** Updates part of column transpose (BTRANU), |
---|
742 | assumes index is sorted i.e. region is correct */ |
---|
743 | void updateColumnTransposeU ( CoinIndexedVector * region, |
---|
744 | CoinSimplexInt smallestIndex |
---|
745 | #if ABC_SMALL<2 |
---|
746 | , CoinAbcStatistics & statistics |
---|
747 | #endif |
---|
748 | #if ABC_PARALLEL |
---|
749 | ,int whichCpu |
---|
750 | #endif |
---|
751 | ) const; |
---|
752 | /** Updates part of column transpose (BTRANU) when densish, |
---|
753 | assumes index is sorted i.e. region is correct */ |
---|
754 | void updateColumnTransposeUDensish ( CoinIndexedVector * region, |
---|
755 | CoinSimplexInt smallestIndex) const; |
---|
756 | /** Updates part of column transpose (BTRANU) when sparse, |
---|
757 | assumes index is sorted i.e. region is correct */ |
---|
758 | void updateColumnTransposeUSparse ( CoinIndexedVector * region |
---|
759 | #if ABC_PARALLEL |
---|
760 | ,int whichSparse |
---|
761 | #endif |
---|
762 | ) const; |
---|
763 | /** Updates part of column transpose (BTRANU) by column |
---|
764 | assumes index is sorted i.e. region is correct */ |
---|
765 | void updateColumnTransposeUByColumn ( CoinIndexedVector * region, |
---|
766 | CoinSimplexInt smallestIndex) const; |
---|
767 | |
---|
768 | /// Updates part of column transpose (BTRANR) |
---|
769 | void updateColumnTransposeR ( CoinIndexedVector * region |
---|
770 | #if ABC_SMALL<2 |
---|
771 | , CoinAbcStatistics & statistics |
---|
772 | #endif |
---|
773 | ) const; |
---|
774 | /// Updates part of column transpose (BTRANR) when dense |
---|
775 | void updateColumnTransposeRDensish ( CoinIndexedVector * region ) const; |
---|
776 | /// Updates part of column transpose (BTRANR) when sparse |
---|
777 | void updateColumnTransposeRSparse ( CoinIndexedVector * region ) const; |
---|
778 | |
---|
779 | /// Updates part of column transpose (BTRANL) |
---|
780 | void updateColumnTransposeL ( CoinIndexedVector * region |
---|
781 | #if ABC_SMALL<2 |
---|
782 | , CoinAbcStatistics & statistics |
---|
783 | #endif |
---|
784 | #if ABC_PARALLEL |
---|
785 | ,int whichSparse |
---|
786 | #endif |
---|
787 | ) const; |
---|
788 | /// Updates part of column transpose (BTRANL) when densish by column |
---|
789 | void updateColumnTransposeLDensish ( CoinIndexedVector * region ) const; |
---|
790 | /// Updates part of column transpose (BTRANL) when densish by row |
---|
791 | void updateColumnTransposeLByRow ( CoinIndexedVector * region ) const; |
---|
792 | /// Updates part of column transpose (BTRANL) when sparse (by Row) |
---|
793 | void updateColumnTransposeLSparse ( CoinIndexedVector * region |
---|
794 | #if ABC_PARALLEL |
---|
795 | ,int whichSparse |
---|
796 | #endif |
---|
797 | ) const; |
---|
798 | public: |
---|
799 | /** Replaces one Column to basis for PFI |
---|
800 | returns 0=OK, 1=Probably OK, 2=singular, 3=no room. |
---|
801 | In this case region is not empty - it is incoming variable (updated) |
---|
802 | */ |
---|
803 | CoinSimplexInt replaceColumnPFI ( CoinIndexedVector * regionSparse, |
---|
804 | CoinSimplexInt pivotRow, CoinSimplexDouble alpha); |
---|
805 | protected: |
---|
806 | /** Returns accuracy status of replaceColumn |
---|
807 | returns 0=OK, 1=Probably OK, 2=singular */ |
---|
808 | CoinSimplexInt checkPivot(CoinSimplexDouble saveFromU, CoinSimplexDouble oldPivot) const; |
---|
809 | /// 0 fine, -99 singular, 2 dense |
---|
810 | int pivot ( CoinSimplexInt pivotRow, |
---|
811 | CoinSimplexInt pivotColumn, |
---|
812 | CoinBigIndex pivotRowPosition, |
---|
813 | CoinBigIndex pivotColumnPosition, |
---|
814 | CoinFactorizationDouble * COIN_RESTRICT work, |
---|
815 | CoinSimplexUnsignedInt * COIN_RESTRICT workArea2, |
---|
816 | CoinSimplexInt increment2, |
---|
817 | int * COIN_RESTRICT markRow ); |
---|
818 | int pivot ( CoinSimplexInt & pivotRow, |
---|
819 | CoinSimplexInt & pivotColumn, |
---|
820 | CoinBigIndex pivotRowPosition, |
---|
821 | CoinBigIndex pivotColumnPosition, |
---|
822 | int * COIN_RESTRICT markRow ); |
---|
823 | #if ABC_SMALL<2 |
---|
824 | #define CONVERTROW 2 |
---|
825 | #elif ABC_SMALL<4 |
---|
826 | #else |
---|
827 | #undef ABC_DENSE_CODE |
---|
828 | #define ABC_DENSE_CODE 0 |
---|
829 | #endif |
---|
830 | |
---|
831 | //@} |
---|
832 | ////////////////// data ////////////////// |
---|
833 | protected: |
---|
834 | |
---|
835 | /**@name data */ |
---|
836 | //@{ |
---|
837 | CoinSimplexInt * pivotColumnAddress_; |
---|
838 | CoinSimplexInt * permuteAddress_; |
---|
839 | CoinFactorizationDouble * pivotRegionAddress_; |
---|
840 | CoinFactorizationDouble * elementUAddress_; |
---|
841 | CoinSimplexInt * indexRowUAddress_; |
---|
842 | CoinSimplexInt * numberInColumnAddress_; |
---|
843 | CoinSimplexInt * numberInColumnPlusAddress_; |
---|
844 | #ifdef ABC_USE_FUNCTION_POINTERS |
---|
845 | /// Array of function pointers |
---|
846 | scatterStruct * scatterPointersUColumnAddress_; |
---|
847 | CoinFactorizationDouble * elementUColumnPlusAddress_; |
---|
848 | #endif |
---|
849 | CoinBigIndex * startColumnUAddress_; |
---|
850 | #if CONVERTROW |
---|
851 | CoinBigIndex * convertRowToColumnUAddress_; |
---|
852 | #if CONVERTROW>1 |
---|
853 | CoinBigIndex * convertColumnToRowUAddress_; |
---|
854 | #endif |
---|
855 | #endif |
---|
856 | #if ABC_SMALL<2 |
---|
857 | CoinFactorizationDouble * elementRowUAddress_; |
---|
858 | #endif |
---|
859 | CoinBigIndex * startRowUAddress_; |
---|
860 | CoinSimplexInt * numberInRowAddress_; |
---|
861 | CoinSimplexInt * indexColumnUAddress_; |
---|
862 | CoinSimplexInt * firstCountAddress_; |
---|
863 | /// Next Row/Column with count |
---|
864 | CoinSimplexInt * nextCountAddress_; |
---|
865 | /// Previous Row/Column with count |
---|
866 | CoinSimplexInt * lastCountAddress_; |
---|
867 | CoinSimplexInt * nextColumnAddress_; |
---|
868 | CoinSimplexInt * lastColumnAddress_; |
---|
869 | CoinSimplexInt * nextRowAddress_; |
---|
870 | CoinSimplexInt * lastRowAddress_; |
---|
871 | CoinSimplexInt * saveColumnAddress_; |
---|
872 | //CoinSimplexInt * saveColumnAddress2_; |
---|
873 | CoinCheckZero * markRowAddress_; |
---|
874 | CoinSimplexInt * listAddress_; |
---|
875 | CoinFactorizationDouble * elementLAddress_; |
---|
876 | CoinSimplexInt * indexRowLAddress_; |
---|
877 | CoinBigIndex * startColumnLAddress_; |
---|
878 | #if ABC_SMALL<2 |
---|
879 | CoinBigIndex * startRowLAddress_; |
---|
880 | #endif |
---|
881 | CoinSimplexInt * pivotLinkedBackwardsAddress_; |
---|
882 | CoinSimplexInt * pivotLinkedForwardsAddress_; |
---|
883 | CoinSimplexInt * pivotLOrderAddress_; |
---|
884 | CoinBigIndex * startColumnRAddress_; |
---|
885 | /// Elements of R |
---|
886 | CoinFactorizationDouble *elementRAddress_; |
---|
887 | /// Row indices for R |
---|
888 | CoinSimplexInt *indexRowRAddress_; |
---|
889 | CoinSimplexInt * indexColumnLAddress_; |
---|
890 | CoinFactorizationDouble * elementByRowLAddress_; |
---|
891 | #if ABC_SMALL<4 |
---|
892 | CoinFactorizationDouble * denseAreaAddress_; |
---|
893 | #endif |
---|
894 | CoinFactorizationDouble * workAreaAddress_; |
---|
895 | CoinSimplexUnsignedInt * workArea2Address_; |
---|
896 | mutable CoinSimplexInt * sparseAddress_; |
---|
897 | #ifdef SMALL_PERMUTE |
---|
898 | CoinSimplexInt * fromSmallToBigRow_; |
---|
899 | CoinSimplexInt * fromSmallToBigColumn_; |
---|
900 | #endif |
---|
901 | /// Number of Rows after iterating |
---|
902 | CoinSimplexInt numberRowsExtra_; |
---|
903 | /// Maximum number of Rows after iterating |
---|
904 | CoinSimplexInt maximumRowsExtra_; |
---|
905 | /// Size of small inverse |
---|
906 | CoinSimplexInt numberRowsSmall_; |
---|
907 | /// Number factorized in L |
---|
908 | CoinSimplexInt numberGoodL_; |
---|
909 | /// Number Rows left (numberRows-numberGood) |
---|
910 | CoinSimplexInt numberRowsLeft_; |
---|
911 | /// Number of elements in U (to go) |
---|
912 | /// or while iterating total overall |
---|
913 | CoinBigIndex totalElements_; |
---|
914 | /// First place in funny copy zeroed out |
---|
915 | CoinBigIndex firstZeroed_; |
---|
916 | #if ABC_SMALL<2 |
---|
917 | /// Below this use sparse technology - if 0 then no L row copy |
---|
918 | CoinSimplexInt sparseThreshold_; |
---|
919 | #endif |
---|
920 | /// Number in R |
---|
921 | CoinSimplexInt numberR_; |
---|
922 | /// Length of R stuff |
---|
923 | CoinBigIndex lengthR_; |
---|
924 | /// length of area reserved for R |
---|
925 | CoinBigIndex lengthAreaR_; |
---|
926 | /// Number in L |
---|
927 | CoinBigIndex numberL_; |
---|
928 | /// Base of L |
---|
929 | CoinBigIndex baseL_; |
---|
930 | /// Length of L |
---|
931 | CoinBigIndex lengthL_; |
---|
932 | /// Length of area reserved for L |
---|
933 | CoinBigIndex lengthAreaL_; |
---|
934 | /// Number in U |
---|
935 | CoinSimplexInt numberU_; |
---|
936 | /// Maximum space used in U |
---|
937 | CoinBigIndex maximumU_; |
---|
938 | /// Length of U |
---|
939 | CoinBigIndex lengthU_; |
---|
940 | /// Length of area reserved for U |
---|
941 | CoinBigIndex lengthAreaU_; |
---|
942 | /// Last entry by column for U |
---|
943 | CoinBigIndex lastEntryByColumnU_; |
---|
944 | #ifdef ABC_USE_FUNCTION_POINTERS |
---|
945 | /// Last entry by column for U |
---|
946 | CoinBigIndex lastEntryByColumnUPlus_; |
---|
947 | /// Length of U |
---|
948 | CoinBigIndex lengthAreaUPlus_; |
---|
949 | #endif |
---|
950 | /// Last entry by row for U |
---|
951 | CoinBigIndex lastEntryByRowU_; |
---|
952 | /// Number of trials before rejection |
---|
953 | CoinSimplexInt numberTrials_; |
---|
954 | #if ABC_SMALL<4 |
---|
955 | /// Leading dimension for dense |
---|
956 | CoinSimplexInt leadingDimension_; |
---|
957 | #endif |
---|
958 | #if COIN_BIG_DOUBLE==1 |
---|
959 | /// Work arrays |
---|
960 | mutable CoinFactorizationLongDoubleArrayWithLength longArray_[FACTOR_CPU]; |
---|
961 | /// Associated CoinIndexedVector |
---|
962 | mutable CoinIndexedVector * associatedVector_[FACTOR_CPU]; |
---|
963 | #endif |
---|
964 | /// Pivot order for each Column |
---|
965 | CoinIntArrayWithLength pivotColumn_; |
---|
966 | /// Permutation vector for pivot row order |
---|
967 | CoinIntArrayWithLength permute_; |
---|
968 | /// Start of each Row as pointer |
---|
969 | CoinBigIndexArrayWithLength startRowU_; |
---|
970 | /// Number in each Row |
---|
971 | CoinIntArrayWithLength numberInRow_; |
---|
972 | /// Number in each Column |
---|
973 | CoinIntArrayWithLength numberInColumn_; |
---|
974 | /// Number in each Column including pivoted |
---|
975 | CoinIntArrayWithLength numberInColumnPlus_; |
---|
976 | /** First Row/Column with count of k, |
---|
977 | can tell which by offset - Rows then Columns */ |
---|
978 | CoinIntArrayWithLength firstCount_; |
---|
979 | /// Next Column in memory order |
---|
980 | CoinIntArrayWithLength nextColumn_; |
---|
981 | /// Previous Column in memory order |
---|
982 | CoinIntArrayWithLength lastColumn_; |
---|
983 | /// Next Row in memory order |
---|
984 | CoinIntArrayWithLength nextRow_; |
---|
985 | /// Previous Row in memory order |
---|
986 | CoinIntArrayWithLength lastRow_; |
---|
987 | /// Columns left to do in a single pivot |
---|
988 | CoinIntArrayWithLength saveColumn_; |
---|
989 | /// Marks rows to be updated |
---|
990 | CoinIntArrayWithLength markRow_; |
---|
991 | /// Base address for U (may change) |
---|
992 | CoinIntArrayWithLength indexColumnU_; |
---|
993 | /// Inverses of pivot values |
---|
994 | CoinFactorizationDoubleArrayWithLength pivotRegion_; |
---|
995 | /// Elements of U |
---|
996 | CoinFactorizationDoubleArrayWithLength elementU_; |
---|
997 | /// Row indices of U |
---|
998 | CoinIntArrayWithLength indexRowU_; |
---|
999 | /// Start of each column in U |
---|
1000 | CoinBigIndexArrayWithLength startColumnU_; |
---|
1001 | #ifdef ABC_USE_FUNCTION_POINTERS |
---|
1002 | /// Array of structs for U Column |
---|
1003 | CoinArbitraryArrayWithLength scatterUColumn_; |
---|
1004 | #endif |
---|
1005 | #if CONVERTROW |
---|
1006 | /// Converts rows to columns in U |
---|
1007 | CoinBigIndexArrayWithLength convertRowToColumnU_; |
---|
1008 | #if CONVERTROW>1 |
---|
1009 | /// Converts columns to rows in U |
---|
1010 | CoinBigIndexArrayWithLength convertColumnToRowU_; |
---|
1011 | #endif |
---|
1012 | #endif |
---|
1013 | #if ABC_SMALL<2 |
---|
1014 | /// Elements of U by row |
---|
1015 | CoinFactorizationDoubleArrayWithLength elementRowU_; |
---|
1016 | #endif |
---|
1017 | /// Elements of L |
---|
1018 | CoinFactorizationDoubleArrayWithLength elementL_; |
---|
1019 | /// Row indices of L |
---|
1020 | CoinIntArrayWithLength indexRowL_; |
---|
1021 | /// Start of each column in L |
---|
1022 | CoinBigIndexArrayWithLength startColumnL_; |
---|
1023 | #if ABC_SMALL<4 |
---|
1024 | /// Dense area |
---|
1025 | CoinFactorizationDoubleArrayWithLength denseArea_; |
---|
1026 | #endif |
---|
1027 | /// First work area |
---|
1028 | CoinFactorizationDoubleArrayWithLength workArea_; |
---|
1029 | /// Second work area |
---|
1030 | CoinUnsignedIntArrayWithLength workArea2_; |
---|
1031 | #if ABC_SMALL<2 |
---|
1032 | /// Start of each row in L |
---|
1033 | CoinBigIndexArrayWithLength startRowL_; |
---|
1034 | /// Index of column in row for L |
---|
1035 | CoinIntArrayWithLength indexColumnL_; |
---|
1036 | /// Elements in L (row copy) |
---|
1037 | CoinFactorizationDoubleArrayWithLength elementByRowL_; |
---|
1038 | /// Sparse regions |
---|
1039 | mutable CoinIntArrayWithLength sparse_; |
---|
1040 | #endif |
---|
1041 | /// Detail in messages |
---|
1042 | CoinSimplexInt messageLevel_; |
---|
1043 | /// Number of compressions done |
---|
1044 | CoinBigIndex numberCompressions_; |
---|
1045 | // last slack pivot row |
---|
1046 | CoinSimplexInt lastSlack_; |
---|
1047 | #if ABC_SMALL<2 |
---|
1048 | /// To decide how to solve |
---|
1049 | mutable double ftranCountInput_; |
---|
1050 | mutable double ftranCountAfterL_; |
---|
1051 | mutable double ftranCountAfterR_; |
---|
1052 | mutable double ftranCountAfterU_; |
---|
1053 | double ftranAverageAfterL_; |
---|
1054 | double ftranAverageAfterR_; |
---|
1055 | double ftranAverageAfterU_; |
---|
1056 | #if FACTORIZATION_STATISTICS |
---|
1057 | double ftranTwiddleFactor1_; |
---|
1058 | double ftranTwiddleFactor2_; |
---|
1059 | #endif |
---|
1060 | mutable CoinSimplexInt numberFtranCounts_; |
---|
1061 | #endif |
---|
1062 | /// Maximum rows (ever) (here to use double alignment) |
---|
1063 | CoinSimplexInt maximumRows_; |
---|
1064 | #if ABC_SMALL<2 |
---|
1065 | mutable double ftranFTCountInput_; |
---|
1066 | mutable double ftranFTCountAfterL_; |
---|
1067 | mutable double ftranFTCountAfterR_; |
---|
1068 | mutable double ftranFTCountAfterU_; |
---|
1069 | double ftranFTAverageAfterL_; |
---|
1070 | double ftranFTAverageAfterR_; |
---|
1071 | double ftranFTAverageAfterU_; |
---|
1072 | #if FACTORIZATION_STATISTICS |
---|
1073 | double ftranFTTwiddleFactor1_; |
---|
1074 | double ftranFTTwiddleFactor2_; |
---|
1075 | #endif |
---|
1076 | mutable CoinSimplexInt numberFtranFTCounts_; |
---|
1077 | #endif |
---|
1078 | #if ABC_SMALL<4 |
---|
1079 | /// Dense threshold (here to use double alignment) |
---|
1080 | CoinSimplexInt denseThreshold_; |
---|
1081 | #endif |
---|
1082 | #if ABC_SMALL<2 |
---|
1083 | mutable double btranCountInput_; |
---|
1084 | mutable double btranCountAfterU_; |
---|
1085 | mutable double btranCountAfterR_; |
---|
1086 | mutable double btranCountAfterL_; |
---|
1087 | double btranAverageAfterU_; |
---|
1088 | double btranAverageAfterR_; |
---|
1089 | double btranAverageAfterL_; |
---|
1090 | #if FACTORIZATION_STATISTICS |
---|
1091 | double btranTwiddleFactor1_; |
---|
1092 | double btranTwiddleFactor2_; |
---|
1093 | #endif |
---|
1094 | mutable CoinSimplexInt numberBtranCounts_; |
---|
1095 | #endif |
---|
1096 | /// Maximum maximum pivots |
---|
1097 | CoinSimplexInt maximumMaximumPivots_; |
---|
1098 | #if ABC_SMALL<2 |
---|
1099 | /// To decide how to solve |
---|
1100 | mutable double ftranFullCountInput_; |
---|
1101 | mutable double ftranFullCountAfterL_; |
---|
1102 | mutable double ftranFullCountAfterR_; |
---|
1103 | mutable double ftranFullCountAfterU_; |
---|
1104 | double ftranFullAverageAfterL_; |
---|
1105 | double ftranFullAverageAfterR_; |
---|
1106 | double ftranFullAverageAfterU_; |
---|
1107 | #if FACTORIZATION_STATISTICS |
---|
1108 | double ftranFullTwiddleFactor1_; |
---|
1109 | double ftranFullTwiddleFactor2_; |
---|
1110 | #endif |
---|
1111 | mutable CoinSimplexInt numberFtranFullCounts_; |
---|
1112 | #endif |
---|
1113 | /// Rows first time nonzero |
---|
1114 | CoinSimplexInt initialNumberRows_; |
---|
1115 | #if ABC_SMALL<2 |
---|
1116 | /// To decide how to solve |
---|
1117 | mutable double btranFullCountInput_; |
---|
1118 | mutable double btranFullCountAfterL_; |
---|
1119 | mutable double btranFullCountAfterR_; |
---|
1120 | mutable double btranFullCountAfterU_; |
---|
1121 | double btranFullAverageAfterL_; |
---|
1122 | double btranFullAverageAfterR_; |
---|
1123 | double btranFullAverageAfterU_; |
---|
1124 | #if FACTORIZATION_STATISTICS |
---|
1125 | double btranFullTwiddleFactor1_; |
---|
1126 | double btranFullTwiddleFactor2_; |
---|
1127 | #endif |
---|
1128 | mutable CoinSimplexInt numberBtranFullCounts_; |
---|
1129 | #endif |
---|
1130 | /** State of saved version and what can be done |
---|
1131 | 0 - nothing saved |
---|
1132 | 1 - saved and can go back to previous save by unwinding |
---|
1133 | 2 - saved - getting on for a full copy |
---|
1134 | higher bits - see ABC_FAC.... |
---|
1135 | */ |
---|
1136 | CoinSimplexInt state_; |
---|
1137 | /// Size in bytes of a sparseArray |
---|
1138 | CoinBigIndex sizeSparseArray_; |
---|
1139 | public: |
---|
1140 | #if ABC_SMALL<2 |
---|
1141 | #if ABC_SMALL>=0 |
---|
1142 | inline bool gotLCopy() const {return ((state_&ABC_FAC_GOT_LCOPY)!=0);} |
---|
1143 | inline void setNoGotLCopy() {state_ &= ~ABC_FAC_GOT_LCOPY;} |
---|
1144 | inline void setYesGotLCopy() {state_ |= ABC_FAC_GOT_LCOPY;} |
---|
1145 | inline bool gotRCopy() const {return ((state_&ABC_FAC_GOT_RCOPY)!=0);} |
---|
1146 | inline void setNoGotRCopy() {state_ &= ~ABC_FAC_GOT_RCOPY;} |
---|
1147 | inline void setYesGotRCopy() {state_ |= ABC_FAC_GOT_RCOPY;} |
---|
1148 | inline bool gotUCopy() const {return ((state_&ABC_FAC_GOT_UCOPY)!=0);} |
---|
1149 | inline void setNoGotUCopy() {state_ &= ~ABC_FAC_GOT_UCOPY;} |
---|
1150 | inline void setYesGotUCopy() {state_ |= ABC_FAC_GOT_UCOPY;} |
---|
1151 | inline bool gotSparse() const {return ((state_&ABC_FAC_GOT_SPARSE)!=0);} |
---|
1152 | inline void setNoGotSparse() {state_ &= ~ABC_FAC_GOT_SPARSE;} |
---|
1153 | inline void setYesGotSparse() {state_ |= ABC_FAC_GOT_SPARSE;} |
---|
1154 | #else |
---|
1155 | // force use of copies |
---|
1156 | inline bool gotLCopy() const {return true;} |
---|
1157 | inline void setNoGotLCopy() {} |
---|
1158 | inline void setYesGotLCopy() {} |
---|
1159 | inline bool gotRCopy() const {return true;} |
---|
1160 | inline void setNoGotRCopy() {} |
---|
1161 | inline void setYesGotRCopy() {} |
---|
1162 | inline bool gotUCopy() const {return true;} |
---|
1163 | inline void setNoGotUCopy() {} |
---|
1164 | inline void setYesGotUCopy() {} |
---|
1165 | inline bool gotSparse() const {return true;} |
---|
1166 | inline void setNoGotSparse() {} |
---|
1167 | inline void setYesGotSparse() {} |
---|
1168 | #endif |
---|
1169 | #else |
---|
1170 | // force no use of copies |
---|
1171 | inline bool gotLCopy() const {return false;} |
---|
1172 | inline void setNoGotLCopy() {} |
---|
1173 | inline void setYesGotLCopy() {} |
---|
1174 | inline bool gotRCopy() const {return false;} |
---|
1175 | inline void setNoGotRCopy() {} |
---|
1176 | inline void setYesGotRCopy() {} |
---|
1177 | inline bool gotUCopy() const {return false;} |
---|
1178 | inline void setNoGotUCopy() {} |
---|
1179 | inline void setYesGotUCopy() {} |
---|
1180 | inline bool gotSparse() const {return false;} |
---|
1181 | inline void setNoGotSparse() {} |
---|
1182 | inline void setYesGotSparse() {} |
---|
1183 | #endif |
---|
1184 | /** Array persistence flag |
---|
1185 | If 0 then as now (delete/new) |
---|
1186 | 1 then only do arrays if bigger needed |
---|
1187 | 2 as 1 but give a bit extra if bigger needed |
---|
1188 | */ |
---|
1189 | //CoinSimplexInt persistenceFlag_; |
---|
1190 | //@} |
---|
1191 | }; |
---|
1192 | |
---|
1193 | |
---|