- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

ClpDynamicMatrix.hpp
Go to the documentation of this file.
1 /* $Id: ClpDynamicMatrix.hpp 1755 2011-06-28 18:24:31Z lou $ */
2 // Copyright (C) 2004, 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 #ifndef ClpDynamicMatrix_H
7 #define ClpDynamicMatrix_H
8
9
10 #include "CoinPragma.hpp"
11
12 #include "ClpPackedMatrix.hpp"
13 class ClpSimplex;
20 class ClpDynamicMatrix : public ClpPackedMatrix {
21
22 public:
24 enum DynamicStatus {
25 soloKey = 0x00,
26 inSmall = 0x01,
27 atUpperBound = 0x02,
28 atLowerBound = 0x03
29 };
32 virtual void partialPricing(ClpSimplex * model, double start, double end,
34 int & bestSequence, int & numberWanted);
35
39 virtual int updatePivot(ClpSimplex * model, double oldInValue, double oldOutValue);
43 virtual double * rhsOffset(ClpSimplex * model, bool forceRefresh = false,
44 bool check = false);
45
46 using ClpPackedMatrix::times ;
50 virtual void times(double scalar,
51 const double * x, double * y) const;
53 void modifyOffset(int sequence, double amount);
55 double keyValue(int iSet) const;
64 virtual void dualExpanded(ClpSimplex * model, CoinIndexedVector * array,
65 double * other, int mode);
83 virtual int generalExpanded(ClpSimplex * model, int mode, int & number);
88 virtual int refresh(ClpSimplex * model);
92 virtual void createVariable(ClpSimplex * model, int & bestSequence);
94 virtual double reducedCost( ClpSimplex * model, int sequence) const;
96 void gubCrash();
98 void writeMps(const char * name);
100 void initialProblem();
102 int addColumn(int numberEntries, const int * row, const double * element,
103 double cost, double lower, double upper, int iSet,
104 DynamicStatus status);
109 virtual void packDown(const int * , int ) {}
111 inline double columnLower(int sequence) const {
112 if (columnLower_) return columnLower_[sequence];
113 else return 0.0;
114 }
116 inline double columnUpper(int sequence) const {
117 if (columnUpper_) return columnUpper_[sequence];
118 else return COIN_DBL_MAX;
119 }
120
122
123
124
128 ClpDynamicMatrix();
135 ClpDynamicMatrix(ClpSimplex * model, int numberSets,
136 int numberColumns, const int * starts,
137 const double * lower, const double * upper,
138 const CoinBigIndex * startColumn, const int * row,
139 const double * element, const double * cost,
140 const double * columnLower = NULL, const double * columnUpper = NULL,
141 const unsigned char * status = NULL,
142 const unsigned char * dynamicStatus = NULL);
143
145 virtual ~ClpDynamicMatrix();
147
151 ClpDynamicMatrix(const ClpDynamicMatrix&);
153 ClpDynamicMatrix(const CoinPackedMatrix&);
154
155 ClpDynamicMatrix& operator=(const ClpDynamicMatrix&);
157 virtual ClpMatrixBase * clone() const ;
159
161 inline ClpSimplex::Status getStatus(int sequence) const {
163 return static_cast<ClpSimplex::Status> (status_[sequence] & 7);
164 }
165 inline void setStatus(int sequence, ClpSimplex::Status status) {
166 unsigned char & st_byte = status_[sequence];
167 st_byte = static_cast<unsigned char>(st_byte & ~7);
168 st_byte = static_cast<unsigned char>(st_byte | status);
169 }
171 inline bool flaggedSlack(int i) const {
172 return (status_[i] & 8) != 0;
173 }
174 inline void setFlaggedSlack(int i) {
175 status_[i] = static_cast<unsigned char>(status_[i] | 8);
176 }
177 inline void unsetFlaggedSlack(int i) {
178 status_[i] = static_cast<unsigned char>(status_[i] & ~8);
179 }
181 inline int numberSets() const {
182 return numberSets_;
183 }
185 inline int numberGubEntries() const
186 { return startSet_[numberSets_];}
188 inline int * startSets() const
189 { return startSet_;}
191 inline bool flagged(int i) const {
192 return (dynamicStatus_[i] & 8) != 0;
193 }
194 inline void setFlagged(int i) {
195 dynamicStatus_[i] = static_cast<unsigned char>(dynamicStatus_[i] | 8);
196 }
197 inline void unsetFlagged(int i) {
198 dynamicStatus_[i] = static_cast<unsigned char>(dynamicStatus_[i] & ~8);
199 }
200 inline void setDynamicStatus(int sequence, DynamicStatus status) {
201 unsigned char & st_byte = dynamicStatus_[sequence];
202 st_byte = static_cast<unsigned char>(st_byte & ~7);
203 st_byte = static_cast<unsigned char>(st_byte | status);
204 }
205 inline DynamicStatus getDynamicStatus(int sequence) const {
206 return static_cast<DynamicStatus> (dynamicStatus_[sequence] & 7);
207 }
209 inline double objectiveOffset() const {
210 return objectiveOffset_;
211 }
213 inline CoinBigIndex * startColumn() const {
214 return startColumn_;
215 }
217 inline int * row() const {
218 return row_;
219 }
221 inline double * element() const {
222 return element_;
223 }
225 inline double * cost() const {
226 return cost_;
227 }
229 inline int * id() const {
230 return id_;
231 }
233 inline double * columnLower() const {
234 return columnLower_;
235 }
237 inline double * columnUpper() const {
238 return columnUpper_;
239 }
241 inline double * lowerSet() const {
242 return lowerSet_;
243 }
245 inline double * upperSet() const {
246 return upperSet_;
247 }
249 inline int numberGubColumns() const {
250 return numberGubColumns_;
251 }
253 inline int firstAvailable() const {
254 return firstAvailable_;
255 }
257 inline int firstDynamic() const {
258 return firstDynamic_;
259 }
261 inline int lastDynamic() const {
262 return lastDynamic_;
263 }
265 inline int numberStaticRows() const {
266 return numberStaticRows_;
267 }
269 inline int numberElements() const {
270 return numberElements_;
271 }
272 inline int * keyVariable() const {
273 return keyVariable_;
274 }
276 void switchOffCheck();
278 inline unsigned char * gubRowStatus() const {
279 return status_;
280 }
282 inline unsigned char * dynamicStatus() const {
283 return dynamicStatus_;
284 }
286 int whichSet (int sequence) const;
288
289
290 protected:
294 double sumDualInfeasibilities_;
297 double sumPrimalInfeasibilities_;
299 double sumOfRelaxedDualInfeasibilities_;
301 double sumOfRelaxedPrimalInfeasibilities_;
303 double savedBestGubDual_;
305 int savedBestSet_;
307 int * backToPivotRow_;
309 mutable int * keyVariable_;
311 int * toIndex_;
312 // Reverse pointer from index to set
313 int * fromIndex_;
315 int numberSets_;
317 int numberActiveSets_;
319 double objectiveOffset_;
321 double * lowerSet_;
323 double * upperSet_;
325 unsigned char * status_;
327 ClpSimplex * model_;
329 int firstAvailable_;
331 int firstAvailableBefore_;
333 int firstDynamic_;
335 int lastDynamic_;
337 int numberStaticRows_;
339 int numberElements_;
341 int numberDualInfeasibilities_;
343 int numberPrimalInfeasibilities_;
349 int noCheck_;
351 double infeasibilityWeight_;
353 int numberGubColumns_;
355 int maximumGubColumns_;
357 int maximumElements_;
359 int * startSet_;
361 int * next_;
363 CoinBigIndex * startColumn_;
365 int * row_;
367 double * element_;
369 double * cost_;
371 int * id_;
373 unsigned char * dynamicStatus_;
375 double * columnLower_;
377 double * columnUpper_;
379 };
380
381 #endif
ClpDynamicMatrix::lowerSet
double * lowerSet() const
Lower bounds on sets.
Definition: ClpDynamicMatrix.hpp:241
CoinBigIndex
int CoinBigIndex
Definition: Coin_C_defines.h:105
ClpDynamicMatrix::setFlaggedSlack
void setFlaggedSlack(int i)
Status of row slacks.
Definition: ClpDynamicMatrix.hpp:174
ClpDynamicMatrix::noCheck_
int noCheck_
If pricing will declare victory (i.e.
Definition: ClpDynamicMatrix.hpp:349
ClpDynamicMatrix::columnUpper
double * columnUpper() const
Optional upper bounds on columns.
Definition: ClpDynamicMatrix.hpp:237
ClpDynamicMatrix::gubRowStatus
unsigned char * gubRowStatus() const
Status region for gub slacks.
Definition: ClpDynamicMatrix.hpp:278
ClpDynamicMatrix::backToPivotRow_
int * backToPivotRow_
Backward pointer to pivot row !!!
Definition: ClpDynamicMatrix.hpp:307
ClpDynamicMatrix::numberGubColumns_
int numberGubColumns_
size
Definition: ClpDynamicMatrix.hpp:353
ClpDynamicMatrix::ClpDynamicMatrix
ClpDynamicMatrix()
Default constructor.
ClpDynamicMatrix::unsetFlaggedSlack
void unsetFlaggedSlack(int i)
Status of row slacks.
Definition: ClpDynamicMatrix.hpp:177
ClpDynamicMatrix::element
double * element() const
elements
Definition: ClpDynamicMatrix.hpp:221
ClpDynamicMatrix::id_
int * id_
ids of active columns (just index here)
Definition: ClpDynamicMatrix.hpp:371
ClpDynamicMatrix::numberElements_
int numberElements_
size of working matrix (max)
Definition: ClpDynamicMatrix.hpp:339
ClpDynamicMatrix::dynamicStatus
unsigned char * dynamicStatus() const
Status region for gub variables.
Definition: ClpDynamicMatrix.hpp:282
ClpDynamicMatrix::DynamicStatus
DynamicStatus
enums for status of various sorts
Definition: ClpDynamicMatrix.hpp:24
ClpDynamicMatrix::refresh
virtual int refresh(ClpSimplex *model)
Purely for column generation and similar ideas.
ClpDynamicMatrix::whichSet
int whichSet(int sequence) const
Returns which set a variable is in.
ClpDynamicMatrix::numberElements
int numberElements() const
size of working matrix (max)
Definition: ClpDynamicMatrix.hpp:269
ClpDynamicMatrix::clone
virtual ClpMatrixBase * clone() const
Clone.
ClpDynamicMatrix::atLowerBound
Definition: ClpDynamicMatrix.hpp:28
ClpDynamicMatrix::columnUpper
double columnUpper(int sequence) const
Gets upper bound (to simplify coding)
Definition: ClpDynamicMatrix.hpp:116
ClpDynamicMatrix::inSmall
Definition: ClpDynamicMatrix.hpp:26
ClpDynamicMatrix::createVariable
virtual void createVariable(ClpSimplex *model, int &bestSequence)
Creates a variable.
ClpDynamicMatrix::columnLower_
double * columnLower_
Optional lower bounds on columns.
Definition: ClpDynamicMatrix.hpp:375
ClpDynamicMatrix::sumDualInfeasibilities_
double sumDualInfeasibilities_
Sum of dual infeasibilities.
Definition: ClpDynamicMatrix.hpp:295
ClpDynamicMatrix::keyVariable
int * keyVariable() const
Status of row slacks.
Definition: ClpDynamicMatrix.hpp:272
ClpDynamicMatrix::columnLower
double * columnLower() const
Optional lower bounds on columns.
Definition: ClpDynamicMatrix.hpp:233
ClpDynamicMatrix::toIndex_
int * toIndex_
Backward pointer to extra row.
Definition: ClpDynamicMatrix.hpp:311
ClpDynamicMatrix::startSet_
int * startSet_
Start of each set.
Definition: ClpDynamicMatrix.hpp:359
ClpDynamicMatrix::numberSets
int numberSets() const
Number of sets (dynamic rows)
Definition: ClpDynamicMatrix.hpp:181
ClpDynamicMatrix::upperSet
double * upperSet() const
Upper bounds on sets.
Definition: ClpDynamicMatrix.hpp:245
ClpDynamicMatrix::initialProblem
void initialProblem()
Populates initial matrix from dynamic status.
ClpDynamicMatrix::setStatus
void setStatus(int sequence, ClpSimplex::Status status)
Status of row slacks.
Definition: ClpDynamicMatrix.hpp:165
ClpDynamicMatrix::element_
double * element_
elements
Definition: ClpDynamicMatrix.hpp:367
ClpDynamicMatrix::numberGubEntries
int numberGubEntries() const
Number of possible gub variables.
Definition: ClpDynamicMatrix.hpp:185
ClpDynamicMatrix::reducedCost
virtual double reducedCost(ClpSimplex *model, int sequence) const
Returns reduced cost of a variable.
ClpDynamicMatrix::cost
double * cost() const
costs
Definition: ClpDynamicMatrix.hpp:225
ClpDynamicMatrix::numberStaticRows
int numberStaticRows() const
number of rows in original model
Definition: ClpDynamicMatrix.hpp:265
CoinPackedMatrix
Sparse Matrix Base Class.
Definition: CoinPackedMatrix.hpp:79
ClpDynamicMatrix::startColumn_
CoinBigIndex * startColumn_
Starts of each column.
Definition: ClpDynamicMatrix.hpp:363
ClpDynamicMatrix::firstAvailable
int firstAvailable() const
first free
Definition: ClpDynamicMatrix.hpp:253
ClpDynamicMatrix::lastDynamic_
int lastDynamic_
number of columns in dynamic model
Definition: ClpDynamicMatrix.hpp:335
ClpDynamicMatrix::savedBestGubDual_
double savedBestGubDual_
Saved best dual on gub row in pricing.
Definition: ClpDynamicMatrix.hpp:303
ClpDynamicMatrix::keyValue
double keyValue(int iSet) const
Gets key value when none in small.
ClpDynamicMatrix::model_
ClpSimplex * model_
Pointer back to model.
Definition: ClpDynamicMatrix.hpp:327
ClpDynamicMatrix::generalExpanded
virtual int generalExpanded(ClpSimplex *model, int mode, int &number)
mode=0 - Create list of non-key basics in pivotVariable_ using number as numberBasic in and out mode=...
ClpDynamicMatrix::objectiveOffset
double objectiveOffset() const
Saved value of objective offset.
Definition: ClpDynamicMatrix.hpp:209
ClpDynamicMatrix::writeMps
void writeMps(const char *name)
Writes out model (without names)
ClpDynamicMatrix::startColumn
CoinBigIndex * startColumn() const
Starts of each column.
Definition: ClpDynamicMatrix.hpp:213
ClpDynamicMatrix::savedBestSet_
int savedBestSet_
Saved best set in pricing.
Definition: ClpDynamicMatrix.hpp:305
ClpDynamicMatrix::keyVariable_
int * keyVariable_
Key variable of set (only accurate if none in small problem)
Definition: ClpDynamicMatrix.hpp:309
ClpDynamicMatrix::maximumGubColumns_
int maximumGubColumns_
current maximum number of columns (then compress)
Definition: ClpDynamicMatrix.hpp:355
ClpDynamicMatrix::numberDualInfeasibilities_
int numberDualInfeasibilities_
Number of dual infeasibilities.
Definition: ClpDynamicMatrix.hpp:341
ClpDynamicMatrix::getDynamicStatus
DynamicStatus getDynamicStatus(int sequence) const
Status of row slacks.
Definition: ClpDynamicMatrix.hpp:205
ClpDynamicMatrix::cost_
double * cost_
costs
Definition: ClpDynamicMatrix.hpp:369
ClpDynamicMatrix::rhsOffset
virtual double * rhsOffset(ClpSimplex *model, bool forceRefresh=false, bool check=false)
Returns effective RHS offset if it is being used.
ClpSimplex::Status
Status
enums for status of various sorts.
Definition: ClpSimplex.hpp:78
ClpDynamicMatrix::sumOfRelaxedDualInfeasibilities_
double sumOfRelaxedDualInfeasibilities_
Sum of Dual infeasibilities using tolerance based on error in duals.
Definition: ClpDynamicMatrix.hpp:299
ClpDynamicMatrix::sumOfRelaxedPrimalInfeasibilities_
double sumOfRelaxedPrimalInfeasibilities_
Sum of Primal infeasibilities using tolerance based on error in primals.
Definition: ClpDynamicMatrix.hpp:301
ClpDynamicMatrix::packDown
virtual void packDown(const int *, int)
If addColumn forces compression then this allows descendant to know what to do.
Definition: ClpDynamicMatrix.hpp:109
ClpDynamicMatrix::id
int * id() const
ids of active columns (just index here)
Definition: ClpDynamicMatrix.hpp:229
ClpDynamicMatrix::firstAvailable_
int firstAvailable_
first free
Definition: ClpDynamicMatrix.hpp:329
ClpDynamicMatrix::row
int * row() const
rows
Definition: ClpDynamicMatrix.hpp:217
ClpDynamicMatrix::getStatus
ClpSimplex::Status getStatus(int sequence) const
Status of row slacks.
Definition: ClpDynamicMatrix.hpp:162
ClpDynamicMatrix::soloKey
Definition: ClpDynamicMatrix.hpp:25
ClpDynamicMatrix::~ClpDynamicMatrix
virtual ~ClpDynamicMatrix()
Destructor.
ClpDynamicMatrix::setDynamicStatus
void setDynamicStatus(int sequence, DynamicStatus status)
Status of row slacks.
Definition: ClpDynamicMatrix.hpp:200
ClpPackedMatrix::times
virtual void times(double scalar, const double *x, double *y) const
Return y + A * scalar *x in y.
ClpDynamicMatrix::status_
unsigned char * status_
Status of slack on set.
Definition: ClpDynamicMatrix.hpp:325
CoinIndexedVector
Indexed Vector.
Definition: CoinIndexedVector.hpp:104
ClpDynamicMatrix::upperSet_
double * upperSet_
Upper bounds on sets.
Definition: ClpDynamicMatrix.hpp:323
ClpDynamicMatrix::numberActiveSets_
int numberActiveSets_
Number of active sets.
Definition: ClpDynamicMatrix.hpp:317
ClpDynamicMatrix
This implements a dynamic matrix when we have a limit on the number of &quot;interesting rows&quot;...
Definition: ClpDynamicMatrix.hpp:20
ClpDynamicMatrix::numberStaticRows_
int numberStaticRows_
number of rows in original model
Definition: ClpDynamicMatrix.hpp:337
ClpDynamicMatrix::row_
int * row_
rows
Definition: ClpDynamicMatrix.hpp:365
ClpSimplex
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:70
ClpPackedMatrix
Definition: ClpPackedMatrix.hpp:21
ClpDynamicMatrix::columnUpper_
double * columnUpper_
Optional upper bounds on columns.
Definition: ClpDynamicMatrix.hpp:377
COIN_DBL_MAX
const double COIN_DBL_MAX
Definition: CoinFinite.hpp:18
ClpMatrixBase
Abstract base class for Clp Matrices.
Definition: ClpMatrixBase.hpp:38
ClpDynamicMatrix::times
virtual void times(double scalar, const double *x, double *y) const
Return y + A * scalar *x in y.
ClpDynamicMatrix::dualExpanded
virtual void dualExpanded(ClpSimplex *model, CoinIndexedVector *array, double *other, int mode)
mode=0 - Set up before &quot;updateTranspose&quot; and &quot;transposeTimes&quot; for duals using extended updates array ...
ClpDynamicMatrix::flagged
bool flagged(int i) const
Whether flagged.
Definition: ClpDynamicMatrix.hpp:191
ClpDynamicMatrix::infeasibilityWeight_
double infeasibilityWeight_
Infeasibility weight when last full pass done.
Definition: ClpDynamicMatrix.hpp:351
ClpDynamicMatrix::firstDynamic_
int firstDynamic_
first dynamic
Definition: ClpDynamicMatrix.hpp:333
ClpDynamicMatrix::addColumn
int addColumn(int numberEntries, const int *row, const double *element, double cost, double lower, double upper, int iSet, DynamicStatus status)
Adds in a column to gub structure (called from descendant) and returns sequence.
ClpDynamicMatrix::updatePivot
virtual int updatePivot(ClpSimplex *model, double oldInValue, double oldOutValue)
update information for a pivot (and effective rhs)
ClpDynamicMatrix::partialPricing
virtual void partialPricing(ClpSimplex *model, double start, double end, int &bestSequence, int &numberWanted)
Partial pricing.
ClpDynamicMatrix::sumPrimalInfeasibilities_
double sumPrimalInfeasibilities_
Sum of primal infeasibilities.
Definition: ClpDynamicMatrix.hpp:297
ClpDynamicMatrix::objectiveOffset_
double objectiveOffset_
Saved value of objective offset.
Definition: ClpDynamicMatrix.hpp:319
CoinPragma.hpp
ClpDynamicMatrix::atUpperBound
Definition: ClpDynamicMatrix.hpp:27
ClpDynamicMatrix::columnLower
double columnLower(int sequence) const
Gets lower bound (to simplify coding)
Definition: ClpDynamicMatrix.hpp:111
ClpDynamicMatrix::flaggedSlack
bool flaggedSlack(int i) const
Whether flagged slack.
Definition: ClpDynamicMatrix.hpp:171
ClpDynamicMatrix::fromIndex_
int * fromIndex_
Sum of dual infeasibilities.
Definition: ClpDynamicMatrix.hpp:313
ClpPackedMatrix.hpp
ClpDynamicMatrix::unsetFlagged
void unsetFlagged(int i)
Status of row slacks.
Definition: ClpDynamicMatrix.hpp:197
ClpDynamicMatrix::numberSets_
int numberSets_
Number of sets (dynamic rows)
Definition: ClpDynamicMatrix.hpp:315
ClpDynamicMatrix::maximumElements_
int maximumElements_
current maximum number of elemnts (then compress)
Definition: ClpDynamicMatrix.hpp:357
ClpDynamicMatrix::startSets
int * startSets() const
Sets.
Definition: ClpDynamicMatrix.hpp:188
ClpDynamicMatrix::numberPrimalInfeasibilities_
int numberPrimalInfeasibilities_
Number of primal infeasibilities.
Definition: ClpDynamicMatrix.hpp:343
ClpDynamicMatrix::firstAvailableBefore_
int firstAvailableBefore_
first free when iteration started
Definition: ClpDynamicMatrix.hpp:331
ClpDynamicMatrix::numberGubColumns
int numberGubColumns() const
size
Definition: ClpDynamicMatrix.hpp:249
ClpDynamicMatrix::setFlagged
void setFlagged(int i)
Status of row slacks.
Definition: ClpDynamicMatrix.hpp:194
ClpDynamicMatrix::firstDynamic
int firstDynamic() const
first dynamic
Definition: ClpDynamicMatrix.hpp:257
ClpDynamicMatrix::operator=
ClpDynamicMatrix & operator=(const ClpDynamicMatrix &)
The copy constructor.
ClpDynamicMatrix::switchOffCheck
void switchOffCheck()
Switches off dj checking each factorization (for BIG models)
ClpDynamicMatrix::next_
int * next_
next in chain
Definition: ClpDynamicMatrix.hpp:361
ClpDynamicMatrix::gubCrash
void gubCrash()
Does gub crash.
ClpDynamicMatrix::lastDynamic
int lastDynamic() const
number of columns in dynamic model
Definition: ClpDynamicMatrix.hpp:261
ClpDynamicMatrix::dynamicStatus_
unsigned char * dynamicStatus_
for status and which bound
Definition: ClpDynamicMatrix.hpp:373
ClpDynamicMatrix::lowerSet_
double * lowerSet_
Lower bounds on sets.
Definition: ClpDynamicMatrix.hpp:321
ClpDynamicMatrix::modifyOffset
void modifyOffset(int sequence, double amount)
Modifies rhs offset.