00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CglRedSplit_H
00016 #define CglRedSplit_H
00017
00018 #include "CglCutGenerator.hpp"
00019 #include "CglRedSplitParam.hpp"
00020
00026 class CglRedSplit : public CglCutGenerator {
00027
00028 friend void CglRedSplitUnitTest(const OsiSolverInterface * siP,
00029 const std::string mpdDir);
00030 public:
00061 virtual void generateCuts(const OsiSolverInterface & si, OsiCuts & cs,
00062 const CglTreeInfo info = CglTreeInfo());
00063
00065 virtual void generateCuts(const OsiSolverInterface & si, OsiCuts & cs,
00066 const CglTreeInfo info = CglTreeInfo()) const;
00067
00069 virtual bool needsOptimalBasis() const;
00071
00072
00075
00076
00077 void setParam(const CglRedSplitParam &source);
00078
00079 inline CglRedSplitParam getParam() const {return param;}
00080
00081
00082 void compute_is_lub();
00083
00084
00085 void compute_is_integer();
00086
00092 void set_given_optsol(const double *given_sol, const int card_sol);
00093
00095 void print() const;
00096
00098 void printOptTab(OsiSolverInterface *solver) const;
00099
00101
00104
00105
00108 void setLimit(int limit);
00110 int getLimit() const;
00111
00116 void setAway(double value);
00118 double getAway() const;
00122 void setLUB(double value);
00124 double getLUB() const;
00125
00128 void setEPS(double value);
00130 double getEPS() const;
00131
00134 void setEPS_COEFF(double value);
00136 double getEPS_COEFF() const;
00137
00141 void setEPS_COEFF_LUB(double value);
00143 double getEPS_COEFF_LUB() const;
00144
00148 void setEPS_RELAX(double value);
00150 double getEPS_RELAX() const;
00151
00154 void setNormIsZero(double value);
00156 double getNormIsZero() const;
00157
00160 void setMinReduc(double value);
00162 double getMinReduc() const;
00163
00169 void setMaxTab(double value);
00171 double getMaxTab() const;
00172
00173
00174
00176
00179
00180 CglRedSplit();
00181
00183 CglRedSplit(const CglRedSplitParam &RS_param);
00184
00186 CglRedSplit (const CglRedSplit &);
00187
00189 virtual CglCutGenerator * clone() const;
00190
00192 CglRedSplit &
00193 operator=(
00194 const CglRedSplit& rhs);
00195
00197 virtual
00198 ~CglRedSplit ();
00200 virtual std::string generateCpp( FILE * fp);
00202
00203 private:
00204
00205
00206
00210
00211
00212 void generateCuts(OsiCuts & cs);
00213
00215 inline double rs_above_integer(double value);
00216
00218 void update_pi_mat(int r1, int r2, int step);
00219
00221 void update_redTab(int r1, int r2, int step);
00222
00225 void find_step(int r1, int r2, int *step,
00226 double *reduc, double *norm);
00227
00230 int test_pair(int r1, int r2, double *norm);
00231
00233 void reduce_contNonBasicTab();
00234
00236 void generate_row(int index_row, double *row);
00237
00240 int generate_cgcut(double *row, double *rhs);
00241
00244 int generate_cgcut_2(int basic_ind, double *row, double *rhs);
00245
00248 void eliminate_slacks(double *row,
00249 const double *elements,
00250 const int *start,
00251 const int *indices,
00252 const int *rowLength,
00253 const double *rhs, double *rowrhs);
00254
00257 void flip(double *row);
00258
00263 void unflip(double *row, double *rowrhs, double *slack_val);
00264
00272 double row_scale_factor(double *row);
00273
00275 int generate_packed_row(const double *xlp, double *row,
00276 int *rowind, double *rowelem,
00277 int *card_row, double & rhs);
00278
00280 void check_optsol(const int calling_place,
00281 const double *xlp, const double *slack_val,
00282 const int do_flip);
00283
00285 void check_optsol(const int calling_place,
00286 const double *xlp, const double *slack_val,
00287 const double *ck_row, const double ck_rhs,
00288 const int cut_number, const int do_flip);
00289
00290
00291 bool rs_are_different_vectors(const int *vect1,
00292 const int *vect2,
00293 const int dim);
00294
00295
00296 bool rs_are_different_vectors(const double *vect1,
00297 const double *vect2,
00298 const int dim);
00299
00300
00301 bool rs_are_different_matrices(const CoinPackedMatrix *mat1,
00302 const CoinPackedMatrix *mat2,
00303 const int nmaj,
00304 const int nmin);
00306
00307
00308
00309
00313
00315 CglRedSplitParam param;
00316
00318 int nrow;
00319
00321 int ncol;
00322
00324 const double *colLower;
00325
00327 const double *colUpper;
00328
00330 const double *rowLower;
00331
00333 const double *rowUpper;
00334
00336 const double *rowRhs;
00337
00340 int card_intBasicVar_frac;
00341
00344 int card_intNonBasicVar;
00345
00348 int card_contNonBasicVar;
00349
00352 int card_nonBasicAtUpper;
00353
00356 int card_nonBasicAtLower;
00357
00360 int *cv_intBasicVar_frac;
00361
00364 int *intBasicVar_frac;
00365
00367 int *intNonBasicVar;
00368
00370
00371 int *contNonBasicVar;
00372
00375 int *nonBasicAtUpper;
00376
00379 int *nonBasicAtLower;
00380
00382 int mTab;
00383
00385 int nTab;
00386
00389 int **pi_mat;
00390
00394 double **contNonBasicTab;
00395
00398
00399 double **intNonBasicTab;
00400
00403 double *rhsTab ;
00404
00406 const double *given_optsol;
00407
00409 int card_given_optsol;
00410
00413 int *is_integer;
00414
00417 int *low_is_lub;
00418
00421 int *up_is_lub;
00422
00424 OsiSolverInterface *solver;
00425
00427 const double *xlp;
00428
00430 const double *rowActivity;
00431
00433 const char *colType;
00434
00437 const CoinPackedMatrix *byRow;
00438
00440 };
00441
00442
00448 void CglRedSplitUnitTest(const OsiSolverInterface * siP,
00449 const std::string mpdDir );
00450
00451
00452 #endif