1/* $Id: ClpNetworkBasis.hpp 1753 2011-06-19 16:27:26Z stefan $ */
2// Copyright (C) 2003, International Business Machines
3// Corporation and others. All Rights Reserved.
4// This code is licensed under the terms of the Eclipse Public License (EPL).
5/*
6 Authors
7
8 John Forrest
9
10 */
11#ifndef ClpNetworkBasis_H
12#define ClpNetworkBasis_H
13
14class ClpMatrixBase;
15class CoinIndexedVector;
16class ClpSimplex;
17#include "CoinTypes.hpp"
18#ifndef COIN_FAST_CODE
19#define COIN_FAST_CODE
20#endif
21
22/** This deals with Factorization and Updates for network structures
23 */
24
25
26class ClpNetworkBasis {
27
28public:
29
30 /**@name Constructors and destructor and copy */
31 //@{
32 /// Default constructor
33 ClpNetworkBasis ( );
34 /// Constructor from CoinFactorization
35 ClpNetworkBasis(const ClpSimplex * model,
36 int numberRows, const CoinFactorizationDouble * pivotRegion,
37 const int * permuteBack, const CoinBigIndex * startColumn,
38 const int * numberInColumn,
39 const int * indexRow, const CoinFactorizationDouble * element);
40 /// Copy constructor
41 ClpNetworkBasis ( const ClpNetworkBasis &other);
42
43 /// Destructor
44 ~ClpNetworkBasis ( );
45 /// = copy
46 ClpNetworkBasis & operator = ( const ClpNetworkBasis & other );
47 //@}
48
49 /**@name Do factorization */
50 //@{
51 /** When part of LP - given by basic variables.
52 Actually does factorization.
53 Arrays passed in have non negative value to say basic.
54 If status is okay, basic variables have pivot row - this is only needed
55 if increasingRows_ >1.
56 If status is singular, then basic variables have pivot row
57 and ones thrown out have -1
58 returns 0 -okay, -1 singular, -2 too many in basis */
59 int factorize ( const ClpMatrixBase * matrix,
60 int rowIsBasic[], int columnIsBasic[]);
61 //@}
62
63 /**@name rank one updates which do exist */
64 //@{
65
66 /** Replaces one Column to basis,
67 returns 0=OK, 1=Probably OK, 2=singular!!
68 */
69 int replaceColumn ( CoinIndexedVector * column,
70 int pivotRow);
71 //@}
72
73 /**@name various uses of factorization (return code number elements)
74 which user may want to know about */
75 //@{
76 /** Updates one column (FTRAN) from region,
77 Returns pivot value if "pivotRow" >=0
78 */
79 double updateColumn ( CoinIndexedVector * regionSparse,
80 CoinIndexedVector * regionSparse2,
81 int pivotRow);
82 /** Updates one column (FTRAN) to/from array
83 ** For large problems you should ALWAYS know where the nonzeros
84 are, so please try and migrate to previous method after you
85 have got code working using this simple method - thank you!
86 (the only exception is if you know input is dense e.g. rhs) */
87 int updateColumn ( CoinIndexedVector * regionSparse,
88 double array[] ) const;
89 /** Updates one column transpose (BTRAN)
90 ** For large problems you should ALWAYS know where the nonzeros
91 are, so please try and migrate to previous method after you
92 have got code working using this simple method - thank you!
93 (the only exception is if you know input is dense e.g. dense objective)
94 returns number of nonzeros */
95 int updateColumnTranspose ( CoinIndexedVector * regionSparse,
96 double array[] ) const;
97 /** Updates one column (BTRAN) from region2 */
98 int updateColumnTranspose ( CoinIndexedVector * regionSparse,
99 CoinIndexedVector * regionSparse2) const;
100 //@}
101////////////////// data //////////////////
102private:
103
104 // checks looks okay
105 void check();
106 // prints data
107 void print();
108 /**@name data */
109 //@{
110#ifndef COIN_FAST_CODE
111 /// Whether slack value is +1 or -1
112 double slackValue_;
113#endif
114 /// Number of Rows in factorization
115 int numberRows_;
116 /// Number of Columns in factorization
117 int numberColumns_;
118 /// model
119 const ClpSimplex * model_;
120 /// Parent for each column
121 int * parent_;
122 /// Descendant
123 int * descendant_;
124 /// Pivot row
125 int * pivot_;
126 /// Right sibling
127 int * rightSibling_;
128 /// Left sibling
129 int * leftSibling_;
130 /// Sign of pivot
131 double * sign_;
132 /// Stack
133 int * stack_;
134 /// Permute into array
135 int * permute_;
136 /// Permute back array
137 int * permuteBack_;
138 /// Second stack
139 int * stack2_;
140 /// Depth
141 int * depth_;
142 /// To mark rows
143 char * mark_;
144 //@}
145};
146#endif
147