CbcHeuristicDive.hpp

Go to the documentation of this file.
00001 /* $Id: CbcHeuristicDive.hpp 2093 2014-11-06 16:17:38Z forrest $ */
00002 // Copyright (C) 2008, International Business Machines
00003 // Corporation and others.  All Rights Reserved.
00004 // This code is licensed under the terms of the Eclipse Public License (EPL).
00005 
00006 #ifndef CbcHeuristicDive_H
00007 #define CbcHeuristicDive_H
00008 
00009 #include "CbcHeuristic.hpp"
00010 class CbcSubProblem;
00011 class OsiRowCut;
00012 struct PseudoReducedCost {
00013     int var;
00014     double pseudoRedCost;
00015 };
00016 
00017 
00021 class CbcHeuristicDive : public CbcHeuristic {
00022 public:
00023 
00024     // Default Constructor
00025     CbcHeuristicDive ();
00026 
00027     // Constructor with model - assumed before cuts
00028     CbcHeuristicDive (CbcModel & model);
00029 
00030     // Copy constructor
00031     CbcHeuristicDive ( const CbcHeuristicDive &);
00032 
00033     // Destructor
00034     ~CbcHeuristicDive ();
00035 
00037     virtual CbcHeuristicDive * clone() const = 0;
00038 
00040     CbcHeuristicDive & operator=(const CbcHeuristicDive& rhs);
00041 
00043     virtual void generateCpp( FILE * ) {}
00044 
00046     void generateCpp( FILE * fp, const char * heuristic);
00047 
00049     virtual void resetModel(CbcModel * model);
00050 
00052     virtual void setModel(CbcModel * model);
00053 
00054     //  REMLOVE using CbcHeuristic::solution ;
00061     virtual int solution(double & objectiveValue,
00062                          double * newSolution);
00064     int solution(double & objectiveValue, int & numberNodes,
00065                  int & numberCuts, OsiRowCut ** cuts,
00066                  CbcSubProblem ** & nodes,
00067                  double * newSolution);
00073     int fathom(CbcModel * model, int & numberNodes,CbcSubProblem ** & nodes);
00074 
00076     virtual void validate();
00077 
00079     void setPriorities();
00080 
00082     void selectBinaryVariables();
00083 
00085     void setPercentageToFix(double value) {
00086         percentageToFix_ = value;
00087     }
00088 
00090     void setMaxIterations(int value) {
00091         maxIterations_ = value;
00092     }
00093 
00095     void setMaxSimplexIterations(int value) {
00096         maxSimplexIterations_ = value;
00097     }
00099     inline int maxSimplexIterations() const {
00100         return maxSimplexIterations_;
00101     }
00102 
00104     void setMaxSimplexIterationsAtRoot(int value) {
00105         maxSimplexIterationsAtRoot_ = value;
00106     }
00107 
00109     void setMaxTime(double value) {
00110         maxTime_ = value;
00111     }
00112 
00114     virtual bool canHeuristicRun();
00115 
00122     virtual bool selectVariableToBranch(OsiSolverInterface* solver,
00123                                         const double* newSolution,
00124                                         int& bestColumn,
00125                                         int& bestRound) = 0;
00128     virtual void initializeData() {}
00129 
00131     int reducedCostFix (OsiSolverInterface* solver);
00133     virtual int fixOtherVariables(OsiSolverInterface * solver,
00134                                   const double * solution,
00135                                   PseudoReducedCost * candidate,
00136                                   const double * random);
00137 
00138 protected:
00139     // Data
00140 
00141     // Original matrix by column
00142     CoinPackedMatrix matrix_;
00143 
00144     // Original matrix by
00145     CoinPackedMatrix matrixByRow_;
00146 
00147     // Down locks
00148     unsigned short * downLocks_;
00149 
00150     // Up locks
00151     unsigned short * upLocks_;
00152 
00154     double * downArray_;
00155 
00157     double * upArray_;
00158 
00160     typedef struct {
00161       unsigned int direction:3; //  0 bit off, 1 bit (0 down first, 1 up first) 2 bit non zero don't try other way
00162       unsigned int priority:29;
00163     } PriorityType;
00164     PriorityType * priority_;
00165     // Indexes of binary variables with 0 objective coefficient
00166     // and in variable bound constraints
00167     std::vector<int> binVarIndex_;
00168 
00169     // Indexes of variable bound rows for each binary variable
00170     std::vector<int> vbRowIndex_;
00171 
00172     // Percentage of integer variables to fix at bounds
00173     double percentageToFix_;
00174 
00175     // Maximum time allowed
00176     double maxTime_;
00177 
00178     // Small objective (i.e. treat zero objective as this)
00179     double smallObjective_;
00180 
00181     // Maximum number of major iterations
00182     int maxIterations_;
00183 
00184     // Maximum number of simplex iterations
00185     int maxSimplexIterations_;
00186 
00187     // Maximum number of simplex iterations at root node
00188     int maxSimplexIterationsAtRoot_;
00189 
00190 };
00191 #endif
00192 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 7 Feb 2015 for Cbc by  doxygen 1.6.1