Clp 1.16.9
Loading...
Searching...
No Matches
AbcSimplexFactorization.hpp
Go to the documentation of this file.
1/* $Id: AbcSimplexFactorization.hpp 2078 2015-01-05 12:39:49Z forrest $ */
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#ifndef AbcSimplexFactorization_H
7#define AbcSimplexFactorization_H
8
9
10#include "CoinPragma.hpp"
11
12#include "CoinAbcCommon.hpp"
14#include "AbcMatrix.hpp"
15//#include "CoinAbcAnyFactorization.hpp"
16#include "AbcSimplex.hpp"
17#ifndef ABC_USE_COIN_FACTORIZATION
19class CoinFactorization;
20#else
21#include "ClpFactorization.hpp"
22#include "CoinFactorization.hpp"
23#endif
28{
29
30public:
42 int factorize (AbcSimplex * model, int solveType, bool valuesPass);
43#ifdef EARLY_FACTORIZE
45 inline int factorize (AbcSimplex * model, CoinIndexedVector & stuff)
46 { return coinAbcFactorization_->factorize(model,stuff);}
47#endif
49
50
58
62 AbcSimplexFactorization(const AbcSimplexFactorization&, int denseIfSmaller = 0);
67
68 /* **** below here is so can use networkish basis */
71
76 inline
77#ifdef ABC_LONG_FACTORIZATION
78 long
79#endif
80 double checkReplacePart1 ( CoinIndexedVector * regionSparse,
81 int pivotRow)
82 {return coinAbcFactorization_->checkReplacePart1(regionSparse,pivotRow);}
87 inline
88#ifdef ABC_LONG_FACTORIZATION
89 long
90#endif
91 double checkReplacePart1 ( CoinIndexedVector * regionSparse,
92 CoinIndexedVector * partialUpdate,
93 int pivotRow)
94 {return coinAbcFactorization_->checkReplacePart1(regionSparse,partialUpdate,pivotRow);}
95#ifdef MOVE_REPLACE_PART1A
100 inline void checkReplacePart1a ( CoinIndexedVector * regionSparse,
101 int pivotRow)
102 {coinAbcFactorization_->checkReplacePart1a(regionSparse,pivotRow);}
103 inline double checkReplacePart1b (CoinIndexedVector * regionSparse,
104 int pivotRow)
105 {return coinAbcFactorization_->checkReplacePart1b(regionSparse,pivotRow);}
106#endif
109 inline int checkReplacePart2 ( int pivotRow,
110 double btranAlpha,
111 double ftranAlpha,
112#ifdef ABC_LONG_FACTORIZATION
113 long
114#endif
115 double ftAlpha)
116 {return coinAbcFactorization_->checkReplacePart2(pivotRow,btranAlpha,ftranAlpha,ftAlpha);}
117#ifdef ABC_LONG_FACTORIZATION
119 inline void clearHiddenArrays()
120 { coinAbcFactorization_->clearHiddenArrays();}
121#endif
124 void replaceColumnPart3 ( const AbcSimplex * model,
125 CoinIndexedVector * regionSparse,
126 CoinIndexedVector * tableauColumn,
127 int pivotRow,
128#ifdef ABC_LONG_FACTORIZATION
129 long
130#endif
131 double alpha );
134 void replaceColumnPart3 ( const AbcSimplex * model,
135 CoinIndexedVector * regionSparse,
136 CoinIndexedVector * tableauColumn,
137 CoinIndexedVector * partialUpdate,
138 int pivotRow,
139#ifdef ABC_LONG_FACTORIZATION
140 long
141#endif
142 double alpha );
143#ifdef EARLY_FACTORIZE
145 inline int replaceColumns ( const AbcSimplex * model,
146 CoinIndexedVector & stuff,
147 int firstPivot,int lastPivot,bool cleanUp)
148 { return coinAbcFactorization_->replaceColumns(model,stuff,firstPivot,lastPivot,cleanUp);}
149#endif
151
155#if 0
160 int updateColumnFT ( CoinIndexedVector * regionSparse,
161 CoinIndexedVector * regionSparse2);
164 int updateColumn ( CoinIndexedVector * regionSparse,
165 CoinIndexedVector * regionSparse2) const;
171 int updateTwoColumnsFT ( CoinIndexedVector * regionSparse1,
172 CoinIndexedVector * regionSparse2,
173 CoinIndexedVector * regionSparse3) ;
176 int updateColumnTranspose ( CoinIndexedVector * regionSparse,
177 CoinIndexedVector * regionSparse2) const;
178#endif
182 inline int updateColumnFT ( CoinIndexedVector & regionSparseFT)
183 { return coinAbcFactorization_->updateColumnFT(regionSparseFT);}
184 inline int updateColumnFTPart1 ( CoinIndexedVector & regionSparseFT)
185 { return coinAbcFactorization_->updateColumnFTPart1(regionSparseFT);}
186 inline void updateColumnFTPart2 ( CoinIndexedVector & regionSparseFT)
187 { coinAbcFactorization_->updateColumnFTPart2(regionSparseFT);}
191 inline void updateColumnFT ( CoinIndexedVector & regionSparseFT,
192 CoinIndexedVector & partialUpdate,
193 int which)
194 { coinAbcFactorization_->updateColumnFT(regionSparseFT,partialUpdate,which);}
196 inline int updateColumn ( CoinIndexedVector & regionSparse) const
197 { return coinAbcFactorization_->updateColumn(regionSparse);}
202 inline int updateTwoColumnsFT ( CoinIndexedVector & regionSparseFT,
203 CoinIndexedVector & regionSparseOther)
204 { return coinAbcFactorization_->updateTwoColumnsFT(regionSparseFT,regionSparseOther);}
206 inline int updateColumnTranspose ( CoinIndexedVector & regionSparse) const
207 { return coinAbcFactorization_->updateColumnTranspose(regionSparse);}
209 inline void updateColumnCpu ( CoinIndexedVector & regionSparse,int whichCpu) const
210#ifndef ABC_USE_COIN_FACTORIZATION
211 { coinAbcFactorization_->updateColumnCpu(regionSparse,whichCpu);}
212#else
213 { coinAbcFactorization_->updateColumn(regionSparse);}
214#endif
216 inline void updateColumnTransposeCpu ( CoinIndexedVector & regionSparse,int whichCpu) const
217#ifndef ABC_USE_COIN_FACTORIZATION
218 { coinAbcFactorization_->updateColumnTransposeCpu(regionSparse,whichCpu);}
219#else
220 { coinAbcFactorization_->updateColumnTranspose(regionSparse);}
221#endif
223 inline void updateFullColumn ( CoinIndexedVector & regionSparse) const
224 { coinAbcFactorization_->updateFullColumn(regionSparse);}
226 inline void updateFullColumnTranspose ( CoinIndexedVector & regionSparse) const
227 { coinAbcFactorization_->updateFullColumnTranspose(regionSparse);}
229 void updateWeights ( CoinIndexedVector & regionSparse) const
230#ifndef ABC_USE_COIN_FACTORIZATION
231 { coinAbcFactorization_->updateWeights(regionSparse);}
232#else
233 { coinAbcFactorization_->updateColumn(regionSparse);}
234#endif
236
239 inline int numberElements ( ) const {
240 return coinAbcFactorization_->numberElements() ;
241 }
243 inline int maximumPivots ( ) const {
244 return coinAbcFactorization_->maximumPivots() ;
245 }
247 inline void maximumPivots ( int value) {
248 coinAbcFactorization_->maximumPivots(value);
249 }
251 inline bool usingFT() const
252 { return !coinAbcFactorization_->wantsTableauColumn();}
254 inline int pivots ( ) const {
255 return coinAbcFactorization_->pivots() ;
256 }
258 inline void setModel(AbcSimplex * model)
259 {model_ = model;}
261 inline void setPivots ( int value ) const {
262 coinAbcFactorization_->setPivots(value) ;
263 }
265 inline double areaFactor ( ) const {
266 return coinAbcFactorization_->areaFactor() ;
267 }
269 inline void areaFactor ( double value) {
270 coinAbcFactorization_->areaFactor(value);
271 }
273 inline double zeroTolerance ( ) const {
274 return coinAbcFactorization_->zeroTolerance() ;
275 }
277 inline void zeroTolerance ( double value) {
278 coinAbcFactorization_->zeroTolerance(value);
279 }
283 inline int status ( ) const {
284 return coinAbcFactorization_->status() ;
285 }
287 inline void setStatus ( int value) {
288 coinAbcFactorization_->setStatus(value) ;
289 }
290#if ABC_PARALLEL==2
292 inline void setParallelMode(int value)
293 {coinAbcFactorization_->setParallelMode(value);};
294#endif
296 inline int numberDense() const {
297 return coinAbcFactorization_->numberDense() ;
298 }
299 bool timeToRefactorize() const;
300#if CLP_FACTORIZATION_NEW_TIMING>1
301 void statsRefactor(char when) const;
302#endif
304 inline void clearArrays() {
305 coinAbcFactorization_->clearArrays();
306 }
308 inline int numberRows ( ) const {
309 return coinAbcFactorization_->numberRows() ;
310 }
312 inline int numberSlacks() const
313 { return numberSlacks_;}
315 inline double pivotTolerance ( ) const {
316 return coinAbcFactorization_->pivotTolerance();
317 }
319 inline void pivotTolerance ( double value) {
320 coinAbcFactorization_->pivotTolerance(value);
321 }
323 inline double minimumPivotTolerance ( ) const {
324 return coinAbcFactorization_->minimumPivotTolerance();
325 }
327 inline void minimumPivotTolerance ( double value) {
328 coinAbcFactorization_->minimumPivotTolerance(value);
329 }
331 inline double * pivotRegion() const
332 { return coinAbcFactorization_->pivotRegion();}
334 //inline void relaxAccuracyCheck(double /*value*/) {
335 //abort();
336 //}
338 inline void almostDestructor() {
339 coinAbcFactorization_->clearArrays();
340 }
342 void setDenseThreshold(int number);
343 int getDenseThreshold() const;
345 void forceOtherFactorization(int which);
349 inline int goDenseThreshold() const {
350 return goDenseThreshold_;
351 }
353 inline void setGoDenseThreshold(int value) {
354 goDenseThreshold_ = value;
355 }
357 inline int goSmallThreshold() const {
358 return goSmallThreshold_;
359 }
361 inline void setGoSmallThreshold(int value) {
362 goSmallThreshold_ = value;
363 }
365 inline int goLongThreshold() const {
366 return goLongThreshold_;
367 }
369 inline void setGoLongThreshold(int value) {
370 goLongThreshold_ = value;
371 }
373 inline int typeOfFactorization() const
374 { return forceB_;}
376 void synchronize(const ClpFactorization * otherFactorization,const AbcSimplex * model);
378
382 void goSparse();
383#ifndef NDEBUG
384#ifndef ABC_USE_COIN_FACTORIZATION
385 inline void checkMarkArrays() const
386 { coinAbcFactorization_->checkMarkArrays();}
387#else
388 inline void checkMarkArrays() const
389 { }
390#endif
391#endif
393 inline bool needToReorder() const {abort();return true;}
395#ifndef ABC_USE_COIN_FACTORIZATION
397 { return coinAbcFactorization_;}
398#else
399 CoinFactorization * factorization() const
400 { return coinAbcFactorization_;}
401#endif
403
405private:
406
410 AbcSimplex * model_;
412#ifndef ABC_USE_COIN_FACTORIZATION
413 CoinAbcAnyFactorization * coinAbcFactorization_;
414#else
415 CoinFactorization * coinAbcFactorization_;
416#endif
417#ifdef CLP_FACTORIZATION_NEW_TIMING
419 mutable double shortestAverage_;
420 mutable double totalInR_;
421 mutable double totalInIncreasingU_;
422 mutable int endLengthU_;
423 mutable int lastNumberPivots_;
424 mutable int effectiveStartNumberU_;
425#endif
427 int forceB_;
429 int goDenseThreshold_;
431 int goSmallThreshold_;
433 int goLongThreshold_;
435 int numberSlacks_;
437};
438
439#endif
This just implements AbcFactorization when an AbcMatrix object is passed.
int updateTwoColumnsFT(CoinIndexedVector &regionSparseFT, CoinIndexedVector &regionSparseOther)
Updates one column (FTRAN) from regionFT Tries to do FT update number returned is negative if no room...
AbcSimplexFactorization(const AbcSimplexFactorization &, int denseIfSmaller=0)
The copy constructor.
int factorize(AbcSimplex *model, int solveType, bool valuesPass)
When part of LP - given by basic variables.
void zeroTolerance(double value)
Set zero tolerance.
int goDenseThreshold() const
Get switch to dense if number rows <= this.
void almostDestructor()
Allows change of pivot accuracy check 1.0 == none >1.0 relaxed.
void pivotTolerance(double value)
Set pivot tolerance.
int numberElements() const
Total number of elements in factorization.
bool needToReorder() const
Says whether to redo pivot order.
void updateFullColumn(CoinIndexedVector &regionSparse) const
Updates one full column (FTRAN)
int numberSlacks() const
Number of slacks at last factorization.
double * pivotRegion() const
pivot region
int pivots() const
Returns number of pivots since factorization.
void updateColumnFT(CoinIndexedVector &regionSparseFT, CoinIndexedVector &partialUpdate, int which)
Updates one column (FTRAN) Tries to do FT update puts partial update in vector.
int typeOfFactorization() const
Returns type.
double checkReplacePart1(CoinIndexedVector *regionSparse, CoinIndexedVector *partialUpdate, int pivotRow)
Checks if can replace one Column to basis, returns update alpha Fills in region for use later partial...
bool timeToRefactorize() const
void goSparse()
makes a row copy of L for speed and to allow very sparse problems
double minimumPivotTolerance() const
Minimum pivot tolerance.
void synchronize(const ClpFactorization *otherFactorization, const AbcSimplex *model)
Synchronize stuff.
int getDenseThreshold() const
int numberRows() const
Number of Rows after factorization.
void saferTolerances(double zeroTolerance, double pivotTolerance)
Set tolerances to safer of existing and given.
int updateColumnFTPart1(CoinIndexedVector &regionSparseFT)
CoinAbcAnyFactorization * factorization() const
Pointer to factorization.
void replaceColumnPart3(const AbcSimplex *model, CoinIndexedVector *regionSparse, CoinIndexedVector *tableauColumn, int pivotRow, double alpha)
Replaces one Column to basis, partial update already in U.
AbcSimplexFactorization(int numberRows=0)
Default constructor.
double pivotTolerance() const
Pivot tolerance.
void setDenseThreshold(int number)
So we can temporarily switch off dense.
void setPivots(int value) const
Sets number of pivots since factorization.
int maximumPivots() const
Maximum number of pivots between factorizations.
void clearArrays()
Get rid of all memory.
void updateFullColumnTranspose(CoinIndexedVector &regionSparse) const
Updates one full column (BTRAN)
void setGoSmallThreshold(int value)
Set switch to small if number rows <= this.
void areaFactor(double value)
Set whether larger areas needed.
int updateColumnTranspose(CoinIndexedVector &regionSparse) const
Updates one column (BTRAN)
~AbcSimplexFactorization()
Destructor.
double areaFactor() const
Whether larger areas needed.
int updateColumnFT(CoinIndexedVector &regionSparseFT)
Updates one column (FTRAN) Tries to do FT update number returned is negative if no room.
int goSmallThreshold() const
Get switch to small if number rows <= this.
void updateColumnTransposeCpu(CoinIndexedVector &regionSparse, int whichCpu) const
Updates one column (BTRAN)
void goDenseOrSmall(int numberRows)
Go over to dense code.
void setGoLongThreshold(int value)
Set switch to long/ordered if number rows >= this.
void forceOtherFactorization(int which)
If nonzero force use of 1,dense 2,small 3,long.
double zeroTolerance() const
Zero tolerance.
void setGoDenseThreshold(int value)
Set switch to dense if number rows <= this.
AbcSimplexFactorization & operator=(const AbcSimplexFactorization &)
void setFactorization(AbcSimplexFactorization &rhs)
Sets factorization.
void replaceColumnPart3(const AbcSimplex *model, CoinIndexedVector *regionSparse, CoinIndexedVector *tableauColumn, CoinIndexedVector *partialUpdate, int pivotRow, double alpha)
Replaces one Column to basis, partial update in vector.
int goLongThreshold() const
Get switch to long/ordered if number rows >= this.
void setModel(AbcSimplex *model)
Sets model.
double checkReplacePart1(CoinIndexedVector *regionSparse, int pivotRow)
Checks if can replace one Column to basis, returns update alpha Fills in region for use later partial...
void setStatus(int value)
Sets status.
bool usingFT() const
Returns true if doing FT.
int status() const
Returns status.
void updateColumnCpu(CoinIndexedVector &regionSparse, int whichCpu) const
Updates one column (FTRAN)
void updateWeights(CoinIndexedVector &regionSparse) const
Updates one column for dual steepest edge weights (FTRAN)
void maximumPivots(int value)
Set maximum number of pivots between factorizations.
int numberDense() const
Returns number of dense rows.
void updateColumnFTPart2(CoinIndexedVector &regionSparseFT)
void minimumPivotTolerance(double value)
Set minimum pivot tolerance.
int updateColumn(CoinIndexedVector &regionSparse) const
Updates one column (FTRAN)
int checkReplacePart2(int pivotRow, double btranAlpha, double ftranAlpha, double ftAlpha)
Checks if can replace one Column to basis, returns 0=OK, 1=Probably OK, 2=singular,...
This just implements CoinFactorization when an ClpMatrixBase object is passed.
Abstract base class which also has some scalars so can be used from Dense or Simp.
void setStatus(int value)
Sets status.
virtual int numberElements() const =0
Total number of elements in factorization.
virtual int updateTwoColumnsFT(CoinIndexedVector &regionFT, CoinIndexedVector &regionOther)=0
does FTRAN on two unpacked columns
virtual void updateFullColumnTranspose(CoinIndexedVector &regionSparse) const =0
Updates one column (BTRAN) from unpacked regionSparse.
double zeroTolerance() const
Zero tolerance.
double pivotTolerance() const
Pivot tolerance.
int pivots() const
Returns number of pivots since factorization.
virtual double checkReplacePart1b(CoinIndexedVector *, int)
int maximumPivots() const
Maximum number of pivots between factorizations.
virtual int checkReplacePart2(int pivotRow, double btranAlpha, double ftranAlpha, double ftAlpha, double acceptablePivot=1.0e-8)=0
Checks if can replace one Column to basis, returns 0=OK, 1=Probably OK, 2=singular,...
virtual void updateWeights(CoinIndexedVector &regionSparse) const =0
Updates one column for dual steepest edge weights (FTRAN)
virtual CoinFactorizationDouble * pivotRegion() const
virtual void clearArrays()
Get rid of all memory.
void setPivots(int value)
Sets number of pivots since factorization.
virtual void updateColumnFTPart2(CoinIndexedVector &regionSparse)=0
virtual int updateColumnFTPart1(CoinIndexedVector &regionSparse)=0
virtual int updateColumn(CoinIndexedVector &regionSparse) const =0
This version has same effect as above with FTUpdate==false so number returned is always >=0.
virtual bool wantsTableauColumn() const
Returns true if wants tableauColumn in replaceColumn.
virtual int updateColumnFT(CoinIndexedVector &regionSparse)=0
Updates one column (FTRAN) from unpacked regionSparse Tries to do FT update number returned is negati...
virtual void checkReplacePart1a(CoinIndexedVector *, int)
double areaFactor() const
Area factor.
virtual int updateColumnTranspose(CoinIndexedVector &regionSparse) const =0
Updates one column (BTRAN) from unpacked regionSparse.
int numberRows() const
Number of Rows after factorization.
int status() const
Returns status.
virtual void updateFullColumn(CoinIndexedVector &regionSparse) const =0
This version does FTRAN on array when indices not set up.
virtual void updateColumnTransposeCpu(CoinIndexedVector &regionSparse, int whichCpu) const
Updates one column (BTRAN)
virtual double checkReplacePart1(CoinIndexedVector *, int)
Checks if can replace one Column to basis, returns update alpha Fills in region for use later partial...
CoinSimplexInt numberDense() const
Number of dense rows after factorization.
double minimumPivotTolerance() const
Minimum pivot tolerance.
virtual void updateColumnCpu(CoinIndexedVector &regionSparse, int whichCpu) const
Updates one column (FTRAN)