Cgl 0.60.2

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ClpDynamicMatrix.hpp
Go to the documentation of this file.
1 /* $Id: ClpDynamicMatrix.hpp 2385 2019-01-06 19:43:06Z unxusr $ */
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 #include "CoinPragma.hpp"
10
11 #include "ClpPackedMatrix.hpp"
12 class ClpSimplex;
19 class ClpDynamicMatrix : public ClpPackedMatrix {
20
21 public:
23 enum DynamicStatus {
24 soloKey = 0x00,
25 inSmall = 0x01,
26 atUpperBound = 0x02,
27 atLowerBound = 0x03
28 };
31 virtual void partialPricing(ClpSimplex *model, double start, double end,
33 int &bestSequence, int &numberWanted);
34
38 virtual int updatePivot(ClpSimplex *model, double oldInValue, double oldOutValue);
42 virtual double *rhsOffset(ClpSimplex *model, bool forceRefresh = false,
43 bool check = false);
44
45 using ClpPackedMatrix::times;
49 virtual void times(double scalar,
50 const double *x, double *y) const;
52 void modifyOffset(int sequence, double amount);
54 double keyValue(int iSet) const;
63 virtual void dualExpanded(ClpSimplex *model, CoinIndexedVector *array,
64 double *other, int mode);
82 virtual int generalExpanded(ClpSimplex *model, int mode, int &number);
87 virtual int refresh(ClpSimplex *model);
91 virtual void createVariable(ClpSimplex *model, int &bestSequence);
93 virtual double reducedCost(ClpSimplex *model, int sequence) const;
95 void gubCrash();
97 void writeMps(const char *name);
99 void initialProblem();
101 int addColumn(CoinBigIndex numberEntries, const int *row, const double *element,
102 double cost, double lower, double upper, int iSet,
103 DynamicStatus status);
108 virtual void packDown(const int *, int) {}
110 inline double columnLower(int sequence) const
111 {
112 if (columnLower_)
113 return columnLower_[sequence];
114 else
115 return 0.0;
116 }
118 inline double columnUpper(int sequence) const
119 {
120 if (columnUpper_)
121 return columnUpper_[sequence];
122 else
123 return COIN_DBL_MAX;
124 }
125
127
131 ClpDynamicMatrix();
138 ClpDynamicMatrix(ClpSimplex *model, int numberSets,
139 int numberColumns, const int *starts,
140 const double *lower, const double *upper,
141 const CoinBigIndex *startColumn, const int *row,
142 const double *element, const double *cost,
143 const double *columnLower = NULL, const double *columnUpper = NULL,
144 const unsigned char *status = NULL,
145 const unsigned char *dynamicStatus = NULL);
146
148 virtual ~ClpDynamicMatrix();
150
154 ClpDynamicMatrix(const ClpDynamicMatrix &);
156 ClpDynamicMatrix(const CoinPackedMatrix &);
157
158 ClpDynamicMatrix &operator=(const ClpDynamicMatrix &);
160 virtual ClpMatrixBase *clone() const;
162
164 inline ClpSimplex::Status getStatus(int sequence) const
166 {
167 return static_cast< ClpSimplex::Status >(status_[sequence] & 7);
168 }
169 inline void setStatus(int sequence, ClpSimplex::Status status)
170 {
171 unsigned char &st_byte = status_[sequence];
172 st_byte = static_cast< unsigned char >(st_byte & ~7);
173 st_byte = static_cast< unsigned char >(st_byte | status);
174 }
176 inline bool flaggedSlack(int i) const
177 {
178 return (status_[i] & 8) != 0;
179 }
180 inline void setFlaggedSlack(int i)
181 {
182 status_[i] = static_cast< unsigned char >(status_[i] | 8);
183 }
184 inline void unsetFlaggedSlack(int i)
185 {
186 status_[i] = static_cast< unsigned char >(status_[i] & ~8);
187 }
189 inline int numberSets() const
190 {
191 return numberSets_;
192 }
194 inline int numberGubEntries() const
195 {
196 return startSet_[numberSets_];
197 }
199 inline int *startSets() const
200 {
201 return startSet_;
202 }
204 inline bool flagged(int i) const
205 {
206 return (dynamicStatus_[i] & 8) != 0;
207 }
208 inline void setFlagged(int i)
209 {
210 dynamicStatus_[i] = static_cast< unsigned char >(dynamicStatus_[i] | 8);
211 }
212 inline void unsetFlagged(int i)
213 {
214 dynamicStatus_[i] = static_cast< unsigned char >(dynamicStatus_[i] & ~8);
215 }
216 inline void setDynamicStatus(int sequence, DynamicStatus status)
217 {
218 unsigned char &st_byte = dynamicStatus_[sequence];
219 st_byte = static_cast< unsigned char >(st_byte & ~7);
220 st_byte = static_cast< unsigned char >(st_byte | status);
221 }
222 inline DynamicStatus getDynamicStatus(int sequence) const
223 {
224 return static_cast< DynamicStatus >(dynamicStatus_[sequence] & 7);
225 }
227 inline double objectiveOffset() const
228 {
229 return objectiveOffset_;
230 }
232 inline CoinBigIndex *startColumn() const
233 {
234 return startColumn_;
235 }
237 inline int *row() const
238 {
239 return row_;
240 }
242 inline double *element() const
243 {
244 return element_;
245 }
247 inline double *cost() const
248 {
249 return cost_;
250 }
252 inline int *id() const
253 {
254 return id_;
255 }
257 inline double *columnLower() const
258 {
259 return columnLower_;
260 }
262 inline double *columnUpper() const
263 {
264 return columnUpper_;
265 }
267 inline double *lowerSet() const
268 {
269 return lowerSet_;
270 }
272 inline double *upperSet() const
273 {
274 return upperSet_;
275 }
277 inline int numberGubColumns() const
278 {
279 return numberGubColumns_;
280 }
282 inline int firstAvailable() const
283 {
284 return firstAvailable_;
285 }
287 inline int firstDynamic() const
288 {
289 return firstDynamic_;
290 }
292 inline int lastDynamic() const
293 {
294 return lastDynamic_;
295 }
297 inline int numberStaticRows() const
298 {
299 return numberStaticRows_;
300 }
302 inline CoinBigIndex numberElements() const
303 {
304 return numberElements_;
305 }
306 inline int *keyVariable() const
307 {
308 return keyVariable_;
309 }
311 void switchOffCheck();
313 inline unsigned char *gubRowStatus() const
314 {
315 return status_;
316 }
318 inline unsigned char *dynamicStatus() const
319 {
320 return dynamicStatus_;
321 }
323 int whichSet(int sequence) const;
325
326 protected:
330 double sumDualInfeasibilities_;
333 double sumPrimalInfeasibilities_;
335 double sumOfRelaxedDualInfeasibilities_;
337 double sumOfRelaxedPrimalInfeasibilities_;
339 double savedBestGubDual_;
341 int savedBestSet_;
343 int *backToPivotRow_;
345 mutable int *keyVariable_;
347 int *toIndex_;
348 // Reverse pointer from index to set
349 int *fromIndex_;
351 int numberSets_;
353 int numberActiveSets_;
355 double objectiveOffset_;
357 double *lowerSet_;
359 double *upperSet_;
361 unsigned char *status_;
363 ClpSimplex *model_;
365 int firstAvailable_;
367 int firstAvailableBefore_;
369 int firstDynamic_;
371 int lastDynamic_;
373 int numberStaticRows_;
375 CoinBigIndex numberElements_;
377 int numberDualInfeasibilities_;
379 int numberPrimalInfeasibilities_;
385 int noCheck_;
387 double infeasibilityWeight_;
389 int numberGubColumns_;
391 int maximumGubColumns_;
393 CoinBigIndex maximumElements_;
395 int *startSet_;
397 int *next_;
399 CoinBigIndex *startColumn_;
401 int *row_;
403 double *element_;
405 double *cost_;
407 int *id_;
409 unsigned char *dynamicStatus_;
411 double *columnLower_;
413 double *columnUpper_;
415 };
416
417 #endif
418
419 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
420 */
ClpDynamicMatrix::initialProblem
void initialProblem()
Populates initial matrix from dynamic status.
ClpDynamicMatrix::unsetFlaggedSlack
void unsetFlaggedSlack(int i)
Definition: ClpDynamicMatrix.hpp:184
ClpDynamicMatrix::sumPrimalInfeasibilities_
double sumPrimalInfeasibilities_
Sum of primal infeasibilities.
Definition: ClpDynamicMatrix.hpp:333
ClpDynamicMatrix::getDynamicStatus
DynamicStatus getDynamicStatus(int sequence) const
Definition: ClpDynamicMatrix.hpp:222
ClpDynamicMatrix::createVariable
virtual void createVariable(ClpSimplex *model, int &bestSequence)
Creates a variable.
ClpDynamicMatrix::numberActiveSets_
int numberActiveSets_
Number of active sets.
Definition: ClpDynamicMatrix.hpp:353
ClpDynamicMatrix::savedBestGubDual_
double savedBestGubDual_
Saved best dual on gub row in pricing.
Definition: ClpDynamicMatrix.hpp:339
ClpDynamicMatrix::model_
ClpSimplex * model_
Pointer back to model.
Definition: ClpDynamicMatrix.hpp:363
ClpDynamicMatrix::firstAvailable
int firstAvailable() const
first free
Definition: ClpDynamicMatrix.hpp:282
ClpSimplex::Status
Status
enums for status of various sorts.
Definition: ClpSimplex.hpp:114
ClpDynamicMatrix::maximumElements_
CoinBigIndex maximumElements_
current maximum number of elemnts (then compress)
Definition: ClpDynamicMatrix.hpp:393
ClpDynamicMatrix::cost
double * cost() const
costs
Definition: ClpDynamicMatrix.hpp:247
ClpDynamicMatrix::packDown
virtual void packDown(const int *, int)
If addColumn forces compression then this allows descendant to know what to do.
Definition: ClpDynamicMatrix.hpp:108
ClpDynamicMatrix::numberElements
CoinBigIndex numberElements() const
size of working matrix (max)
Definition: ClpDynamicMatrix.hpp:302
ClpDynamicMatrix::numberGubEntries
int numberGubEntries() const
Number of possible gub variables.
Definition: ClpDynamicMatrix.hpp:194
ClpMatrixBase
Abstract base class for Clp Matrices.
Definition: ClpMatrixBase.hpp:38
ClpDynamicMatrix::rhsOffset
virtual double * rhsOffset(ClpSimplex *model, bool forceRefresh=false, bool check=false)
Returns effective RHS offset if it is being used.
ClpDynamicMatrix::switchOffCheck
void switchOffCheck()
Switches off dj checking each factorization (for BIG models)
ClpDynamicMatrix::dynamicStatus_
unsigned char * dynamicStatus_
for status and which bound
Definition: ClpDynamicMatrix.hpp:409
ClpDynamicMatrix::DynamicStatus
DynamicStatus
enums for status of various sorts
Definition: ClpDynamicMatrix.hpp:23
ClpDynamicMatrix::keyVariable_
int * keyVariable_
Key variable of set (only accurate if none in small problem)
Definition: ClpDynamicMatrix.hpp:345
ClpDynamicMatrix::operator=
ClpDynamicMatrix & operator=(const ClpDynamicMatrix &)
ClpDynamicMatrix::upperSet_
double * upperSet_
Upper bounds on sets.
Definition: ClpDynamicMatrix.hpp:359
ClpDynamicMatrix::gubCrash
void gubCrash()
Does gub crash.
ClpDynamicMatrix::infeasibilityWeight_
double infeasibilityWeight_
Infeasibility weight when last full pass done.
Definition: ClpDynamicMatrix.hpp:387
ClpDynamicMatrix::backToPivotRow_
int * backToPivotRow_
Backward pointer to pivot row !!!
Definition: ClpDynamicMatrix.hpp:343
ClpDynamicMatrix::sumDualInfeasibilities_
double sumDualInfeasibilities_
Sum of dual infeasibilities.
Definition: ClpDynamicMatrix.hpp:331
ClpDynamicMatrix::maximumGubColumns_
int maximumGubColumns_
current maximum number of columns (then compress)
Definition: ClpDynamicMatrix.hpp:391
ClpDynamicMatrix::id
int * id() const
ids of active columns (just index here)
Definition: ClpDynamicMatrix.hpp:252
ClpPackedMatrix
Definition: ClpPackedMatrix.hpp:23
ClpDynamicMatrix::atLowerBound
Definition: ClpDynamicMatrix.hpp:27
ClpDynamicMatrix::numberSets_
int numberSets_
Number of sets (dynamic rows)
Definition: ClpDynamicMatrix.hpp:351
ClpDynamicMatrix::lastDynamic
int lastDynamic() const
number of columns in dynamic model
Definition: ClpDynamicMatrix.hpp:292
ClpDynamicMatrix::next_
int * next_
next in chain
Definition: ClpDynamicMatrix.hpp:397
ClpDynamicMatrix::lowerSet_
double * lowerSet_
Lower bounds on sets.
Definition: ClpDynamicMatrix.hpp:357
ClpDynamicMatrix::startSet_
int * startSet_
Start of each set.
Definition: ClpDynamicMatrix.hpp:395
ClpDynamicMatrix::inSmall
Definition: ClpDynamicMatrix.hpp:25
ClpDynamicMatrix::flagged
bool flagged(int i) const
Whether flagged.
Definition: ClpDynamicMatrix.hpp:204
ClpDynamicMatrix::columnLower
double columnLower(int sequence) const
Gets lower bound (to simplify coding)
Definition: ClpDynamicMatrix.hpp:110
ClpPackedMatrix::times
virtual void times(double scalar, const double *x, double *y) const
Return y + A * scalar *x in y.
ClpDynamicMatrix::toIndex_
int * toIndex_
Backward pointer to extra row.
Definition: ClpDynamicMatrix.hpp:347
ClpDynamicMatrix::refresh
virtual int refresh(ClpSimplex *model)
Purely for column generation and similar ideas.
ClpDynamicMatrix::fromIndex_
int * fromIndex_
Definition: ClpDynamicMatrix.hpp:349
ClpDynamicMatrix::flaggedSlack
bool flaggedSlack(int i) const
Whether flagged slack.
Definition: ClpDynamicMatrix.hpp:176
ClpDynamicMatrix::objectiveOffset_
double objectiveOffset_
Saved value of objective offset.
Definition: ClpDynamicMatrix.hpp:355
ClpDynamicMatrix::gubRowStatus
unsigned char * gubRowStatus() const
Status region for gub slacks.
Definition: ClpDynamicMatrix.hpp:313
ClpDynamicMatrix::savedBestSet_
int savedBestSet_
Saved best set in pricing.
Definition: ClpDynamicMatrix.hpp:341
ClpDynamicMatrix::columnUpper
double * columnUpper() const
Optional upper bounds on columns.
Definition: ClpDynamicMatrix.hpp:262
ClpDynamicMatrix::setFlaggedSlack
void setFlaggedSlack(int i)
Definition: ClpDynamicMatrix.hpp:180
ClpDynamicMatrix::ClpDynamicMatrix
ClpDynamicMatrix()
Default constructor.
ClpDynamicMatrix::firstAvailableBefore_
int firstAvailableBefore_
first free when iteration started
Definition: ClpDynamicMatrix.hpp:367
ClpDynamicMatrix::reducedCost
virtual double reducedCost(ClpSimplex *model, int sequence) const
Returns reduced cost of a variable.
ClpDynamicMatrix::numberElements_
CoinBigIndex numberElements_
size of working matrix (max)
Definition: ClpDynamicMatrix.hpp:375
ClpDynamicMatrix::element_
double * element_
elements
Definition: ClpDynamicMatrix.hpp:403
ClpSimplex
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:106
CoinIndexedVector
Indexed Vector.
Definition: CoinIndexedVector.hpp:104
ClpDynamicMatrix::setDynamicStatus
void setDynamicStatus(int sequence, DynamicStatus status)
Definition: ClpDynamicMatrix.hpp:216
CoinPragma.hpp
ClpDynamicMatrix::setFlagged
void setFlagged(int i)
Definition: ClpDynamicMatrix.hpp:208
ClpDynamicMatrix::dynamicStatus
unsigned char * dynamicStatus() const
Status region for gub variables.
Definition: ClpDynamicMatrix.hpp:318
ClpDynamicMatrix::keyValue
double keyValue(int iSet) const
Gets key value when none in small.
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::setStatus
void setStatus(int sequence, ClpSimplex::Status status)
Definition: ClpDynamicMatrix.hpp:169
ClpDynamicMatrix::numberSets
int numberSets() const
Number of sets (dynamic rows)
Definition: ClpDynamicMatrix.hpp:189
ClpDynamicMatrix::addColumn
int addColumn(CoinBigIndex 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::lowerSet
double * lowerSet() const
Lower bounds on sets.
Definition: ClpDynamicMatrix.hpp:267
ClpDynamicMatrix::atUpperBound
Definition: ClpDynamicMatrix.hpp:26
ClpDynamicMatrix::numberPrimalInfeasibilities_
int numberPrimalInfeasibilities_
Number of primal infeasibilities.
Definition: ClpDynamicMatrix.hpp:379
ClpDynamicMatrix::numberGubColumns_
int numberGubColumns_
size
Definition: ClpDynamicMatrix.hpp:389
ClpDynamicMatrix::objectiveOffset
double objectiveOffset() const
Saved value of objective offset.
Definition: ClpDynamicMatrix.hpp:227
ClpDynamicMatrix::updatePivot
virtual int updatePivot(ClpSimplex *model, double oldInValue, double oldOutValue)
update information for a pivot (and effective rhs)
ClpDynamicMatrix::unsetFlagged
void unsetFlagged(int i)
Definition: ClpDynamicMatrix.hpp:212
ClpDynamicMatrix::firstAvailable_
int firstAvailable_
first free
Definition: ClpDynamicMatrix.hpp:365
ClpDynamicMatrix::numberDualInfeasibilities_
int numberDualInfeasibilities_
Number of dual infeasibilities.
Definition: ClpDynamicMatrix.hpp:377
ClpDynamicMatrix::numberStaticRows
int numberStaticRows() const
number of rows in original model
Definition: ClpDynamicMatrix.hpp:297
ClpDynamicMatrix::times
virtual void times(double scalar, const double *x, double *y) const
Return y + A * scalar *x in y.
ClpDynamicMatrix::getStatus
ClpSimplex::Status getStatus(int sequence) const
Status of row slacks.
Definition: ClpDynamicMatrix.hpp:165
CoinPackedMatrix
Sparse Matrix Base Class.
Definition: CoinPackedMatrix.hpp:79
ClpDynamicMatrix::writeMps
void writeMps(const char *name)
Writes out model (without names)
ClpDynamicMatrix::soloKey
Definition: ClpDynamicMatrix.hpp:24
ClpDynamicMatrix::~ClpDynamicMatrix
virtual ~ClpDynamicMatrix()
Destructor.
ClpDynamicMatrix::sumOfRelaxedPrimalInfeasibilities_
double sumOfRelaxedPrimalInfeasibilities_
Sum of Primal infeasibilities using tolerance based on error in primals.
Definition: ClpDynamicMatrix.hpp:337
ClpDynamicMatrix::columnLower
double * columnLower() const
Optional lower bounds on columns.
Definition: ClpDynamicMatrix.hpp:257
ClpDynamicMatrix::firstDynamic
int firstDynamic() const
first dynamic
Definition: ClpDynamicMatrix.hpp:287
ClpDynamicMatrix::columnUpper_
double * columnUpper_
Optional upper bounds on columns.
Definition: ClpDynamicMatrix.hpp:413
CoinBigIndex
int CoinBigIndex
Definition: Coin_C_defines.h:136
ClpDynamicMatrix::firstDynamic_
int firstDynamic_
first dynamic
Definition: ClpDynamicMatrix.hpp:369
ClpDynamicMatrix::columnLower_
double * columnLower_
Optional lower bounds on columns.
Definition: ClpDynamicMatrix.hpp:411
ClpDynamicMatrix
This implements a dynamic matrix when we have a limit on the number of &quot;interesting rows&quot;...
Definition: ClpDynamicMatrix.hpp:19
ClpPackedMatrix.hpp
ClpDynamicMatrix::clone
virtual ClpMatrixBase * clone() const
Clone.
ClpDynamicMatrix::noCheck_
int noCheck_
If pricing will declare victory (i.e.
Definition: ClpDynamicMatrix.hpp:385
ClpDynamicMatrix::startSets
int * startSets() const
Sets.
Definition: ClpDynamicMatrix.hpp:199
ClpDynamicMatrix::startColumn
CoinBigIndex * startColumn() const
Starts of each column.
Definition: ClpDynamicMatrix.hpp:232
ClpDynamicMatrix::lastDynamic_
int lastDynamic_
number of columns in dynamic model
Definition: ClpDynamicMatrix.hpp:371
ClpDynamicMatrix::numberStaticRows_
int numberStaticRows_
number of rows in original model
Definition: ClpDynamicMatrix.hpp:373
ClpDynamicMatrix::sumOfRelaxedDualInfeasibilities_
double sumOfRelaxedDualInfeasibilities_
Sum of Dual infeasibilities using tolerance based on error in duals.
Definition: ClpDynamicMatrix.hpp:335
ClpDynamicMatrix::keyVariable
int * keyVariable() const
Definition: ClpDynamicMatrix.hpp:306
ClpDynamicMatrix::row_
int * row_
rows
Definition: ClpDynamicMatrix.hpp:401
ClpDynamicMatrix::columnUpper
double columnUpper(int sequence) const
Gets upper bound (to simplify coding)
Definition: ClpDynamicMatrix.hpp:118
ClpDynamicMatrix::modifyOffset
void modifyOffset(int sequence, double amount)
Modifies rhs offset.
ClpDynamicMatrix::upperSet
double * upperSet() const
Upper bounds on sets.
Definition: ClpDynamicMatrix.hpp:272
COIN_DBL_MAX
const double COIN_DBL_MAX
Definition: CoinFinite.hpp:18
ClpDynamicMatrix::id_
int * id_
ids of active columns (just index here)
Definition: ClpDynamicMatrix.hpp:407
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::cost_
double * cost_
costs
Definition: ClpDynamicMatrix.hpp:405
ClpDynamicMatrix::element
double * element() const
elements
Definition: ClpDynamicMatrix.hpp:242
ClpDynamicMatrix::startColumn_
CoinBigIndex * startColumn_
Starts of each column.
Definition: ClpDynamicMatrix.hpp:399
ClpDynamicMatrix::numberGubColumns
int numberGubColumns() const
size
Definition: ClpDynamicMatrix.hpp:277
ClpDynamicMatrix::partialPricing
virtual void partialPricing(ClpSimplex *model, double start, double end, int &bestSequence, int &numberWanted)
Partial pricing.
ClpDynamicMatrix::row
int * row() const
rows
Definition: ClpDynamicMatrix.hpp:237
ClpDynamicMatrix::whichSet
int whichSet(int sequence) const
Returns which set a variable is in.
ClpDynamicMatrix::status_
unsigned char * status_
Status of slack on set.
Definition: ClpDynamicMatrix.hpp:361