Cgl  0.60.7
CglLandP.hpp
Go to the documentation of this file.
1 // Copyright (C) 2005-2009, Pierre Bonami and others. All Rights Reserved.
2 // Author: Pierre Bonami
3 // Tepper School of Business
4 // Carnegie Mellon University, Pittsburgh, PA 15213
5 // Date: 07/21/05
6 //
7 // $Id$
8 //
9 // This code is licensed under the terms of the Eclipse Public License (EPL).
10 //---------------------------------------------------------------------------
11 #ifndef CglLandP_H
12 #define CglLandP_H
13 
14 #include "CglLandPValidator.hpp"
15 #include "CglCutGenerator.hpp"
16 #include "CglParam.hpp"
17 
18 #include <iostream>
19 class CoinWarmStartBasis;
24 namespace LAP
25 {
27 {
36 };
38 class LapMessages : public CoinMessages
39 {
40 public:
42  LapMessages( );
44  virtual ~LapMessages() {}
45 };
46 class CglLandPSimplex;
47 }
48 
49 class CglLandP : public CglCutGenerator
50 {
51  friend void CglLandPUnitTest(OsiSolverInterface *si, const std::string & mpsDir);
52 
53  friend class LAP::CglLandPSimplex;
54  friend class CftCglp;
55 
56 public:
57 
59  {
63  };
64 
66  {
71  };
72 
75  {
79  };
80 
83  {
88  };
89 
90  enum LHSnorm
91  {
92  L1 = 0,
93  L2,
98  };
101  {
102  Fixed = 0 ,
104  };
107  class Parameters : public CglParam
108  {
109  public:
111  Parameters();
113  Parameters(const Parameters &other);
115  Parameters & operator=(const Parameters &other);
118 
137 
138  double pivotTol;
140  double away;
142  double timeLimit;
146  double rhsWeight;
148 
151 
162  bool perturb;
174  };
175 
176 
181  ~CglLandP();
183  CglLandP(const CglLandP &source);
185  CglLandP& operator=(const CglLandP &rhs);
187  CglCutGenerator * clone() const;
188 
191 
192  virtual void generateCuts(const OsiSolverInterface & si, OsiCuts & cs,
193  const CglTreeInfo info = CglTreeInfo());
194 
196 
197  virtual bool needsOptimalBasis() const
198  {
199  return true;
200  }
201 
203  {
204  return validator_;
205  }
213  void setLogLevel(int level)
214  {
215  handler_->setLogLevel(level);
216  }
217 
218  class NoBasisError : public CoinError
219  {
220  public:
221  NoBasisError(): CoinError("No basis available","LandP","") {}
222  };
223 
224  class SimplexInterfaceError : public CoinError
225  {
226  public:
227  SimplexInterfaceError(): CoinError("Invalid conversion to simplex interface", "CglLandP","CglLandP") {}
228  };
230  {
231  return params_;
232  }
233 private:
234 
235 
236  void scanExtraCuts(OsiCuts& cs, const double * colsol) const;
237 
239 
241  struct CachedData
242  {
243  CachedData(int nBasics = 0 , int nNonBasics = 0);
244  CachedData(const CachedData & source);
245 
246  CachedData& operator=(const CachedData &source);
248  void getData(const OsiSolverInterface &si);
249 
250  void clean();
251 
252  ~CachedData();
254  int * basics_;
258  int nBasics_;
262  CoinWarmStartBasis * basis_;
264  double * colsol_;
266  double * slacks_;
268  bool * integers_;
270  OsiSolverInterface * solver_;
271  };
274  int getSortedFractionals(CoinPackedVector &xFrac,
275  const CachedData & data,
276  const CglLandP::Parameters& params) const;
279  void getSortedFractionalIndices(std::vector<int>& indices,
280  const CachedData &data,
281  const CglLandP::Parameters & params) const;
285  CoinMessageHandler * handler_;
287  CoinMessages messages_;
291  int numrows_;
293  int numcols_;
299  bool canLift_;
301  OsiCuts extraCuts_;
302 };
303 void CglLandPUnitTest(OsiSolverInterface *si, const std::string & mpsDir);
304 
305 #endif
306 
CglLandP::SimplexInterfaceError
Definition: CglLandP.hpp:224
CglLandP::clone
CglCutGenerator * clone() const
Clone function.
CglLandP::messages_
CoinMessages messages_
messages
Definition: CglLandP.hpp:287
CglLandP::Unweighted
@ Unweighted
Definition: CglLandP.hpp:84
CglLandP::none
@ none
Generate no extra cuts.
Definition: CglLandP.hpp:67
CglLandP::Parameters::lhs_norm
LHSnorm lhs_norm
How to weight LHS of normalization.
Definition: CglLandP.hpp:168
CglParam
Class collecting parameters for all cut generators.
Definition: CglParam.hpp:22
LAP::BEGIN_ROUND
@ BEGIN_ROUND
Definition: CglLandP.hpp:28
CglLandP::AtOptimalBasis
@ AtOptimalBasis
Generate cuts from the optimal basis.
Definition: CglLandP.hpp:68
CglLandP::AllViolatedMigs
@ AllViolatedMigs
Generate all violated Mixed integer Gomory cuts in the course of the optimization.
Definition: CglLandP.hpp:70
CglLandP::LHSnorm
LHSnorm
Definition: CglLandP.hpp:90
CglLandP::Parameters::pivotTol
double pivotTol
Tolerance for small pivots values (should be the same as the solver.
Definition: CglLandP.hpp:138
CglTreeInfo
Information about where the cut generator is invoked from.
Definition: CglTreeInfo.hpp:15
CglLandP::RhsWeightType
RhsWeightType
RHS weight in normalization.
Definition: CglLandP.hpp:100
CglLandP::Parameters::Parameters
Parameters()
Default constructor (with default values)
CglLandP::WeightLHS
@ WeightLHS
Definition: CglLandP.hpp:86
LAP::DURING_SEP
@ DURING_SEP
Definition: CglLandP.hpp:30
CglLandP::SupportSize
@ SupportSize
Definition: CglLandP.hpp:94
LAP::END_ROUND
@ END_ROUND
Definition: CglLandP.hpp:29
CglLandP::CachedData
Some informations that will be changed by the pivots and that we want to keep.
Definition: CglLandP.hpp:241
CglLandP::Full
@ Full
Work in full space.
Definition: CglLandP.hpp:78
CglLandP::SimplexInterfaceError::SimplexInterfaceError
SimplexInterfaceError()
Definition: CglLandP.hpp:227
CglLandP::Parameters::maxCutPerRound
int maxCutPerRound
Maximum number of cuts generated at a given round.
Definition: CglLandP.hpp:126
CglLandP::Parameters::timeLimit
double timeLimit
Total time limit for cut generation.
Definition: CglLandP.hpp:142
CglLandP::Parameters::perturb
bool perturb
Apply perturbation procedure.
Definition: CglLandP.hpp:162
CglLandP::canLift_
bool canLift_
Flag to say if cuts can be lifted.
Definition: CglLandP.hpp:299
LAP::CUT_REJECTED
@ CUT_REJECTED
Definition: CglLandP.hpp:31
CglLandP::Parameters::strengthen
bool strengthen
Do we strengthen the final cut (always do if modularize is 1)
Definition: CglLandP.hpp:156
CglLandP::CachedData::CachedData
CachedData(int nBasics=0, int nNonBasics=0)
CglLandP::extraCuts_
OsiCuts extraCuts_
Store some extra cut which could be cheaply generated but do not cut current incumbent.
Definition: CglLandP.hpp:301
LAP::LapMessages
Output messages for Cgl.
Definition: CglLandP.hpp:38
CglLandP::CachedData::nBasics_
int nBasics_
number of basics variables
Definition: CglLandP.hpp:258
CglLandP::Normalization
Normalization
Normalization.
Definition: CglLandP.hpp:82
CglLandP::originalColLower_
double * originalColLower_
Original lower bounds for the problem (for lifting cuts).
Definition: CglLandP.hpp:295
CglLandP::cached_
CachedData cached_
Cached informations about problem.
Definition: CglLandP.hpp:283
CglLandP::getSortedFractionalIndices
void getSortedFractionalIndices(std::vector< int > &indices, const CachedData &data, const CglLandP::Parameters &params) const
Retrieve sorted integer variables which are fractional in the solution.
CglLandP
Definition: CglLandP.hpp:49
CglLandP::L2
@ L2
Definition: CglLandP.hpp:93
CglLandP::Parameters::extraCutsLimit
int extraCutsLimit
Maximum number of extra rows to generate per round.
Definition: CglLandP.hpp:133
CglLandP::SelectionRules
SelectionRules
Definition: CglLandP.hpp:58
CglLandP::CachedData::nNonBasics_
int nNonBasics_
number of non-basics
Definition: CglLandP.hpp:260
CglLandP::setLogLevel
void setLogLevel(int level)
set level of log for cut generation procedure :
Definition: CglLandP.hpp:213
CglLandP::Parameters::pivotLimitInTree
int pivotLimitInTree
Max number of pivots at regular nodes.
Definition: CglLandP.hpp:124
CglCutGenerator.hpp
CglLandP::CachedData::basics_
int * basics_
Indices of basic variables in starting basis (ordered if variable basics_[i] s basic in row i)
Definition: CglLandP.hpp:254
LAP::LAP_MESSAGES_DUMMY_END
@ LAP_MESSAGES_DUMMY_END
Definition: CglLandP.hpp:35
CglLandP::Fractional_rc
@ Fractional_rc
Use fractional space only for computing reduced costs.
Definition: CglLandP.hpp:77
CglLandP::scanExtraCuts
void scanExtraCuts(OsiCuts &cs, const double *colsol) const
CglLandP::Parameters::modularize
bool modularize
Do we apply Egon Balas's Heuristic for modularized cuts.
Definition: CglLandP.hpp:154
LAP::LapMessages::~LapMessages
virtual ~LapMessages()
destructor.
Definition: CglLandP.hpp:44
CglLandP::numcols_
int numcols_
number of columns in the original problems.
Definition: CglLandP.hpp:293
CglLandP::handler_
CoinMessageHandler * handler_
message handler
Definition: CglLandP.hpp:285
CglLandP::Parameters::rhsWeightType
RhsWeightType rhsWeightType
How to weight RHS of normalization.
Definition: CglLandP.hpp:166
CglLandP::Parameters::rhsWeight
double rhsWeight
Weight to put in RHS of normalization if static.
Definition: CglLandP.hpp:146
CglLandP::validator_
LAP::Validator validator_
cut validator
Definition: CglLandP.hpp:289
CglCutGenerator
Cut Generator Base Class.
Definition: CglCutGenerator.hpp:23
CglLandP::WeightBoth
@ WeightBoth
Definition: CglLandP.hpp:87
LAP::CUT_GAP
@ CUT_GAP
Definition: CglLandP.hpp:33
CglLandP::Fixed
@ Fixed
Definition: CglLandP.hpp:102
CglLandP::CachedData::basis_
CoinWarmStartBasis * basis_
Optimal basis.
Definition: CglLandP.hpp:262
CglLandP::Parameters::away
double away
A variable have to be at least away from integrity to be generated.
Definition: CglLandP.hpp:140
CglLandP::Parameters::countMistakenRc
bool countMistakenRc
Wether to limit or not the number of mistaken RC (when perturbation is applied).
Definition: CglLandP.hpp:158
CglLandP::CftCglp
friend class CftCglp
Definition: CglLandP.hpp:54
CglLandP::Parameters::operator=
Parameters & operator=(const Parameters &other)
Assignment opertator.
CglParam.hpp
CglLandP::initialReducedCosts
@ initialReducedCosts
Select only those rows which had initialy a 0 reduced cost.
Definition: CglLandP.hpp:62
CglLandP::bestPivot
@ bestPivot
select best possible pivot.
Definition: CglLandP.hpp:61
CglLandP::parameter
Parameters & parameter()
Definition: CglLandP.hpp:229
CglLandP::CglLandPUnitTest
friend void CglLandPUnitTest(OsiSolverInterface *si, const std::string &mpsDir)
CglLandP::Average
@ Average
Definition: CglLandP.hpp:96
CglLandP::Dynamic
@ Dynamic
2 * current number of constraints.
Definition: CglLandP.hpp:103
CglLandP::Uniform
@ Uniform
Definition: CglLandP.hpp:97
LAP::LAP_CUT_FAILED_DO_MIG
@ LAP_CUT_FAILED_DO_MIG
Definition: CglLandP.hpp:34
CglLandP::Parameters::sepSpace
SeparationSpaces sepSpace
Work in the reduced space (only non-structurals enter the basis)
Definition: CglLandP.hpp:160
CglLandP::needsOptimalBasis
virtual bool needsOptimalBasis() const
Return true if needs optimal basis to do cuts.
Definition: CglLandP.hpp:197
LAP::LapMessages::LapMessages
LapMessages()
Constructor.
LAP::CUT_FAILED
@ CUT_FAILED
Definition: CglLandP.hpp:32
CglLandP::CachedData::nonBasics_
int * nonBasics_
Indices of non-basic variables.
Definition: CglLandP.hpp:256
CglLandP::NoBasisError::NoBasisError
NoBasisError()
Definition: CglLandP.hpp:221
CglLandP::CachedData::colsol_
double * colsol_
Stores the value of the solution to cut.
Definition: CglLandP.hpp:264
CglLandPUnitTest
void CglLandPUnitTest(OsiSolverInterface *si, const std::string &mpsDir)
CglLandP::Parameters
Class storing parameters.
Definition: CglLandP.hpp:107
CglLandPValidator.hpp
CglLandP::originalColUpper_
double * originalColUpper_
Original upper bounds for the problem (for lifting cuts).
Definition: CglLandP.hpp:297
CglLandP::CachedData::getData
void getData(const OsiSolverInterface &si)
Get the data from a problem.
CglLandP::operator=
CglLandP & operator=(const CglLandP &rhs)
Assignment operator.
CglLandP::WeightRHS
@ WeightRHS
Definition: CglLandP.hpp:85
CglLandP::ExtraCutsMode
ExtraCutsMode
Definition: CglLandP.hpp:65
CglLandP::getSortedFractionals
int getSortedFractionals(CoinPackedVector &xFrac, const CachedData &data, const CglLandP::Parameters &params) const
Retrieve sorted integer variables which are fractional in the solution.
CglLandP::Fractional
@ Fractional
Definition: CglLandP.hpp:76
LAP::CglLandPSimplex
Definition: CglLandPSimplex.hpp:42
CglLandP::Parameters::singleCutTimeLimit
double singleCutTimeLimit
Time limit for generating a single cut.
Definition: CglLandP.hpp:144
CglLandP::Parameters::failedPivotLimit
int failedPivotLimit
Maximum number of failed pivots before aborting.
Definition: CglLandP.hpp:128
CglLandP::CachedData::slacks_
double * slacks_
Stores the values of the slacks.
Definition: CglLandP.hpp:266
CglLandP::generateCuts
virtual void generateCuts(const OsiSolverInterface &si, OsiCuts &cs, const CglTreeInfo info=CglTreeInfo())
Generate cuts for the model data contained in si.
CglLandP::CachedData::solver_
OsiSolverInterface * solver_
Solver before pivots.
Definition: CglLandP.hpp:270
CglLandP::CachedData::integers_
bool * integers_
Stores wheter slacks are integer constrained.
Definition: CglLandP.hpp:268
CglLandP::NoBasisError
Definition: CglLandP.hpp:218
CglLandP::numrows_
int numrows_
number of rows in the original problems.
Definition: CglLandP.hpp:291
LAP::LapMessagesTypes
LapMessagesTypes
Definition: CglLandP.hpp:26
CglLandP::mostNegativeRc
@ mostNegativeRc
select most negative reduced cost
Definition: CglLandP.hpp:60
LAP::Validator
Class to validate or reject a cut.
Definition: CglLandPValidator.hpp:26
CglLandP::Parameters::pivotSelection
SelectionRules pivotSelection
Which rule to apply for choosing entering and leaving variables.
Definition: CglLandP.hpp:172
CglLandP::CglLandP
CglLandP(const CglLandP::Parameters &params=CglLandP::Parameters(), const LAP::Validator &validator=LAP::Validator())
Constructor for the class.
CglLandP::validator
LAP::Validator & validator()
Definition: CglLandP.hpp:202
CglLandP::L1
@ L1
Definition: CglLandP.hpp:92
CglLandP::params_
Parameters params_
Definition: CglLandP.hpp:238
CglLandP::Infinity
@ Infinity
Definition: CglLandP.hpp:95
CglLandP::CachedData::~CachedData
~CachedData()
CglLandP::CachedData::clean
void clean()
CglLandP::Parameters::pivotLimit
int pivotLimit
Max number of pivots before we generate the cut \default 20.
Definition: CglLandP.hpp:121
CglLandP::SeparationSpaces
SeparationSpaces
Space where cuts are optimized.
Definition: CglLandP.hpp:74
CglLandP::Parameters::generateExtraCuts
ExtraCutsMode generateExtraCuts
Generate extra constraints from optimal lift-and-project basis.
Definition: CglLandP.hpp:170
CglLandP::Parameters::degeneratePivotLimit
int degeneratePivotLimit
maximum number of consecutive degenerate pivots \default 0
Definition: CglLandP.hpp:131
CglLandP::Parameters::normalization
Normalization normalization
How to weight normalization.
Definition: CglLandP.hpp:164
CglLandP::CachedData::operator=
CachedData & operator=(const CachedData &source)
CglLandP::~CglLandP
~CglLandP()
Destructor.
CglLandP::Parameters::useTableauRow
bool useTableauRow
Do we use tableau row or the disjunction (I don't really get that there should be a way to always use...
Definition: CglLandP.hpp:152
LAP
Performs one round of Lift & Project using CglLandPSimplex to build cuts.
Definition: CglLandP.hpp:24
CglLandP::WhenEnteringBasis
@ WhenEnteringBasis
Generate cuts as soon as a structural enters the basis.
Definition: CglLandP.hpp:69