Ignore:
Timestamp:
Jan 6, 2019 2:43:06 PM (4 months ago)
Author:
unxusr
Message:

formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/src/ClpPESimplex.hpp

    r2150 r2385  
    2121#include <fstream>
    2222
    23 
    2423// #define PE_DEBUG 0
    2524
    2625/** SHARED METHODS FOR USEFUL ALGEBRAIC OPERATIONS */
    2726
    28 /** inner product between a coin vector and a pointer */ 
    29 double PEdot(CoinIndexedVector& v1, const double* v2);
     27/** inner product between a coin vector and a pointer */
     28double PEdot(CoinIndexedVector &v1, const double *v2);
    3029
    3130/** inner product between two coin vectors
    32     call the function with the sparser vector first for efficiency */ 
    33 double PEdot(CoinIndexedVector& v1, CoinIndexedVector& v2);
     31    call the function with the sparser vector first for efficiency */
     32double PEdot(CoinIndexedVector &v1, CoinIndexedVector &v2);
    3433
    3534/** compute the product x^T*[A I] for the indices "which" of [A I] */
    36 void PEtransposeTimesSubsetAll(ClpSimplex* model, int number, const int * which,
    37                             const double * COIN_RESTRICT x, double * COIN_RESTRICT y,
    38                             const double * COIN_RESTRICT rowScale,
    39                             const double * COIN_RESTRICT columnScale);
    40 
     35void PEtransposeTimesSubsetAll(ClpSimplex *model, int number, const int *which,
     36  const double *COIN_RESTRICT x, double *COIN_RESTRICT y,
     37  const double *COIN_RESTRICT rowScale,
     38  const double *COIN_RESTRICT columnScale);
    4139
    4240/** BASE CLASS FOR THE IMPROVED SIMPLEX
     
    4543
    4644public:
    47 
    48      /** Constructor */
    49     ClpPESimplex(ClpSimplex *model);
    50 
    51     /** Destructor */
    52     ~ClpPESimplex();
    53 
    54 /** BASIC GET METHODS */
    55 public:
    56     inline int coPrimalDegenerates() {return coPrimalDegenerates_;}
    57     inline int coDualDegenerates() {return coDualDegenerates_;}
    58     inline int coCompatibleCols() {return coCompatibleCols_;}
    59     inline int coCompatibleRows() {return coCompatibleRows_;}
    60 
    61     inline bool isCompatibleCol(int sequence) {return isCompatibleCol_[sequence];}
    62     inline bool isCompatibleRow(int row) {
    63       assert (row>=0&&row<numberRows_);
    64       return isCompatibleRow_[row];}
    65 
    66     inline ClpSimplex* clpModel() {return model_;}
    67     // check seems to be same model - returns false if size changed
    68     bool checkSize();
    69 /** PUBLIC METHODS RELATED TO COMPATIBILITY */
    70 public:
    71     /** Updates the set of variables that are not at their bounds */
    72     void updatePrimalDegenerates();
    73 
    74     /** Updates the set of dual degenerate variables */
    75     void updateDualDegenerates();
    76 
    77     /** Identify the primal compatible columns
     45  /** Constructor */
     46  ClpPESimplex(ClpSimplex *model);
     47
     48  /** Destructor */
     49  ~ClpPESimplex();
     50
     51  /** BASIC GET METHODS */
     52public:
     53  inline int coPrimalDegenerates() { return coPrimalDegenerates_; }
     54  inline int coDualDegenerates() { return coDualDegenerates_; }
     55  inline int coCompatibleCols() { return coCompatibleCols_; }
     56  inline int coCompatibleRows() { return coCompatibleRows_; }
     57
     58  inline bool isCompatibleCol(int sequence) { return isCompatibleCol_[sequence]; }
     59  inline bool isCompatibleRow(int row)
     60  {
     61    assert(row >= 0 && row < numberRows_);
     62    return isCompatibleRow_[row];
     63  }
     64
     65  inline ClpSimplex *clpModel() { return model_; }
     66  // check seems to be same model - returns false if size changed
     67  bool checkSize();
     68  /** PUBLIC METHODS RELATED TO COMPATIBILITY */
     69public:
     70  /** Updates the set of variables that are not at their bounds */
     71  void updatePrimalDegenerates();
     72
     73  /** Updates the set of dual degenerate variables */
     74  void updateDualDegenerates();
     75
     76  /** Identify the primal compatible columns
    7877        The input argument is a temporary array that is needed for the Clp's BTRAN */
    79     void identifyCompatibleCols(int number, const int *which,
    80                                 CoinIndexedVector * spareRow2,
    81                                 CoinIndexedVector * wPrimal);
    82 
    83     /** Identify the dual compatible rows */
    84     void identifyCompatibleRows(CoinIndexedVector * spare,
    85                                 CoinIndexedVector * wDual);
    86 
    87     /** Update the dual compatible rows */
    88     void updateCompatibleRows(int sequence);
    89 
    90 
    91 /** DEBUG AND DISPLAY METHODS */
    92 public:
    93     #if PE_DEBUG >= 1
    94     /** Print the set of variables within their bounds */
    95     void printPrimalDegenerates();
    96 
    97     /** Print the set of primal compatible variables */
    98     void printCompatibleCols();
    99 
    100     /** Check that a nonbasic variable is indeed compatible */
    101     bool checkCompatibilityCol(int sequence, CoinIndexedVector* spareRow2);
    102     #endif
    103 
    104     /** Check that a basic row is indeed compatible */
    105     bool checkCompatibilityRow(int pivotRow);
    106 
    107     /** Tracking the degenerate iterations after compatible pivots */
    108     inline double lastObjectiveValue() {return lastObjectiveValue_;}
    109     inline void updateLastObjectiveValue() {lastObjectiveValue_ = model_->objectiveValue();}
    110     inline bool isDegeneratePivot() {return fabs(model_->objectiveValue() -lastObjectiveValue_) < model_->dualTolerance();}
    111     inline bool isLastPivotCompatible() {return isLastPivotCompatible_;}
    112     inline void isLastPivotCompatible(bool yesOrNo) {isLastPivotCompatible_ = yesOrNo;}
    113 
    114     /** Start and stop the timer, and print the total recorded time */
    115     inline void startTimer() {timeTmp_  = CoinCpuTime();}
    116     inline void stopTimer() {timeCompatibility_ += CoinCpuTime() - timeTmp_;}
    117     void printTimer(std::ostream &out);
    118     inline double timeMultRandom() {return timeMultRandom_;}
    119     inline double timeLinearSystem() {return timeLinearSystem_;}
    120     inline double timeCompatibility() {return timeCompatibility_;}
    121 
    122     /** Update and return the number of degenerate pivots and variables */
    123     inline void addDegeneratePivot() {coDegeneratePivots_++;}
    124     inline int coDegeneratePivots() {return coDegeneratePivots_;}
    125     inline void addDegeneratePivotConsecutive() {coDegeneratePivotsConsecutive_++;}
    126     inline void resetDegeneratePivotsConsecutive() {coDegeneratePivotsConsecutive_ = 0;}
    127     inline int coDegeneratePivotsConsecutive() {return coDegeneratePivotsConsecutive_;}
    128     void updateDualDegeneratesAvg(int coPivots);
    129     inline double coDualDegeneratesAvg() {return coDualDegeneratesAvg_;}
    130     void updatePrimalDegeneratesAvg(int coPivots);
    131     inline double coPrimalDegeneratesAvg() {return coPrimalDegeneratesAvg_;}
    132     inline double coCompatibleRowsAvg() {return coCompatibleRowsAvg_;}
    133     void updateCompatibleRowsAvg(int coPivots);
    134     inline double coCompatibleColsAvg() {return coCompatibleColsAvg_;}
    135     void updateCompatibleColsAvg(int coPivots);
    136     inline int coCompatiblePivots() {return coCompatiblePivots_;}
    137     inline void addCompatiblePivot() {coCompatiblePivots_++;}
    138     inline int coDegenerateCompatiblePivots() {return coDegenerateCompatiblePivots_;}
    139     inline void addDegenerateCompatiblePivot() {coDegenerateCompatiblePivots_++;}
    140 
    141     /* Get and update the number of compatible pivots that were done because of the priority factor */
    142     inline void addPriorityPivot() {coPriorityPivots_++;}
    143     inline int coPriorityPivots() {return coPriorityPivots_;}
    144     inline int doStatistics() const
    145     { return doStatistics_;}
    146     inline void setDoStatistics(int value)
    147     { doStatistics_ = value;}
     78  void identifyCompatibleCols(int number, const int *which,
     79    CoinIndexedVector *spareRow2,
     80    CoinIndexedVector *wPrimal);
     81
     82  /** Identify the dual compatible rows */
     83  void identifyCompatibleRows(CoinIndexedVector *spare,
     84    CoinIndexedVector *wDual);
     85
     86  /** Update the dual compatible rows */
     87  void updateCompatibleRows(int sequence);
     88
     89  /** DEBUG AND DISPLAY METHODS */
     90public:
     91#if PE_DEBUG >= 1
     92  /** Print the set of variables within their bounds */
     93  void printPrimalDegenerates();
     94
     95  /** Print the set of primal compatible variables */
     96  void printCompatibleCols();
     97
     98  /** Check that a nonbasic variable is indeed compatible */
     99  bool checkCompatibilityCol(int sequence, CoinIndexedVector *spareRow2);
     100#endif
     101
     102  /** Check that a basic row is indeed compatible */
     103  bool checkCompatibilityRow(int pivotRow);
     104
     105  /** Tracking the degenerate iterations after compatible pivots */
     106  inline double lastObjectiveValue() { return lastObjectiveValue_; }
     107  inline void updateLastObjectiveValue() { lastObjectiveValue_ = model_->objectiveValue(); }
     108  inline bool isDegeneratePivot() { return fabs(model_->objectiveValue() - lastObjectiveValue_) < model_->dualTolerance(); }
     109  inline bool isLastPivotCompatible() { return isLastPivotCompatible_; }
     110  inline void isLastPivotCompatible(bool yesOrNo) { isLastPivotCompatible_ = yesOrNo; }
     111
     112  /** Start and stop the timer, and print the total recorded time */
     113  inline void startTimer() { timeTmp_ = CoinCpuTime(); }
     114  inline void stopTimer() { timeCompatibility_ += CoinCpuTime() - timeTmp_; }
     115  void printTimer(std::ostream &out);
     116  inline double timeMultRandom() { return timeMultRandom_; }
     117  inline double timeLinearSystem() { return timeLinearSystem_; }
     118  inline double timeCompatibility() { return timeCompatibility_; }
     119
     120  /** Update and return the number of degenerate pivots and variables */
     121  inline void addDegeneratePivot() { coDegeneratePivots_++; }
     122  inline int coDegeneratePivots() { return coDegeneratePivots_; }
     123  inline void addDegeneratePivotConsecutive() { coDegeneratePivotsConsecutive_++; }
     124  inline void resetDegeneratePivotsConsecutive() { coDegeneratePivotsConsecutive_ = 0; }
     125  inline int coDegeneratePivotsConsecutive() { return coDegeneratePivotsConsecutive_; }
     126  void updateDualDegeneratesAvg(int coPivots);
     127  inline double coDualDegeneratesAvg() { return coDualDegeneratesAvg_; }
     128  void updatePrimalDegeneratesAvg(int coPivots);
     129  inline double coPrimalDegeneratesAvg() { return coPrimalDegeneratesAvg_; }
     130  inline double coCompatibleRowsAvg() { return coCompatibleRowsAvg_; }
     131  void updateCompatibleRowsAvg(int coPivots);
     132  inline double coCompatibleColsAvg() { return coCompatibleColsAvg_; }
     133  void updateCompatibleColsAvg(int coPivots);
     134  inline int coCompatiblePivots() { return coCompatiblePivots_; }
     135  inline void addCompatiblePivot() { coCompatiblePivots_++; }
     136  inline int coDegenerateCompatiblePivots() { return coDegenerateCompatiblePivots_; }
     137  inline void addDegenerateCompatiblePivot() { coDegenerateCompatiblePivots_++; }
     138
     139  /* Get and update the number of compatible pivots that were done because of the priority factor */
     140  inline void addPriorityPivot() { coPriorityPivots_++; }
     141  inline int coPriorityPivots() { return coPriorityPivots_; }
     142  inline int doStatistics() const
     143  {
     144    return doStatistics_;
     145  }
     146  inline void setDoStatistics(int value)
     147  {
     148    doStatistics_ = value;
     149  }
     150
    148151protected:
    149     /** Indices of the variables that were not at one of their bounds
     152  /** Indices of the variables that were not at one of their bounds
    150153        during the last update (non primal degenerate variables) */
    151     int coPrimalDegenerates_;
    152     int *primalDegenerates_;
    153     bool *isPrimalDegenerate_;
    154 
    155     /** Indices of the non basic variables with a zero reduced cost
     154  int coPrimalDegenerates_;
     155  int *primalDegenerates_;
     156  bool *isPrimalDegenerate_;
     157
     158  /** Indices of the non basic variables with a zero reduced cost
    156159        during the last update (ndual-degenerate variables) */
    157     int coDualDegenerates_;
    158     int *dualDegenerates_;
    159     bool *isDualDegenerate_;
    160 
    161     /** Table of booleans indicating whether each variable is primal
     160  int coDualDegenerates_;
     161  int *dualDegenerates_;
     162  bool *isDualDegenerate_;
     163
     164  /** Table of booleans indicating whether each variable is primal
    162165        compatible (true) or not (false) */
    163     int coCompatibleCols_;
    164     double* compatibilityCol_;
    165     bool *isCompatibleCol_;
    166 
    167     /** Table of booleans indicating whether each constraint is dual
     166  int coCompatibleCols_;
     167  double *compatibilityCol_;
     168  bool *isCompatibleCol_;
     169
     170  /** Table of booleans indicating whether each constraint is dual
    168171        compatible (true) or not (false) */
    169     int coCompatibleRows_;
    170     double* compatibilityRow_;
    171     bool *isCompatibleRow_;
    172 
    173   private:
    174     /** pointer to the original model that shall be solved */
    175     ClpSimplex * model_;
    176 
    177     /** tolerance used for the tests of degeneracy and compatibility (resp.) */
    178     double epsDegeneracy_;
    179     double epsCompatibility_;
    180 
    181     /** size of the original model */
    182     int numberRows_;
    183     int numberColumns_;
    184 
    185     /** w vectors that are used to identify the compatible columns and
     172  int coCompatibleRows_;
     173  double *compatibilityRow_;
     174  bool *isCompatibleRow_;
     175
     176private:
     177  /** pointer to the original model that shall be solved */
     178  ClpSimplex *model_;
     179
     180  /** tolerance used for the tests of degeneracy and compatibility (resp.) */
     181  double epsDegeneracy_;
     182  double epsCompatibility_;
     183
     184  /** size of the original model */
     185  int numberRows_;
     186  int numberColumns_;
     187
     188  /** w vectors that are used to identify the compatible columns and
    186189    rows. The name w, refers to the notations of the articles on
    187190    positive edge */
    188     // now passed in CoinIndexedVector *wPrimal_;
    189     // now passed in CoinIndexedVector *wDual_;
    190 
    191     /** temporary vectors that are used to store colulns of the constraint
     191  // now passed in CoinIndexedVector *wPrimal_;
     192  // now passed in CoinIndexedVector *wDual_;
     193
     194  /** temporary vectors that are used to store colulns of the constraint
    192195        matrix or random numbers */
    193     // not usedCoinIndexedVector *tempColumn_;
    194     double *tempRandom_;
    195 
    196     /** number of degenerate pivots and variables */
    197     int coPrimalDegeneratesAvg_;
    198     int coDualDegeneratesAvg_;
    199     int coCompatibleColsAvg_;
    200     int coCompatibleRowsAvg_;
    201     int coUpdateDegenerates_;
    202     int coIdentifyCompatibles_;
    203     int coDegeneratePivots_;
    204     int coCompatiblePivots_;
    205     int coDegenerateCompatiblePivots_;
    206     int coDegeneratePivotsConsecutive_;
    207 
    208 
    209     /** number of compatible pivots that were done because of the priority factor */
    210     int coPriorityPivots_;
    211     /// Do statistics
    212     int doStatistics_;
    213 
    214     /** tracking the degenerate iterations after compatible pivots */
    215     double lastObjectiveValue_;
    216     bool isLastPivotCompatible_;
    217 
    218     /** Timer attribute recording the additional time spent in
     196  // not usedCoinIndexedVector *tempColumn_;
     197  double *tempRandom_;
     198
     199  /** number of degenerate pivots and variables */
     200  int coPrimalDegeneratesAvg_;
     201  int coDualDegeneratesAvg_;
     202  int coCompatibleColsAvg_;
     203  int coCompatibleRowsAvg_;
     204  int coUpdateDegenerates_;
     205  int coIdentifyCompatibles_;
     206  int coDegeneratePivots_;
     207  int coCompatiblePivots_;
     208  int coDegenerateCompatiblePivots_;
     209  int coDegeneratePivotsConsecutive_;
     210
     211  /** number of compatible pivots that were done because of the priority factor */
     212  int coPriorityPivots_;
     213  /// Do statistics
     214  int doStatistics_;
     215
     216  /** tracking the degenerate iterations after compatible pivots */
     217  double lastObjectiveValue_;
     218  bool isLastPivotCompatible_;
     219
     220  /** Timer attribute recording the additional time spent in
    219221        identifying compatible variables */
    220     double timeCompatibility_;
    221     double timeMultRandom_;
    222     double timeLinearSystem_;
    223     double timeTmp_;
    224 
    225 };
     222  double timeCompatibility_;
     223  double timeMultRandom_;
     224  double timeLinearSystem_;
     225  double timeTmp_;
     226};
    226227
    227228#endif
     229
     230/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
     231*/
Note: See TracChangeset for help on using the changeset viewer.