00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef CglRedSplit_H
00013 #define CglRedSplit_H
00014
00015 #include "CglCutGenerator.hpp"
00016 #include "CglRedSplitParam.hpp"
00017
00023 class CglRedSplit : public CglCutGenerator {
00024
00025 friend void CglRedSplitUnitTest(const OsiSolverInterface * siP,
00026 const std::string mpdDir);
00027 public:
00058 virtual void generateCuts(const OsiSolverInterface & si, OsiCuts & cs,
00059 const CglTreeInfo info = CglTreeInfo());
00060
00062 virtual void generateCuts(const OsiSolverInterface & si, OsiCuts & cs,
00063 const CglTreeInfo info = CglTreeInfo()) const;
00064
00066 virtual bool needsOptimalBasis() const;
00068
00069
00072
00073
00074 void setParam(const CglRedSplitParam &source);
00075
00076 inline CglRedSplitParam getParam() const {return param;}
00077
00078
00079 void compute_is_lub();
00080
00081
00082 void compute_is_integer();
00083
00089 void set_given_optsol(const double *given_sol, const int card_sol);
00090
00092 void print() const;
00093
00095 void printOptTab(OsiSolverInterface *solver) const;
00096
00098
00101
00102
00105 void setLimit(int limit);
00107 int getLimit() const;
00108
00113 void setAway(double value);
00115 double getAway() const;
00119 void setLUB(double value);
00121 double getLUB() const;
00122
00125 void setEPS(double value);
00127 double getEPS() const;
00128
00131 void setEPS_COEFF(double value);
00133 double getEPS_COEFF() const;
00134
00138 void setEPS_COEFF_LUB(double value);
00140 double getEPS_COEFF_LUB() const;
00141
00145 void setEPS_RELAX(double value);
00147 double getEPS_RELAX() const;
00148
00151 void setNormIsZero(double value);
00153 double getNormIsZero() const;
00154
00157 void setMinReduc(double value);
00159 double getMinReduc() const;
00160
00166 void setMaxTab(double value);
00168 double getMaxTab() const;
00169
00170
00171
00173
00176
00177 CglRedSplit();
00178
00180 CglRedSplit(const CglRedSplitParam &RS_param);
00181
00183 CglRedSplit (const CglRedSplit &);
00184
00186 virtual CglCutGenerator * clone() const;
00187
00189 CglRedSplit &
00190 operator=(
00191 const CglRedSplit& rhs);
00192
00194 virtual
00195 ~CglRedSplit ();
00197 virtual std::string generateCpp( FILE * fp);
00199
00200 private:
00201
00202
00203
00207
00208
00209 void generateCuts(OsiCuts & cs);
00210
00212 inline double rs_above_integer(double value);
00213
00215 void update_pi_mat(int r1, int r2, int step);
00216
00218 void update_redTab(int r1, int r2, int step);
00219
00222 void find_step(int r1, int r2, int *step,
00223 double *reduc, double *norm);
00224
00227 int test_pair(int r1, int r2, double *norm);
00228
00230 void reduce_contNonBasicTab();
00231
00233 void generate_row(int index_row, double *row);
00234
00237 int generate_cgcut(double *row, double *rhs);
00238
00241 int generate_cgcut_2(int basic_ind, double *row, double *rhs);
00242
00245 void eliminate_slacks(double *row,
00246 const double *elements,
00247 const int *start,
00248 const int *indices,
00249 const int *rowLength,
00250 const double *rhs, double *rowrhs);
00251
00254 void flip(double *row);
00255
00260 void unflip(double *row, double *rowrhs, double *slack_val);
00261
00269 double row_scale_factor(double *row);
00270
00272 int generate_packed_row(const double *xlp, double *row,
00273 int *rowind, double *rowelem,
00274 int *card_row, double & rhs);
00275
00277 void check_optsol(const int calling_place,
00278 const double *xlp, const double *slack_val,
00279 const int do_flip);
00280
00282 void check_optsol(const int calling_place,
00283 const double *xlp, const double *slack_val,
00284 const double *ck_row, const double ck_rhs,
00285 const int cut_number, const int do_flip);
00286
00287
00288 bool rs_are_different_vectors(const int *vect1,
00289 const int *vect2,
00290 const int dim);
00291
00292
00293 bool rs_are_different_vectors(const double *vect1,
00294 const double *vect2,
00295 const int dim);
00296
00297
00298 bool rs_are_different_matrices(const CoinPackedMatrix *mat1,
00299 const CoinPackedMatrix *mat2,
00300 const int nmaj,
00301 const int nmin);
00303
00304
00305
00306
00310
00312 CglRedSplitParam param;
00313
00315 int nrow;
00316
00318 int ncol;
00319
00321 const double *colLower;
00322
00324 const double *colUpper;
00325
00327 const double *rowLower;
00328
00330 const double *rowUpper;
00331
00333 const double *rowRhs;
00334
00337 int card_intBasicVar_frac;
00338
00341 int card_intNonBasicVar;
00342
00345 int card_contNonBasicVar;
00346
00349 int card_nonBasicAtUpper;
00350
00353 int card_nonBasicAtLower;
00354
00357 int *cv_intBasicVar_frac;
00358
00361 int *intBasicVar_frac;
00362
00364 int *intNonBasicVar;
00365
00367
00368 int *contNonBasicVar;
00369
00372 int *nonBasicAtUpper;
00373
00376 int *nonBasicAtLower;
00377
00379 int mTab;
00380
00382 int nTab;
00383
00386 int **pi_mat;
00387
00391 double **contNonBasicTab;
00392
00395
00396 double **intNonBasicTab;
00397
00400 double *rhsTab ;
00401
00403 const double *given_optsol;
00404
00406 int card_given_optsol;
00407
00410 int *is_integer;
00411
00414 int *low_is_lub;
00415
00418 int *up_is_lub;
00419
00421 OsiSolverInterface *solver;
00422
00424 const double *xlp;
00425
00427 const double *rowActivity;
00428
00430 const char *colType;
00431
00434 const CoinPackedMatrix *byRow;
00435
00437 };
00438
00439
00445 void CglRedSplitUnitTest(const OsiSolverInterface * siP,
00446 const std::string mpdDir );
00447
00448
00449 #endif