CglGMIParam.hpp 11.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
// Name:     CglGMIParam.hpp
// Author:   Giacomo Nannicini
//           Singapore University of Technology and Design
//           email: nannicini@sutd.edu.sg
//           based on CglRedSplitParam.hpp by Francois Margot
// Date:     11/17/09
//-----------------------------------------------------------------------------
// Copyright (C) 2009, Giacomo Nannicini and others.  All Rights Reserved.

#ifndef CglGMIParam_H
#define CglGMIParam_H

#include "CglParam.hpp"


  /**@name CglGMI Parameters */
  //@{

  /** Class collecting parameters for the GMI cut generator.

      Parameters of the generator are listed below. Modifying the default 
      values for parameters other than the last four might result in 
      invalid cuts.

      - MAXDYN: Maximum ratio between largest and smallest non zero 
                coefficients in a cut. See method setMAXDYN().
      - EPS_ELIM: Precision for deciding if a coefficient is zero when 
                  eliminating slack variables. See method setEPS_ELIM().
      - MINVIOL: Minimum violation for the current basic solution in 
                 a generated cut. See method setMINVIOL().
      - USE_INTSLACKS: Use integer slacks to generate cuts. 
                       (not implemented yet, will be in the future).
                       See method setUSE_INTSLACKS().
      - AWAY: Look only at basic integer variables whose current value is at
              least this value away from being integer. See method setAway().
      - CHECK_DUPLICATES: Should we check for duplicates when adding a cut
                          to the collection? Can be slow. 
                          Default 0 - do not check, add cuts anyway.
      - CLEAN_PROC: Cleaning procedure that should be used. Look below at the
                    enumeration CleaningProcedure for possible values.
      - INTEGRAL_SCALE_CONT: If we try to scale cut coefficients so that
                             they become integral, do we also scale on 
			     continuous variables?
			     Default 0 - do not scale continuous vars.
			     Used only if CLEAN_PROC does integral scaling.
      - ENFORCE_SCALING: Discard badly scaled cuts, or keep them (unscaled).
                         Default 1 - yes.

  */
  //@}

class CglGMIParam : public CglParam {

public:

  /**@name Enumerations */
  enum CleaningProcedure{
    /* CglLandP procedure I */
    CP_CGLLANDP1,
    /* CglLandP procedure II */
    CP_CGLLANDP2,
    /* CglRedSplit procedure I */
    CP_CGLREDSPLIT,
    /* Only integral cuts, i.e. cuts with integral coefficients */
    CP_INTEGRAL_CUTS,
    /* CglLandP procedure I with integral scaling */
    CP_CGLLANDP1_INT,
    /* CglLandP procedure I with scaling of the max element to 1 if possible */
    CP_CGLLANDP1_SCALEMAX,
    /* CglLandP procedure I with scaling of the rhs to 1 if possible */
    CP_CGLLANDP1_SCALERHS
  };

  /**@name Set/get methods */

  //@{
  /** Aliases for parameter get/set method in the base class CglParam */
  
  /** Value for Infinity. Default: DBL_MAX */
  inline void setInfinity(double value) {setINFINIT(value);}
  inline double getInfinity() const {return INFINIT;}

  /** Epsilon for comparing numbers. Default: 1.0e-6  */
  inline void setEps(double value) {setEPS(value);}
  inline double getEps() const {return EPS;}

  /** Epsilon for zeroing out coefficients. Default: 1.0e-5 */
  inline void setEpsCoeff(double value) {setEPS_COEFF(value);}
  inline double getEpsCoeff() const {return EPS_COEFF;}

  /** Maximum support of the cutting planes. Default: INT_MAX */
  inline void setMaxSupport(int value) {setMAX_SUPPORT(value);}
  inline int getMaxSupport() const {return MAX_SUPPORT;}
  /** Alias for consistency with our naming scheme */
  inline void setMaxSupportAbs(int value) {setMAX_SUPPORT(value);}
  inline int getMaxSupportAbs() const {return MAX_SUPPORT;}
  inline int getMAX_SUPPORT_ABS() const {return MAX_SUPPORT;}

  /** Set AWAY, the minimum distance from being integer used for selecting 
      rows for cut generation;  all rows whose pivot variable should be 
      integer but is more than away from integrality will be selected; 
      Default: 0.005 */
  virtual void setAway(double value);
  /** Get value of away */
  inline double getAway() const {return AWAY;}
  /// Aliases
  inline void setAWAY(double value) {setAway(value);}
  inline double getAWAY() const {return AWAY;}

  /** Set the value of EPS_ELIM, epsilon for values of coefficients when 
      eliminating slack variables;
      Default: 0 */
  virtual void setEPS_ELIM(double value);
  /** Get the value of EPS_ELIM */
  inline double getEPS_ELIM() const {return EPS_ELIM;}
  /// Aliases
  inline void setEpsElim(double value) {setEPS_ELIM(value);}
  inline double getEpsElim() const {return EPS_ELIM;}
  
  /** Set EPS_RELAX_ABS */
  virtual void setEPS_RELAX_ABS(double value);
  /** Get value of EPS_RELAX_ABS */
  inline double getEPS_RELAX_ABS() const {return EPS_RELAX_ABS;}
  /// Aliases
  inline void setEpsRelaxAbs(double value) {setEPS_RELAX_ABS(value);}
  inline double getEpsRelaxAbs() const {return EPS_RELAX_ABS;}

  /** Set EPS_RELAX_REL */
  virtual void setEPS_RELAX_REL(double value);
  /** Get value of EPS_RELAX_REL */
  inline double getEPS_RELAX_REL() const {return EPS_RELAX_REL;}
  /// Aliases
  inline void setEpsRelaxRel(double value) {setEPS_RELAX_REL(value);}
  inline double getEpsRelaxRel() const {return EPS_RELAX_REL;}

  // Set the maximum ratio between largest and smallest non zero 
  // coefficients in a cut. Default: 1e6.
  virtual void setMAXDYN(double value);
  /** Get the value of MAXDYN */
  inline double getMAXDYN() const {return MAXDYN;}
  /// Aliases
  inline void setMaxDyn(double value) {setMAXDYN(value);}
  inline double getMaxDyn() const {return MAXDYN;}

  /** Set the value of MINVIOL, the minimum violation for the current 
      basic solution in a generated cut. Default: 1e-7 */
  virtual void setMINVIOL(double value);
  /** Get the value of MINVIOL */
  inline double getMINVIOL() const {return MINVIOL;}
  /// Aliases
  inline void setMinViol(double value) {setMINVIOL(value);}
  inline double getMinViol() const {return MINVIOL;}

  /** Set the value of MAX_SUPPORT_REL, the factor contributing to the
      maximum support relative to the number of columns. Maximum
      allowed support is: MAX_SUPPORT_ABS +
      MAX_SUPPORT_REL*ncols. Default: 0.1 */
  virtual void setMAX_SUPPORT_REL(double value);
  /** Get the value of MINVIOL */
  inline double getMAX_SUPPORT_REL() const {return MAX_SUPPORT_REL;}
  /// Aliases
  inline void setMaxSupportRel(double value) {setMAX_SUPPORT_REL(value);}
  inline double getMaxSupportRel() const {return MAX_SUPPORT_REL;}

  /** Set the value of USE_INTSLACKS. Default: 0 */
  virtual void setUSE_INTSLACKS(bool value);
  /** Get the value of USE_INTSLACKS */
  inline bool getUSE_INTSLACKS() const {return USE_INTSLACKS;}
  /// Aliases
  inline void setUseIntSlacks(bool value) {setUSE_INTSLACKS(value);}
  inline int getUseIntSlacks() const {return USE_INTSLACKS;}

  /** Set the value of CHECK_DUPLICATES. Default: 0 */
  virtual void setCHECK_DUPLICATES(bool value);
  /** Get the value of CHECK_DUPLICATES */
  inline bool getCHECK_DUPLICATES() const {return CHECK_DUPLICATES;}
  /// Aliases
  inline void setCheckDuplicates(bool value) {setCHECK_DUPLICATES(value);}
  inline bool getCheckDuplicates() const {return CHECK_DUPLICATES;}

  /** Set the value of CLEAN_PROC. Default: CP_CGLLANDP1 */
  virtual void setCLEAN_PROC(CleaningProcedure value);
  /** Get the value of CLEAN_PROC. */
  inline CleaningProcedure getCLEAN_PROC() const {return CLEAN_PROC;}
  /// Aliases
  inline void setCleanProc(CleaningProcedure value) {setCLEAN_PROC(value);}
  inline CleaningProcedure getCleaningProcedure() const {return CLEAN_PROC;}

  /** Set the value of INTEGRAL_SCALE_CONT. Default: 0 */
  virtual void setINTEGRAL_SCALE_CONT(bool value);
  /** Get the value of INTEGRAL_SCALE_CONT. */
  inline bool getINTEGRAL_SCALE_CONT() const {return INTEGRAL_SCALE_CONT;}
  /// Aliases
  inline void setIntegralScaleCont(bool value) {setINTEGRAL_SCALE_CONT(value);}
  inline bool getIntegralScaleCont() const {return INTEGRAL_SCALE_CONT;}

  /** Set the value of ENFORCE_SCALING. Default: 1 */
  virtual void setENFORCE_SCALING(bool value);
  /** Get the value of ENFORCE_SCALING. */
  inline bool getENFORCE_SCALING() const {return ENFORCE_SCALING;}
  /// Aliases
  inline void setEnforceScaling(bool value) {setENFORCE_SCALING(value);}
  inline bool getEnforcescaling() const {return ENFORCE_SCALING;}

  //@}

  /**@name Constructors and destructors */
  //@{
  /// Default constructor 
  CglGMIParam(double eps = 1e-12,
	      double away = 0.005,
	      double eps_coeff = 1e-11,
	      double eps_elim = 0,
	      double eps_relax_abs = 1e-11,
	      double eps_relax_rel = 1e-13,
	      double max_dyn = 1e6,
	      double min_viol = 1e-4,
	      int max_supp_abs = 1000,
	      double max_supp_rel = 0.1,
	      CleaningProcedure clean_proc = CP_CGLLANDP1,
	      bool use_int_slacks = false,
	      bool check_duplicates = false,
	      bool integral_scale_cont = false,
	      bool enforce_scaling = true);

   /// Constructor from CglParam
  CglGMIParam(CglParam &source,
	      double away = 0.005,
	      double eps_elim = 1e-12,
	      double eps_relax_abs = 1e-11,
	      double eps_relax_rel = 1e-13,
	      double max_dyn = 1e6,
	      double min_viol = 1e-4,
	      double max_supp_rel = 0.1,
	      CleaningProcedure clean_proc = CP_CGLLANDP1,
	      bool use_int_slacks = false,
	      bool check_duplicates = false,
	      bool integral_scale_cont = false,
	      bool enforce_scaling = true);
  
  /// Copy constructor 
  CglGMIParam(const CglGMIParam &source);

  /// Clone
  virtual CglGMIParam* clone() const;

  /// Assignment operator 
  virtual CglGMIParam& operator=(const CglGMIParam &rhs);

  /// Destructor 
  virtual ~CglGMIParam();
  //@}

protected:

  /**@name Parameters */
  //@{

  /** Use row only if pivot variable should be integer but is more 
      than AWAY from being integer. */
  double AWAY;

  /** Epsilon for value of coefficients when eliminating slack variables. 
      Default: 0. */
  double EPS_ELIM;

  /** Value added to the right hand side of each generated cut to relax it.
      Default: 1e-11 */
  double EPS_RELAX_ABS;

  /** For a generated cut with right hand side rhs_val, 
      EPS_RELAX_EPS * fabs(rhs_val) is used to relax the constraint.
      Default: 1.e-13 */
  double EPS_RELAX_REL;

  /** Maximum ratio between largest and smallest non zero 
      coefficients in a cut. Default: 1e6. */
  double MAXDYN;

  /** Minimum violation for the current basic solution in a generated cut.
      Default: 1e-4. */
  double MINVIOL;

  /** Maximum support relative to number of columns. Must be between 0
      and 1. Default: 0. */
  double MAX_SUPPORT_REL;

  /** Which cleaning procedure should be used? */
  CleaningProcedure CLEAN_PROC;

  /** Use integer slacks to generate cuts if USE_INTSLACKS = 1. Default: 0. */
  bool USE_INTSLACKS;

  /** Check for duplicates when adding the cut to the collection? */
  bool CHECK_DUPLICATES;

  /** Should we try to rescale cut coefficients on continuous variables
      so that they become integral, or do we only rescale coefficients
      on integral variables? Used only by cleaning procedure that try
      the integral scaling. */
  bool INTEGRAL_SCALE_CONT;

  /** Should we discard badly scaled cuts (according to the scaling
      procedure in use)? If false, CglGMI::scaleCut always returns
      true, even though it still scales cuts whenever possible, but
      not cut is rejected for scaling. Default true. Used only by
      cleaning procedure that try to scale. */
  bool ENFORCE_SCALING;

  //@}
};

#endif