source: branches/heur/Cbc/src/CbcBranchLotsize.hpp

Last change on this file was 911, checked in by ladanyi, 11 years ago
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.3 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  using CbcObject::infeasibility ;
37  /// Infeasibility - large is 0.5
38  virtual double infeasibility(int & preferredWay) const;
39
40  using CbcObject::feasibleRegion ;
41  /** Set bounds to contain the current solution.
42
43    More precisely, for the variable associated with this object, take the
44    value given in the current solution, force it within the current bounds
45    if required, then set the bounds to fix the variable at the integer
46    nearest the solution value.
47  */
48  virtual void feasibleRegion();
49
50  using CbcObject::createBranch ;
51  /// Creates a branching object
52  virtual CbcBranchingObject * createBranch(int way) ;
53
54  /** \brief Given a valid solution (with reduced costs, etc.),
55      return a branching object which would give a new feasible
56      point in the good direction.
57
58    The preferred branching object will force the variable to be +/-1 from
59    its current value, depending on the reduced cost and objective sense.  If
60    movement in the direction which improves the objective is impossible due
61    to bounds on the variable, the branching object will move in the other
62    direction.  If no movement is possible, the method returns NULL.
63
64    Only the bounds on this variable are considered when determining if the new
65    point is feasible.
66  */
67  virtual CbcBranchingObject * preferredNewFeasible() const;
68 
69  /** \brief Given a valid solution (with reduced costs, etc.),
70      return a branching object which would give a new feasible
71      point in a bad direction.
72
73    As for preferredNewFeasible(), but the preferred branching object will
74    force movement in a direction that degrades the objective.
75  */
76  virtual CbcBranchingObject * notPreferredNewFeasible() const ;
77 
78  /** Reset original upper and lower bound values from the solver.
79 
80    Handy for updating bounds held in this object after bounds held in the
81    solver have been tightened.
82   */
83  virtual void resetBounds(const OsiSolverInterface * solver);
84
85  /** Finds range of interest so value is feasible in range range_ or infeasible
86      between hi[range_] and lo[range_+1].  Returns true if feasible.
87  */
88  bool findRange(double value) const;
89 
90  /** Returns floor and ceiling
91  */
92  virtual void floorCeiling(double & floorLotsize, double & ceilingLotsize, double value,
93                            double tolerance) const;
94 
95  /// Model column number
96  inline int modelSequence() const
97  {return columnNumber_;}
98
99  /** Column number if single column object -1 otherwise,
100      so returns >= 0
101      Used by heuristics
102  */
103  virtual int columnNumber() const;
104  /// Original bounds
105  inline double originalLowerBound() const
106  { return bound_[0];}
107  inline double originalUpperBound() const
108  { return bound_[rangeType_*numberRanges_-1];}
109  /// Type - 1 points, 2 ranges
110  inline int rangeType() const
111  { return rangeType_;}
112  /// Number of points
113  inline int numberRanges() const
114  { return numberRanges_;}
115  /// Ranges
116  inline double * bound() const
117  { return bound_;}
118  /** \brief Return true if object can take part in normal heuristics
119  */
120  virtual bool canDoHeuristics() const 
121  {return false;}
122
123private:
124  /// Just for debug (CBC_PRINT defined in CbcBranchLotsize.cpp)
125  void printLotsize(double value,bool condition,int type) const;
126
127private:
128  /// data
129
130  /// Column number in model
131  int columnNumber_;
132  /// Type - 1 points, 2 ranges
133  int rangeType_;
134  /// Number of points
135  int numberRanges_;
136  // largest gap
137  double largestGap_;
138  /// Ranges
139  double * bound_;
140  /// Current range
141  mutable int range_;
142};
143
144
145/** Lotsize branching object
146
147  This object can specify a two-way branch on an integer variable. For each
148  arm of the branch, the upper and lower bounds on the variable can be
149  independently specified.
150 
151  Variable_ holds the index of the integer variable in the integerVariable_
152  array of the model.
153*/
154
155class CbcLotsizeBranchingObject : public CbcBranchingObject {
156
157public:
158
159  /// Default constructor
160  CbcLotsizeBranchingObject ();
161
162  /** Create a lotsize floor/ceiling branch object
163
164    Specifies a simple two-way branch. Let \p value = x*. One arm of the
165    branch will be is lb <= x <= valid range below(x*), the other valid range above(x*) <= x <= ub.
166    Specify way = -1 to set the object state to perform the down arm first,
167    way = 1 for the up arm.
168  */
169  CbcLotsizeBranchingObject (CbcModel *model, int variable,
170                             int way , double value,const CbcLotsize * lotsize) ;
171 
172  /** Create a degenerate branch object
173
174    Specifies a `one-way branch'. Calling branch() for this object will
175    always result in lowerValue <= x <= upperValue. Used to fix in valid range
176  */
177
178  CbcLotsizeBranchingObject (CbcModel *model, int variable, int way,
179                             double lowerValue, double upperValue) ;
180 
181  /// Copy constructor
182  CbcLotsizeBranchingObject ( const CbcLotsizeBranchingObject &);
183   
184  /// Assignment operator
185  CbcLotsizeBranchingObject & operator= (const CbcLotsizeBranchingObject& rhs);
186
187  /// Clone
188  virtual CbcBranchingObject * clone() const;
189
190  /// Destructor
191  virtual ~CbcLotsizeBranchingObject ();
192 
193  using CbcBranchingObject::branch ;
194  /** \brief Sets the bounds for the variable according to the current arm
195             of the branch and advances the object state to the next arm.
196  */
197  virtual double branch();
198
199#if 0
200  // No need to override. Default works fine.
201  /** Reset every information so that the branching object appears to point to
202      the previous child. This method does not need to modify anything in any
203      solver. */
204  virtual void previousBranch();
205#endif
206
207  using CbcBranchingObject::print ;
208  /** \brief Print something about branch - only if log level high
209  */
210  virtual void print();
211
212  /** Return the type (an integer identifier) of \c this */
213  virtual int type() const { return 300; }
214
215  // LL: compareOriginalObject can be inherited from the CbcBranchingObject
216  // since variable_ uniquely defines the lot sizing object.
217
218  /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
219      same type and must have the same original object, but they may have
220      different feasible regions.
221      Return the appropriate CbcRangeCompare value (first argument being the
222      sub/superset if that's the case). In case of overlap (and if \c
223      replaceIfOverlap is true) replace the current branching object with one
224      whose feasible region is the overlap.
225   */
226  virtual CbcRangeCompare compareBranchingObject
227  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
228
229protected:
230  /// Lower [0] and upper [1] bounds for the down arm (way_ = -1)
231  double down_[2];
232  /// Lower [0] and upper [1] bounds for the up arm (way_ = 1)
233  double up_[2];
234};
235
236
237#endif
Note: See TracBrowser for help on using the repository browser.