Cbc  2.9.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbcHeuristicDW.hpp
Go to the documentation of this file.
1 // $Id: CbcHeuristicDW.hpp 1899 2013-04-09 18:12:08Z stefan $
2 // Copyright (C) 2006, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 
6 
7 #ifndef CbcHeuristicDW_H
8 #define CbcHeuristicDW_H
9 
10 #include "CbcHeuristic.hpp"
11 
17 class CbcHeuristicDW : public CbcHeuristic {
18 public:
19 
20  // Default Constructor
21  CbcHeuristicDW ();
22 
23  /* Constructor with model - assumed before cuts
24  */
25  CbcHeuristicDW (CbcModel & model, int keepContinuous=0);
26 
27  /* Constructor with model - assumed before cuts
28  */
29  CbcHeuristicDW (CbcModel & model,
30  int callBack(CbcHeuristicDW * currentHeuristic,
31  CbcModel * thisModel,
32  int whereFrom),
33  int keepContinuous=0);
34 
35  // Copy constructor
36  CbcHeuristicDW ( const CbcHeuristicDW &);
37 
38  // Destructor
39  ~CbcHeuristicDW ();
40 
42  virtual CbcHeuristic * clone() const;
43 
44 
47 
49  virtual void generateCpp( FILE * fp) ;
50 
52  virtual void resetModel(CbcModel * model);
53 
55  virtual void setModel(CbcModel * model);
61  virtual int solution(double & objectiveValue,
62  double * newSolution);
65  inline int numberBlocks() const
66  { return numberBlocks_;}
68  void passInSolution(const double * solution);
70  void passInContinuousSolution(const double * solution);
76  void setProposalActions(int fullDWEverySoOften);
78  double objectiveValueWhen(int whichDW) const;
80  int numberColumnsDW(int whichDW) const;
82  inline OsiSolverInterface * solver() const
83  { return solver_;}
85  OsiSolverInterface * DWModel(int whichDW) const;
87  inline double bestObjective() const
88  { return bestObjective_;}
90  inline const double * bestSolution() const
91  { return bestSolution_;}
93  inline const double * continuousSolution() const
94  { return continuousSolution_;}
96  inline const double * fixedDj() const
97  { return fixedDj_;}
99  inline const double * objectiveDW() const
100  { return objectiveDW_;}
102  inline int numberDWTimes() const
103  { return numberDWTimes_;}
105  inline const int * numberColumnsDW() const
106  { return numberColumnsDW_;}
108  inline void setNumberPasses(int value)
109  { numberPasses_ = value;}
111  inline void setNumberBadPasses(int value)
112  { numberBadPasses_ = value;}
114  inline void setNumberNeeded(int value)
115  { nNeededBase_ = value;}
117  inline int getNumberNeeded() const
118  {return nNeededBase_;}
120  inline void setCurrentNumberNeeded(int value)
121  { nNeeded_ = value;}
123  inline int getCurrentNumberNeeded() const
124  {return nNeeded_;}
126  inline void setNumberNodes(int value)
127  { nNodesBase_ = value;}
129  inline int getNumberNodes() const
130  {return nNodesBase_;}
132  inline void setCurrentNumberNodes(int value)
133  { nNodes_ = value;}
135  inline int getCurrentNumberNodes() const
136  {return nNodes_;}
138  inline void setTargetObjective(double value)
139  { targetObjective_ = value;}
141  inline void setHowOften(int value) {
142  howOften_ = value;
143  }
145  inline const int * whichRowBlock() const
146  { return whichRowBlock_;}
148  inline const int * whichColumnBlock() const
149  { return whichColumnBlock_;}
151  inline double * initialLower() const
152  { return saveLower_;}
154  inline double * initialUpper() const
155  { return saveUpper_;}
157  inline int * intArrays() const
158  { return intArray_;}
160  inline double * doubleArrays() const
161  { return doubleArray_;}
163  inline int phase() const
164  { return phase_;}
166  inline int pass() const
167  { return pass_;}
169  inline const int * columnsInBlock() const
170  { return columnsInBlock_;}
172  inline const int * startColumnBlock() const
173  { return startColumnBlock_;}
175  inline const int * intsInBlock() const
176  { return intsInBlock_;}
178  double objectiveValue(const double * solution);
179 private:
181  void gutsOfCopy(const CbcHeuristicDW & rhs);
183  void gutsOfDelete();
185  void setDefaults();
187  void findStructure();
189  void setupDWStructures();
191  int addDW(const double * solution,int numberBlocksUsed,
192  const int * whichBlocks);
193 protected:
194  typedef int (*heuristicCallBack) (CbcHeuristicDW * ,CbcModel *, int) ;
195  // Data
218  int * intArray_;
220  double * doubleArray_;
226  double * bestSolution_;
230  double * fixedDj_;
232  double * saveLower_;
234  double * saveUpper_;
236  double * random_;
238  double * weights_;
240  double * objectiveDW_;
248  int * dwBlock_;
262  unsigned int * fingerPrint_;
264  unsigned short * affinity_;
292  int phase_;
294  int pass_;
300  int nNeeded_;
302  int nNodes_;
305  // 0 - fine, 1 can't be better, 2 max node
307 };
308 
309 #endif
int * dwBlock_
Block number for each proposal.
void setHowOften(int value)
Sets how often to do it.
void gutsOfDelete()
Guts of delete.
const double * bestSolution() const
Best solution found so far.
int getCurrentNumberNeeded() const
Get number free integers needed (Current value)
void passInContinuousSolution(const double *solution)
Pass in continuous solution.
virtual int solution(double &objectiveValue, double *newSolution)
returns 0 if no solution, 1 if valid solution.
double * continuousSolution_
Continuous solution.
int * rowsInBlock_
Which rows are in blocke.
double * saveLower_
Original lower bounds.
const double * continuousSolution() const
Continuous solution.
int * whichRowBlock_
Block for every row.
heuristicCallBack functionPointer_
Call back whereFrom - 0 - after blocks found but before data setup 1 - after blocks sorted but before...
double * doubleArrays() const
Local double arrays (each numberBlocks_ long)
int whereFrom() const
virtual CbcHeuristic * clone() const
Clone.
double * initialLower() const
Initial Lower bounds.
int * intArray_
Local integer arrays (each numberBlocks_ long)
int numberBlocks() const
Return number of blocks <=0 - no usable structure.
void setNumberBadPasses(int value)
Set number of passes without better solution.
This is unlike the other heuristics in that it is very very compute intensive.
int numberPasses_
Number of passes.
int numberDW_
Number of DW proposals.
int pass() const
Pass number.
void setProposalActions(int fullDWEverySoOften)
DW Proposal actions fullDWEverySoOften - 0 - off k - every k times solution gets better.
int numberDWTimes() const
Number of times we have added to DW model.
int * intArrays() const
Local integer arrays (each numberBlocks_ long)
unsigned short * affinity_
Affinity each block has for other (will be triangular?)
double * doubleArray_
Local double arrays (each numberBlocks_ long)
int * backwardRow_
Points back to master rows.
void setCurrentNumberNeeded(int value)
Set number free integers needed (Current value)
int addDW(const double *solution, int numberBlocksUsed, const int *whichBlocks)
Add DW proposals.
void findStructure()
Find structure.
void setDefaults()
Set default values.
void setTargetObjective(double value)
Set target objective.
void setNumberNodes(int value)
Set number nodes (could be done in callback) (Base value)
int keepContinuous_
Action on decomposition - 1 keep continuous, 0 don't.
int nNeeded_
Base number of integers needed.
int phase_
Phase of solution.
void setNumberNeeded(int value)
Set number free integers needed (Base value)
virtual void generateCpp(FILE *fp)
Create C++ lines to get to current state.
unsigned int * fingerPrint_
Bits set for 1 integers in each block.
Abstract Base Class for describing an interface to a solver.
OsiSolverInterface * solver_
Base solver.
int nNeededBase_
Base number of integers needed.
double * weights_
Weights for each proposal.
OsiSolverInterface * dwSolver_
DW solver.
int getNumberNodes() const
Get number nodes (could be done in callback) (Base value)
double * objectiveDW_
Objective at which DW updated.
virtual void resetModel(CbcModel *model)
Resets stuff if model changes.
int nNodes_
Base number of nodes needed.
int fullDWEverySoOften_
DW Proposal actions fullDWEverySoOften - 0 - off k - every k times solution gets better.
void passInSolution(const double *solution)
Pass in a solution.
int * startColumnBlock_
Starts for columnsInBlock.
double * initialUpper() const
Initial Upper bounds.
int getNumberNeeded() const
Get number free integers needed (Base value)
void gutsOfCopy(const CbcHeuristicDW &rhs)
Guts of copy.
int * intsInBlock_
Number of integer variables in each block.
double bestObjective() const
Best objective value.
const int * whichColumnBlock() const
Block for every column.
int phase() const
Phase of solution.
const double * fixedDj() const
Reduced costs of fixed solution.
double * saveUpper_
Original Upper bounds.
int * startRowBlock_
Starts for rowsInBlock.
int pass_
Pass number.
int(* heuristicCallBack)(CbcHeuristicDW *, CbcModel *, int)
CbcHeuristicDW & operator=(const CbcHeuristicDW &rhs)
Assignment operator.
void setupDWStructures()
Set up DW structure.
OsiSolverInterface * DWModel(int whichDW) const
DW model (user must delete)
double objectiveValue(const double *solution)
Objective value (could also check validity)
double objectiveValueWhen(int whichDW) const
Objective value when whichDw created.
int numberDWTimes_
Number of times we have added to DW model.
const int * whichRowBlock() const
Block for every row.
int nNodesBase_
Base number of nodes needed.
int numberMasterColumns_
Number of columns in master.
Heuristic base class.
int numberMasterRows_
Number of rows in master.
int * columnsInBlock_
Which columns are in block.
int * whichColumnBlock_
Block for every column.
double * fixedDj_
Reduced costs of fixed solution.
double * random_
random numbers for master rows
OsiSolverInterface * solver() const
Solver.
const int * intsInBlock() const
Number of integer variables in each block.
double bestObjective_
Best objective value.
int getCurrentNumberNodes() const
Get number nodes (could be done in callback) (Current value)
virtual int solution(double &objectiveValue, double *newSolution)=0
returns 0 if no solution, 1 if valid solution with better objective value than one passed in Sets sol...
int numberBlocks_
Number of blocks.
virtual void setModel(CbcModel *model)
update model (This is needed if cliques update matrix etc)
double targetObjective_
Target objective.
double lastObjective_
Objective value last time.
const double * objectiveDW() const
Objective at which DW updated.
void setNumberPasses(int value)
Set number of passes.
const int * startColumnBlock() const
Starts for columnsInBlock.
Simple Branch and bound class.
Definition: CbcModel.hpp:101
const int * columnsInBlock() const
Which columns are in block.
int numberBadPasses_
Number of passes without better solution.
void setCurrentNumberNodes(int value)
Set number nodes (could be done in callback) (Current value)
int howOften_
How often to do (code can change)
int * numberColumnsDW_
Number of columns in each DW.
const int * numberColumnsDW() const
Number of columns in DW.
int maximumDW_
Current maximum number of DW proposals.
double * bestSolution_
Best solution found so far.
int sizeFingerPrint_
Number of unsigned ints needed for each block of fingerPrint.