Loading...
Searching...
No Matches
ClpPESimplex.hpp
Go to the documentation of this file.
// Copyright (C) 2002, International Business Machines
// Corporation and others. All Rights Reserved.
/*
Authors
Jeremy Omer
Last update: june 10, 2014
*/
#ifndef ClpPESimplex_H
#define ClpPESimplex_H
#include "ClpSimplex.hpp"
#include "CoinIndexedVector.hpp"
#include "ClpPackedMatrix.hpp"
#include "CoinTime.hpp"
#include <iostream>
#include <fstream>
// #define PE_DEBUG 0
double PEdot(CoinIndexedVector &v1, const double *v2);
double PEdot(CoinIndexedVector &v1, CoinIndexedVector &v2);
void PEtransposeTimesSubsetAll(ClpSimplex *model, int number, const int *which,
const double *COIN_RESTRICT x, double *COIN_RESTRICT y,
const double *COIN_RESTRICT rowScale,
const double *COIN_RESTRICT columnScale);
class ClpPESimplex {
public:
ClpPESimplex(ClpSimplex *model);
~ClpPESimplex();
public:
inline int coPrimalDegenerates() { return coPrimalDegenerates_; }
inline int coDualDegenerates() { return coDualDegenerates_; }
inline int coCompatibleCols() { return coCompatibleCols_; }
inline int coCompatibleRows() { return coCompatibleRows_; }
inline bool isCompatibleCol(int sequence) { return isCompatibleCol_[sequence]; }
inline bool isCompatibleRow(int row)
{
assert(row >= 0 && row < numberRows_);
return isCompatibleRow_[row];
}
inline ClpSimplex *clpModel() { return model_; }
// check seems to be same model - returns false if size changed
bool checkSize();
public:
void updatePrimalDegenerates();
void updateDualDegenerates();
void identifyCompatibleCols(int number, const int *which,
CoinIndexedVector *spareRow2,
CoinIndexedVector *wPrimal);
void identifyCompatibleRows(CoinIndexedVector *spare,
CoinIndexedVector *wDual);
void updateCompatibleRows(int sequence);
public:
#if PE_DEBUG >= 1
void printPrimalDegenerates();
void printCompatibleCols();
bool checkCompatibilityCol(int sequence, CoinIndexedVector *spareRow2);
#endif
bool checkCompatibilityRow(int pivotRow);
inline double lastObjectiveValue() { return lastObjectiveValue_; }
inline void updateLastObjectiveValue() { lastObjectiveValue_ = model_->objectiveValue(); }
inline bool isDegeneratePivot() { return fabs(model_->objectiveValue() - lastObjectiveValue_) < model_->dualTolerance(); }
inline bool isLastPivotCompatible() { return isLastPivotCompatible_; }
inline void isLastPivotCompatible(bool yesOrNo) { isLastPivotCompatible_ = yesOrNo; }
inline void startTimer() { timeTmp_ = CoinCpuTime(); }
inline void stopTimer() { timeCompatibility_ += CoinCpuTime() - timeTmp_; }
void printTimer(std::ostream &out);
inline double timeMultRandom() { return timeMultRandom_; }
inline double timeLinearSystem() { return timeLinearSystem_; }
inline double timeCompatibility() { return timeCompatibility_; }
inline void addDegeneratePivot() { coDegeneratePivots_++; }
inline int coDegeneratePivots() { return coDegeneratePivots_; }
inline void addDegeneratePivotConsecutive() { coDegeneratePivotsConsecutive_++; }
inline void resetDegeneratePivotsConsecutive() { coDegeneratePivotsConsecutive_ = 0; }
inline int coDegeneratePivotsConsecutive() { return coDegeneratePivotsConsecutive_; }
void updateDualDegeneratesAvg(int coPivots);
inline double coDualDegeneratesAvg() { return coDualDegeneratesAvg_; }
void updatePrimalDegeneratesAvg(int coPivots);
inline double coPrimalDegeneratesAvg() { return coPrimalDegeneratesAvg_; }
inline double coCompatibleRowsAvg() { return coCompatibleRowsAvg_; }
void updateCompatibleRowsAvg(int coPivots);
inline double coCompatibleColsAvg() { return coCompatibleColsAvg_; }
void updateCompatibleColsAvg(int coPivots);
inline int coCompatiblePivots() { return coCompatiblePivots_; }
inline void addCompatiblePivot() { coCompatiblePivots_++; }
inline int coDegenerateCompatiblePivots() { return coDegenerateCompatiblePivots_; }
inline void addDegenerateCompatiblePivot() { coDegenerateCompatiblePivots_++; }
/* Get and update the number of compatible pivots that were done because of the priority factor */
inline void addPriorityPivot() { coPriorityPivots_++; }
inline int coPriorityPivots() { return coPriorityPivots_; }
inline int doStatistics() const
{
return doStatistics_;
}
inline void setDoStatistics(int value)
{
doStatistics_ = value;
}
protected:
int coPrimalDegenerates_;
int *primalDegenerates_;
bool *isPrimalDegenerate_;
int coDualDegenerates_;
int *dualDegenerates_;
bool *isDualDegenerate_;
int coCompatibleCols_;
double *compatibilityCol_;
bool *isCompatibleCol_;
int coCompatibleRows_;
double *compatibilityRow_;
bool *isCompatibleRow_;
private:
ClpSimplex *model_;
double epsDegeneracy_;
double epsCompatibility_;
int numberRows_;
int numberColumns_;
// now passed in CoinIndexedVector *wPrimal_;
// now passed in CoinIndexedVector *wDual_;
// not usedCoinIndexedVector *tempColumn_;
double *tempRandom_;
int coPrimalDegeneratesAvg_;
int coDualDegeneratesAvg_;
int coCompatibleColsAvg_;
int coCompatibleRowsAvg_;
int coUpdateDegenerates_;
//int coIdentifyCompatibles_;
int coDegeneratePivots_;
int coCompatiblePivots_;
int coDegenerateCompatiblePivots_;
int coDegeneratePivotsConsecutive_;
int coPriorityPivots_;
int doStatistics_;
double lastObjectiveValue_;
bool isLastPivotCompatible_;
double timeCompatibility_;
double timeMultRandom_;
double timeLinearSystem_;
double timeTmp_;
};
#endif
/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
*/
COIN_RESTRICT
#define COIN_RESTRICT
Definition ClpMatrixBase.hpp:21
PEdot
double PEdot(CoinIndexedVector &v1, const double *v2)
SHARED METHODS FOR USEFUL ALGEBRAIC OPERATIONS.
PEtransposeTimesSubsetAll
void PEtransposeTimesSubsetAll(ClpSimplex *model, int number, const int *which, const double *COIN_RESTRICT x, double *COIN_RESTRICT y, const double *COIN_RESTRICT rowScale, const double *COIN_RESTRICT columnScale)
compute the product x^T*[A I] for the indices "which" of [A I]
ClpPackedMatrix.hpp
ClpSimplex.hpp
ClpPESimplex::coDegenerateCompatiblePivots
int coDegenerateCompatiblePivots()
Definition ClpPESimplex.hpp:136
ClpPESimplex::coDegeneratePivotsConsecutive_
int coDegeneratePivotsConsecutive_
Definition ClpPESimplex.hpp:209
ClpPESimplex::clpModel
ClpSimplex * clpModel()
Definition ClpPESimplex.hpp:65
ClpPESimplex::timeLinearSystem_
double timeLinearSystem_
Definition ClpPESimplex.hpp:224
ClpPESimplex::resetDegeneratePivotsConsecutive
void resetDegeneratePivotsConsecutive()
Definition ClpPESimplex.hpp:124
ClpPESimplex::setDoStatistics
void setDoStatistics(int value)
Definition ClpPESimplex.hpp:146
ClpPESimplex::addDegeneratePivotConsecutive
void addDegeneratePivotConsecutive()
Definition ClpPESimplex.hpp:123
ClpPESimplex::updateDualDegenerates
void updateDualDegenerates()
Updates the set of dual degenerate variables.
ClpPESimplex::coDegenerateCompatiblePivots_
int coDegenerateCompatiblePivots_
Definition ClpPESimplex.hpp:208
ClpPESimplex::checkSize
bool checkSize()
ClpPESimplex::coPrimalDegenerates
int coPrimalDegenerates()
BASIC GET METHODS.
Definition ClpPESimplex.hpp:53
ClpPESimplex::coCompatibleRowsAvg_
int coCompatibleRowsAvg_
Definition ClpPESimplex.hpp:203
ClpPESimplex::updatePrimalDegenerates
void updatePrimalDegenerates()
PUBLIC METHODS RELATED TO COMPATIBILITY.
ClpPESimplex::coCompatibleRows
int coCompatibleRows()
Definition ClpPESimplex.hpp:56
ClpPESimplex::isLastPivotCompatible_
bool isLastPivotCompatible_
Definition ClpPESimplex.hpp:218
ClpPESimplex::isPrimalDegenerate_
bool * isPrimalDegenerate_
Definition ClpPESimplex.hpp:156
ClpPESimplex::coDegeneratePivots_
int coDegeneratePivots_
Definition ClpPESimplex.hpp:206
ClpPESimplex::printTimer
void printTimer(std::ostream &out)
ClpPESimplex::updateCompatibleRows
void updateCompatibleRows(int sequence)
Update the dual compatible rows.
ClpPESimplex::doStatistics
int doStatistics() const
Definition ClpPESimplex.hpp:142
ClpPESimplex::epsDegeneracy_
double epsDegeneracy_
tolerance used for the tests of degeneracy and compatibility (resp.)
Definition ClpPESimplex.hpp:181
ClpPESimplex::timeLinearSystem
double timeLinearSystem()
Definition ClpPESimplex.hpp:117
ClpPESimplex::stopTimer
void stopTimer()
Definition ClpPESimplex.hpp:114
ClpPESimplex::coCompatibleColsAvg_
int coCompatibleColsAvg_
Definition ClpPESimplex.hpp:202
ClpPESimplex::coPriorityPivots_
int coPriorityPivots_
number of compatible pivots that were done because of the priority factor
Definition ClpPESimplex.hpp:212
ClpPESimplex::checkCompatibilityRow
bool checkCompatibilityRow(int pivotRow)
DEBUG AND DISPLAY METHODS.
ClpPESimplex::coDualDegenerates
int coDualDegenerates()
Definition ClpPESimplex.hpp:54
ClpPESimplex::lastObjectiveValue_
double lastObjectiveValue_
tracking the degenerate iterations after compatible pivots
Definition ClpPESimplex.hpp:217
ClpPESimplex::addDegeneratePivot
void addDegeneratePivot()
Update and return the number of degenerate pivots and variables.
Definition ClpPESimplex.hpp:121
ClpPESimplex::numberColumns_
int numberColumns_
Definition ClpPESimplex.hpp:186
ClpPESimplex::addCompatiblePivot
void addCompatiblePivot()
Definition ClpPESimplex.hpp:135
ClpPESimplex::isCompatibleRow_
bool * isCompatibleRow_
Definition ClpPESimplex.hpp:174
ClpPESimplex::coUpdateDegenerates_
int coUpdateDegenerates_
Definition ClpPESimplex.hpp:204
ClpPESimplex::isCompatibleCol_
bool * isCompatibleCol_
Definition ClpPESimplex.hpp:168
ClpPESimplex::coCompatibleCols_
int coCompatibleCols_
Table of booleans indicating whether each variable is primal compatible (true) or not (false).
Definition ClpPESimplex.hpp:166
ClpPESimplex::primalDegenerates_
int * primalDegenerates_
Definition ClpPESimplex.hpp:155
ClpPESimplex::dualDegenerates_
int * dualDegenerates_
Definition ClpPESimplex.hpp:161
ClpPESimplex::coDualDegeneratesAvg_
int coDualDegeneratesAvg_
Definition ClpPESimplex.hpp:201
ClpPESimplex::identifyCompatibleRows
void identifyCompatibleRows(CoinIndexedVector *spare, CoinIndexedVector *wDual)
Identify the dual compatible rows.
ClpPESimplex::updateCompatibleRowsAvg
void updateCompatibleRowsAvg(int coPivots)
ClpPESimplex::updateDualDegeneratesAvg
void updateDualDegeneratesAvg(int coPivots)
ClpPESimplex::coCompatiblePivots
int coCompatiblePivots()
Definition ClpPESimplex.hpp:134
ClpPESimplex::coPrimalDegeneratesAvg_
int coPrimalDegeneratesAvg_
number of degenerate pivots and variables
Definition ClpPESimplex.hpp:200
ClpPESimplex::updateCompatibleColsAvg
void updateCompatibleColsAvg(int coPivots)
ClpPESimplex::isLastPivotCompatible
void isLastPivotCompatible(bool yesOrNo)
Definition ClpPESimplex.hpp:110
ClpPESimplex::isDualDegenerate_
bool * isDualDegenerate_
Definition ClpPESimplex.hpp:162
ClpPESimplex::updatePrimalDegeneratesAvg
void updatePrimalDegeneratesAvg(int coPivots)
ClpPESimplex::doStatistics_
int doStatistics_
Do statistics.
Definition ClpPESimplex.hpp:214
ClpPESimplex::coPrimalDegenerates_
int coPrimalDegenerates_
Indices of the variables that were not at one of their bounds during the last update (non primal dege...
Definition ClpPESimplex.hpp:154
ClpPESimplex::coCompatibleRowsAvg
double coCompatibleRowsAvg()
Definition ClpPESimplex.hpp:130
ClpPESimplex::identifyCompatibleCols
void identifyCompatibleCols(int number, const int *which, CoinIndexedVector *spareRow2, CoinIndexedVector *wPrimal)
Identify the primal compatible columns The input argument is a temporary array that is needed for the...
ClpPESimplex::timeCompatibility_
double timeCompatibility_
Timer attribute recording the additional time spent in identifying compatible variables.
Definition ClpPESimplex.hpp:222
ClpPESimplex::isLastPivotCompatible
bool isLastPivotCompatible()
Definition ClpPESimplex.hpp:109
ClpPESimplex::isCompatibleCol
bool isCompatibleCol(int sequence)
Definition ClpPESimplex.hpp:58
ClpPESimplex::numberRows_
int numberRows_
size of the original model
Definition ClpPESimplex.hpp:185
ClpPESimplex::updateLastObjectiveValue
void updateLastObjectiveValue()
Definition ClpPESimplex.hpp:107
ClpPESimplex::coPriorityPivots
int coPriorityPivots()
Definition ClpPESimplex.hpp:141
ClpPESimplex::timeMultRandom
double timeMultRandom()
Definition ClpPESimplex.hpp:116
ClpPESimplex::epsCompatibility_
double epsCompatibility_
Definition ClpPESimplex.hpp:182
ClpPESimplex::coPrimalDegeneratesAvg
double coPrimalDegeneratesAvg()
Definition ClpPESimplex.hpp:129
ClpPESimplex::timeCompatibility
double timeCompatibility()
Definition ClpPESimplex.hpp:118
ClpPESimplex::lastObjectiveValue
double lastObjectiveValue()
Tracking the degenerate iterations after compatible pivots.
Definition ClpPESimplex.hpp:106
ClpPESimplex::coDualDegeneratesAvg
double coDualDegeneratesAvg()
Definition ClpPESimplex.hpp:127
ClpPESimplex::coCompatiblePivots_
int coCompatiblePivots_
Definition ClpPESimplex.hpp:207
ClpPESimplex::coCompatibleColsAvg
double coCompatibleColsAvg()
Definition ClpPESimplex.hpp:132
ClpPESimplex::tempRandom_
double * tempRandom_
w vectors that are used to identify the compatible columns and rows.
Definition ClpPESimplex.hpp:197
ClpPESimplex::addDegenerateCompatiblePivot
void addDegenerateCompatiblePivot()
Definition ClpPESimplex.hpp:137
ClpPESimplex::coCompatibleRows_
int coCompatibleRows_
Table of booleans indicating whether each constraint is dual compatible (true) or not (false).
Definition ClpPESimplex.hpp:172
ClpPESimplex::compatibilityRow_
double * compatibilityRow_
Definition ClpPESimplex.hpp:173
ClpPESimplex::startTimer
void startTimer()
Start and stop the timer, and print the total recorded time.
Definition ClpPESimplex.hpp:113
ClpPESimplex::coDegeneratePivots
int coDegeneratePivots()
Definition ClpPESimplex.hpp:122
ClpPESimplex::coDegeneratePivotsConsecutive
int coDegeneratePivotsConsecutive()
Definition ClpPESimplex.hpp:125
ClpPESimplex::coDualDegenerates_
int coDualDegenerates_
Indices of the non basic variables with a zero reduced cost during the last update (ndual-degenerate ...
Definition ClpPESimplex.hpp:160
ClpPESimplex::compatibilityCol_
double * compatibilityCol_
Definition ClpPESimplex.hpp:167
ClpPESimplex::timeTmp_
double timeTmp_
Definition ClpPESimplex.hpp:225
ClpPESimplex::model_
ClpSimplex * model_
pointer to the original model that shall be solved
Definition ClpPESimplex.hpp:178
ClpPESimplex::addPriorityPivot
void addPriorityPivot()
Definition ClpPESimplex.hpp:140
ClpPESimplex::coCompatibleCols
int coCompatibleCols()
Definition ClpPESimplex.hpp:55
ClpPESimplex::ClpPESimplex
ClpPESimplex(ClpSimplex *model)
Constructor.
ClpPESimplex::isDegeneratePivot
bool isDegeneratePivot()
Definition ClpPESimplex.hpp:108
ClpPESimplex::timeMultRandom_
double timeMultRandom_
Definition ClpPESimplex.hpp:223
ClpPESimplex::isCompatibleRow
bool isCompatibleRow(int row)
Definition ClpPESimplex.hpp:59
ClpPESimplex::~ClpPESimplex
~ClpPESimplex()
Destructor.
ClpSimplex
This solves LPs using the simplex method.
Definition ClpSimplex.hpp:106