- Main Page
- Namespaces
- Classes
- Files
- Directories

- Search for |

- File List
- File Members

# CglRedSplit.hpp

Go to the documentation of this file.

    00001 // Last edit: 4/20/07
    00002 //
    00003 // Name:     CglRedSplit.hpp
    00004 // Author:   Francois Margot
    00005 //           Tepper School of Business
    00006 //           Carnegie Mellon University, Pittsburgh, PA 15213
    00007 //           email: fmargot@andrew.cmu.edu
    00008 // Date:     2/6/05
    00009 //
    00010 // $Id: CglRedSplit.hpp 944 2011-01-04 23:26:07Z lou $
    00011 //-----------------------------------------------------------------------------
    00012 // Copyright (C) 2005, Francois Margot and others.  All Rights Reserved.
    00013 // This code is licensed under the terms of the Eclipse Public License (EPL).
    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   // Set the parameters to the values of the given CglRedSplitParam object.
    00077   void setParam(const CglRedSplitParam &source);
    00078   // Return the CglRedSplitParam object of the generator.
    00079   inline CglRedSplitParam getParam() const {return param;}
    00080
    00081   // Compute entries of low_is_lub and up_is_lub.
    00082   void compute_is_lub();
    00083
    00084   // Compute entries of is_integer.
    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   // TO BE REMOVED
    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   // END TO BE REMOVED
    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   // Private member methods
    00206
    00210
    00211   // Method generating the cuts after all CglRedSplit members are properly set.
    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   // Check that two vectors are different.
    00291   bool rs_are_different_vectors(const int *vect1,
    00292                                 const int *vect2,
    00293                                 const int dim);
    00294
    00295   // Check that two vectors are different.
    00296   bool rs_are_different_vectors(const double *vect1,
    00297                                 const double *vect2,
    00298                                 const int dim);
    00299
    00300   // Check that two matrices are different.
    00301   bool rs_are_different_matrices(const CoinPackedMatrix *mat1,
    00302                                  const CoinPackedMatrix *mat2,
    00303                                  const int nmaj,
    00304                                  const int nmin);
    00306
    00307
    00308   // Private member data
    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   // slacks are considered continuous (no harm if this is not the case).
    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   // Dimensions: mTab by card_intNonBasicVar.
    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