source: trunk/include/CbcBranchLotsize.hpp @ 72

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

debug for lotsize and when_ for heuristic

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.8 KB
Line 
1// Copyright (C) 2004, International Business Machines
2// Corporation and others.  All Rights Reserved.
3#ifndef CbcBranchLotsize_H
4#define CbcBranchLotsize_H
5
6#include "CbcBranchBase.hpp"
7
8/** Lotsize class */
9
10
11class CbcLotsize : public CbcObject {
12
13public:
14
15  // Default Constructor
16  CbcLotsize ();
17
18  /* Useful constructor - passed model index.
19     Also passed valid values - if range then pairs
20  */
21  CbcLotsize (CbcModel * model, int iColumn,
22              int numberPoints, const double * points, bool range=false);
23 
24  // Copy constructor
25  CbcLotsize ( const CbcLotsize &);
26   
27  /// Clone
28  virtual CbcObject * clone() const;
29
30  // Assignment operator
31  CbcLotsize & operator=( const CbcLotsize& rhs);
32
33  // Destructor
34  ~CbcLotsize ();
35 
36  /// Infeasibility - large is 0.5
37  virtual double infeasibility(int & preferredWay) const;
38
39  /** Set bounds to contain the current solution.
40
41    More precisely, for the variable associated with this object, take the
42    value given in the current solution, force it within the current bounds
43    if required, then set the bounds to fix the variable at the integer
44    nearest the solution value.
45  */
46  virtual void feasibleRegion();
47
48  /// Creates a branching object
49  virtual CbcBranchingObject * createBranch(int way) const;
50
51  /** \brief Given a valid solution (with reduced costs, etc.),
52      return a branching object which would give a new feasible
53      point in the good direction.
54
55    The preferred branching object will force the variable to be +/-1 from
56    its current value, depending on the reduced cost and objective sense.  If
57    movement in the direction which improves the objective is impossible due
58    to bounds on the variable, the branching object will move in the other
59    direction.  If no movement is possible, the method returns NULL.
60
61    Only the bounds on this variable are considered when determining if the new
62    point is feasible.
63  */
64  virtual CbcBranchingObject * preferredNewFeasible() const;
65 
66  /** \brief Given a valid solution (with reduced costs, etc.),
67      return a branching object which would give a new feasible
68      point in a bad direction.
69
70    As for preferredNewFeasible(), but the preferred branching object will
71    force movement in a direction that degrades the objective.
72  */
73  virtual CbcBranchingObject * notPreferredNewFeasible() const ;
74 
75  /** Reset original upper and lower bound values from the solver.
76 
77    Handy for updating bounds held in this object after bounds held in the
78    solver have been tightened.
79   */
80  virtual void resetBounds();
81
82  /** Finds range of interest so value is feasible in range range_ or infeasible
83      between hi[range_] and lo[range_+1].  Returns true if feasible.
84  */
85  bool findRange(double value) const;
86 
87  /** Returns floor and ceiling
88  */
89  virtual void floorCeiling(double & floorLotsize, double & ceilingLotsize, double value,
90                            double tolerance) const;
91 
92  /// Model column number
93  inline int modelSequence() const
94  {return columnNumber_;};
95
96  /// Original bounds
97  inline double originalLowerBound() const
98  { return bound_[0];};
99  inline double originalUpperBound() const
100  { return bound_[rangeType_*numberRanges_-1];};
101  /// Type - 1 points, 2 ranges
102  inline int rangeType() const
103  { return rangeType_;};
104  /// Number of points
105  inline int numberRanges() const
106  { return numberRanges_;};
107  /// Ranges
108  inline double * bound() const
109  { return bound_;};
110
111private:
112  /// Just for debug (CBC_PRINT defined in CbcBranchLotsize.cpp)
113  void printLotsize(double value,bool condition,int type) const;
114
115private:
116  /// data
117
118  /// Column number in model
119  int columnNumber_;
120  /// Type - 1 points, 2 ranges
121  int rangeType_;
122  /// Number of points
123  int numberRanges_;
124  // largest gap
125  double largestGap_;
126  /// Ranges
127  double * bound_;
128  /// Current range
129  mutable int range_;
130};
131
132
133/** Lotsize branching object
134
135  This object can specify a two-way branch on an integer variable. For each
136  arm of the branch, the upper and lower bounds on the variable can be
137  independently specified.
138 
139  Variable_ holds the index of the integer variable in the integerVariable_
140  array of the model.
141*/
142
143class CbcLotsizeBranchingObject : public CbcBranchingObject {
144
145public:
146
147  /// Default constructor
148  CbcLotsizeBranchingObject ();
149
150  /** Create a lotsize floor/ceiling branch object
151
152    Specifies a simple two-way branch. Let \p value = x*. One arm of the
153    branch will be is lb <= x <= valid range below(x*), the other valid range above(x*) <= x <= ub.
154    Specify way = -1 to set the object state to perform the down arm first,
155    way = 1 for the up arm.
156  */
157  CbcLotsizeBranchingObject (CbcModel *model, int variable,
158                             int way , double value,const CbcLotsize * lotsize) ;
159 
160  /** Create a degenerate branch object
161
162    Specifies a `one-way branch'. Calling branch() for this object will
163    always result in lowerValue <= x <= upperValue. Used to fix in valid range
164  */
165
166  CbcLotsizeBranchingObject (CbcModel *model, int variable, int way,
167                             double lowerValue, double upperValue) ;
168 
169  /// Copy constructor
170  CbcLotsizeBranchingObject ( const CbcLotsizeBranchingObject &);
171   
172  /// Assignment operator
173  CbcLotsizeBranchingObject & operator= (const CbcLotsizeBranchingObject& rhs);
174
175  /// Clone
176  virtual CbcBranchingObject * clone() const;
177
178  /// Destructor
179  virtual ~CbcLotsizeBranchingObject ();
180 
181  /** \brief Sets the bounds for the variable according to the current arm
182             of the branch and advances the object state to the next arm.
183  */
184  virtual double branch(bool normalBranch=false);
185
186  /** \brief Print something about branch - only if log level high
187  */
188  virtual void print(bool normalBranch);
189
190private:
191  /// Lower [0] and upper [1] bounds for the down arm (way_ = -1)
192  double down_[2];
193  /// Lower [0] and upper [1] bounds for the up arm (way_ = 1)
194  double up_[2];
195};
196
197
198#endif
Note: See TracBrowser for help on using the repository browser.