00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef CglRedSplit2_H
00014 #define CglRedSplit2_H
00015
00016 #include "CglCutGenerator.hpp"
00017 #include "CglRedSplit2Param.hpp"
00018 #include "CoinWarmStartBasis.hpp"
00019 #include "CoinHelperFunctions.hpp"
00020 #include "CoinTime.hpp"
00021
00031 class CglRedSplit2 : public CglCutGenerator {
00032
00033 friend void CglRedSplit2UnitTest(const OsiSolverInterface * siP,
00034 const std::string mpdDir);
00035 public:
00081 virtual void generateCuts(const OsiSolverInterface & si, OsiCuts & cs,
00082 const CglTreeInfo info = CglTreeInfo());
00083
00085 virtual bool needsOptimalBasis() const;
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 int generateMultipliers(const OsiSolverInterface& si, int* lambda,
00099 int maxNumMultipliers, int* basicVariables = NULL,
00100 OsiCuts* cs = NULL);
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119 int tiltLandPcut(const OsiSolverInterface* si, double* row,
00120 double rowRhs, int rownumber, const double* xbar,
00121 const int* newnonbasics, OsiRowCut* cs, int* lambda = NULL);
00122
00124
00125
00128
00129
00130 void setParam(const CglRedSplit2Param &source);
00131
00132 inline CglRedSplit2Param& getParam() {return param;}
00133
00135 void print() const;
00136
00138 void printOptTab(OsiSolverInterface *solver) const;
00139
00141
00144
00145 CglRedSplit2();
00146
00148 CglRedSplit2(const CglRedSplit2Param &RS_param);
00149
00151 CglRedSplit2(const CglRedSplit2 &);
00152
00154 virtual CglCutGenerator * clone() const;
00155
00157 CglRedSplit2 & operator=(const CglRedSplit2& rhs);
00158
00160 virtual ~CglRedSplit2 ();
00161
00163
00164 private:
00165
00166
00167
00171
00172
00173
00174
00175
00176
00177 int generateCuts(OsiCuts* cs, int maxNumCuts, int* lambda = NULL);
00178
00180 inline double rs_above_integer(const double value) const;
00181
00188 void fill_workNonBasicTab(CglRedSplit2Param::ColumnSelectionStrategy
00189 strategy, const int* ignore_list = NULL);
00190
00195 void fill_workNonBasicTab(const int* newnonbasics, const double* xbar,
00196 CglRedSplit2Param::ColumnScalingStrategy scaling);
00197
00201 void reduce_workNonBasicTab(int numRows,
00202 CglRedSplit2Param::RowSelectionStrategy
00203 rowSelectionStrategy,
00204 int maxIterations);
00205
00209 void generate_row(int index_row, double *row);
00210
00213 int generate_cgcut(double *row, double *rhs);
00214
00217 void eliminate_slacks(double *row,
00218 const double *elements,
00219 const int *start,
00220 const int *indices,
00221 const int *rowLength,
00222 const double *rhs, double *rowrhs);
00223
00226 void flip(double *row);
00227
00232 void unflip(double *row, double *rowrhs);
00233
00239 int check_dynamism(double *row);
00240
00242 int generate_packed_row(const double *xlp, double *row,
00243 int *rowind, double *rowelem,
00244 int *card_row, double & rhs);
00245
00246
00247 void compute_is_integer();
00248
00249
00250 bool rs_are_different_vectors(const int *vect1,
00251 const int *vect2,
00252 const int dim);
00253
00254
00255 void rs_allocmatINT(int ***v, int m, int n);
00256
00257 void rs_deallocmatINT(int ***v, int m);
00258
00259 void rs_allocmatDBL(double ***v, int m, int n);
00260
00261 void rs_deallocmatDBL(double ***v, int m);
00262
00263 void rs_printvecINT(const char *vecstr, const int *x, int n) const;
00264
00265 void rs_printvecDBL(const char *vecstr, const double *x, int n) const;
00266
00267 void rs_printmatINT(const char *vecstr, const int * const *x, int m, int n) const;
00268
00269 void rs_printmatDBL(const char *vecstr, const double * const *x, int m, int n) const;
00270
00271 double rs_dotProd(const double *u, const double *v, int dim) const;
00272 double rs_dotProd(const int *u, const double *v, int dim) const;
00273
00274 int ludcmp(double **a, int n, int *indx, double *d, double* vv) const;
00275
00276 void lubksb(double **a, int n, int *indx, double *b) const;
00277
00278
00279
00280
00281
00282 double compute_norm_change(double oldnorm, const int* listOfRows,
00283 int numElemList, const double* multipliers) const;
00284
00285
00286 int get_list_rows_reduction(int rowIndex, int numRowsReduction,
00287 int* list, const double* norm,
00288 CglRedSplit2Param::RowSelectionStrategy
00289 rowSelectionStrategy) const;
00290
00291
00292
00293
00294
00295
00296 int sort_rows_by_nonzeroes(struct sortElement* array, int rowIndex,
00297 int maxRows, int whichTab) const;
00298
00299
00300
00301 int sort_rows_by_nonzeroes_greedy(struct sortElement* array, int rowIndex,
00302 int maxRows, int whichTab) const;
00303
00304
00305
00306
00307
00308
00309
00310 int sort_rows_by_cosine(struct sortElement* array, int rowIndex,
00311 int maxRows, int whichTab) const;
00312
00313
00314 inline bool checkTime() const{
00315 if ((CoinCpuTime() - startTime) < param.getTimeLimit()){
00316 return true;
00317 }
00318 return false;
00319 }
00320
00322
00323
00324
00325
00329
00331 CglRedSplit2Param param;
00332
00334 int nrow;
00335
00337 int ncol;
00338
00340 int numRedRows;
00341
00343 const double *colLower;
00344
00346 const double *colUpper;
00347
00349 const double *rowLower;
00350
00352 const double *rowUpper;
00353
00355 const double *rowRhs;
00356
00358 const double *reducedCost;
00359
00361 const double *rowPrice;
00362
00364 const double* objective;
00365
00367 int card_intBasicVar;
00368
00371 int card_intBasicVar_frac;
00372
00375 int card_intNonBasicVar;
00376
00379 int card_contNonBasicVar;
00380
00383 int card_workNonBasicVar;
00384
00387 int card_nonBasicAtUpper;
00388
00391 int card_nonBasicAtLower;
00392
00394 int *cv_intBasicVar;
00395
00398 int *cv_intBasicVar_frac;
00399
00402 int *cv_fracRowsTab;
00403
00406 int *intBasicVar;
00407
00410 int *intBasicVar_frac;
00411
00413 int *intNonBasicVar;
00414
00416
00417 int *contNonBasicVar;
00418
00421 int *nonBasicAtUpper;
00422
00425 int *nonBasicAtLower;
00426
00428 int mTab;
00429
00431 int nTab;
00432
00435 int **pi_mat;
00436
00440 double **contNonBasicTab;
00441
00445 double **workNonBasicTab;
00446
00449
00450 double **intNonBasicTab;
00451
00454 double *rhsTab;
00455
00457 double *norm;
00458
00461 int *is_integer;
00462
00464 OsiSolverInterface *solver;
00465
00467 const double *xlp;
00468
00470 const double *rowActivity;
00471
00474 const CoinPackedMatrix *byRow;
00475
00478 double startTime;
00479
00481 };
00482
00483
00490 void CglRedSplit2UnitTest(const OsiSolverInterface * siP,
00491 const std::string mpdDir );
00492
00493
00494 #endif