source: trunk/include/CbcFathomDynamicProgramming.hpp @ 38

Last change on this file since 38 was 38, checked in by forrest, 17 years ago

Slightly faster

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1// Copyright (C) 2004, International Business Machines
2// Corporation and others.  All Rights Reserved.
3#ifndef CbcFathomDynamicProgramming_H
4#define CbcFathomDynamicProgramming_H
5
6#include "CbcFathom.hpp"
7
8//#############################################################################
9/** FathomDynamicProgramming base class.
10
11    The idea is that after some branching the problem will be effectively smaller than
12    the original problem and maybe there will be a more specialized technique which can completely
13    fathom this branch quickly.
14
15    One method is to presolve the problem to give a much smaller new problem and then do branch
16    and cut on that.  Another might be dynamic programming.
17
18 */
19
20class CbcFathomDynamicProgramming : public CbcFathom {
21public:
22  // Default Constructor
23  CbcFathomDynamicProgramming ();
24
25  // Constructor with model - assumed before cuts
26  CbcFathomDynamicProgramming (CbcModel & model);
27  // Copy constructor
28  CbcFathomDynamicProgramming(const CbcFathomDynamicProgramming & rhs);
29
30  virtual ~CbcFathomDynamicProgramming();
31
32  /// update model (This is needed if cliques update matrix etc)
33  virtual void setModel(CbcModel * model);
34 
35  /// Clone
36  virtual CbcFathom * clone() const;
37
38  /// Resets stuff if model changes
39  virtual void resetModel(CbcModel * model);
40
41  /** returns 0 if no fathoming attempted, 1 fully fathomed ,
42      2 incomplete search, 3 incomplete search but treat as complete.
43      If solution then newSolution will not be NULL and
44      will be freed by CbcModel.  It is expected that the solution is better
45      than best so far but CbcModel will double check.
46
47      If returns 3 then of course there is no guarantee of global optimum
48  */
49  virtual int fathom(double *& newSolution);
50
51  /// Maximum size allowed
52  inline int maximumSize() const
53  { return maximumSizeAllowed_;};
54  inline void setMaximumSize(int value)
55  { maximumSizeAllowed_=value;};
56private:
57  /// Returns type
58  int gutsOfCheckPossible(int allowableSize=0);
59  /// Does deleteions
60  void gutsOfDelete();
61
62  /** Adds one attempt of one column of type 0,
63      returns true if was used in making any changes
64  */
65  bool addOneColumn0(int id,int numberElements, const int * rows,
66                     double cost);
67  /** Adds one attempt of one column of type 1,
68      returns true if was used in making any changes.
69      At present the user has to call it once for each possible value
70  */
71  bool addOneColumn1(int id,int numberElements, const int * rows,
72                     const int * coefficients, double cost);
73  /** Adds one attempt of one column of type 1,
74      returns true if was used in making any changes.
75      At present the user has to call it once for each possible value.
76      This version is when there are enough 1 rhs to do faster
77  */
78  bool addOneColumn1A(int id,int numberElements, const int * rows,
79                     const int * coefficients, double cost);
80
81protected:
82
83  /// Size of states (power of 2 unless just one constraint)
84  int size_;
85  /** Type - 0 coefficients and rhs all 1,
86      1 - coefficients > 1 or rhs > 1
87  */
88  int type_;
89  /// Space for states (? could be float)
90  double * cost_;
91  /// Which state produced this cheapest one
92  int * back_;
93  /// Some id as to which variable was used
94  int * id_;
95  /// Some rows may be satisified so we need a lookup
96  int * lookup_;
97  /// Number of active rows
98  int numberActive_;
99  /// Maximum size allowed
100  int maximumSizeAllowed_;
101  /// Start bit for each active row
102  int * startBit_;
103  /// Number bits for each active row
104  int * numberBits_;
105  /// Effective rhs
106  int * rhs_;
107  /// Number of Non 1 rhs
108  int numberNonOne_;
109private:
110 
111  /// Illegal Assignment operator
112  CbcFathomDynamicProgramming & operator=(const CbcFathomDynamicProgramming& rhs);
113 
114};
115
116#endif
Note: See TracBrowser for help on using the repository browser.