source: stable/2.4/Cbc/src/CbcBranchLotsize.hpp @ 1271

Last change on this file since 1271 was 1271, checked in by forrest, 10 years ago

Creating new stable branch 2.4 from trunk (rev 1270)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.4 KB
Line 
1/* $Id: CbcBranchLotsize.hpp 1271 2009-11-05 15:57:25Z forrest $ */
2// Copyright (C) 2004, International Business Machines
3// Corporation and others.  All Rights Reserved.
4#ifndef CbcBranchLotsize_H
5#define CbcBranchLotsize_H
6
7#include "CbcBranchBase.hpp"
8
9/** Lotsize class */
10
11
12class CbcLotsize : public CbcObject {
13
14public:
15
16  // Default Constructor
17  CbcLotsize ();
18
19  /* Useful constructor - passed model index.
20     Also passed valid values - if range then pairs
21  */
22  CbcLotsize (CbcModel * model, int iColumn,
23              int numberPoints, const double * points, bool range=false);
24 
25  // Copy constructor
26  CbcLotsize ( const CbcLotsize &);
27   
28  /// Clone
29  virtual CbcObject * clone() const;
30
31  // Assignment operator
32  CbcLotsize & operator=( const CbcLotsize& rhs);
33
34  // Destructor
35  ~CbcLotsize ();
36 
37  /// Infeasibility - large is 0.5
38  virtual double infeasibility(const OsiBranchingInformation * info,
39                               int &preferredWay) const;
40
41  using CbcObject::feasibleRegion ;
42  /** Set bounds to contain the current solution.
43
44    More precisely, for the variable associated with this object, take the
45    value given in the current solution, force it within the current bounds
46    if required, then set the bounds to fix the variable at the integer
47    nearest the solution value.
48  */
49  virtual void feasibleRegion();
50
51  /// Creates a branching object
52  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, 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  /// Set model column number
99  inline void setModelSequence(int value)
100  {columnNumber_ = value;}
101
102  /** Column number if single column object -1 otherwise,
103      so returns >= 0
104      Used by heuristics
105  */
106  virtual int columnNumber() const;
107  /// Original bounds
108  inline double originalLowerBound() const
109  { return bound_[0];}
110  inline double originalUpperBound() const
111  { return bound_[rangeType_*numberRanges_-1];}
112  /// Type - 1 points, 2 ranges
113  inline int rangeType() const
114  { return rangeType_;}
115  /// Number of points
116  inline int numberRanges() const
117  { return numberRanges_;}
118  /// Ranges
119  inline double * bound() const
120  { return bound_;}
121  /** \brief Return true if object can take part in normal heuristics
122  */
123  virtual bool canDoHeuristics() const 
124  {return false;}
125
126private:
127  /// Just for debug (CBC_PRINT defined in CbcBranchLotsize.cpp)
128  void printLotsize(double value,bool condition,int type) const;
129
130private:
131  /// data
132
133  /// Column number in model
134  int columnNumber_;
135  /// Type - 1 points, 2 ranges
136  int rangeType_;
137  /// Number of points
138  int numberRanges_;
139  // largest gap
140  double largestGap_;
141  /// Ranges
142  double * bound_;
143  /// Current range
144  mutable int range_;
145};
146
147
148/** Lotsize branching object
149
150  This object can specify a two-way branch on an integer variable. For each
151  arm of the branch, the upper and lower bounds on the variable can be
152  independently specified.
153 
154  Variable_ holds the index of the integer variable in the integerVariable_
155  array of the model.
156*/
157
158class CbcLotsizeBranchingObject : public CbcBranchingObject {
159
160public:
161
162  /// Default constructor
163  CbcLotsizeBranchingObject ();
164
165  /** Create a lotsize floor/ceiling branch object
166
167    Specifies a simple two-way branch. Let \p value = x*. One arm of the
168    branch will be is lb <= x <= valid range below(x*), the other valid range above(x*) <= x <= ub.
169    Specify way = -1 to set the object state to perform the down arm first,
170    way = 1 for the up arm.
171  */
172  CbcLotsizeBranchingObject (CbcModel *model, int variable,
173                             int way , double value,const CbcLotsize * lotsize) ;
174 
175  /** Create a degenerate branch object
176
177    Specifies a `one-way branch'. Calling branch() for this object will
178    always result in lowerValue <= x <= upperValue. Used to fix in valid range
179  */
180
181  CbcLotsizeBranchingObject (CbcModel *model, int variable, int way,
182                             double lowerValue, double upperValue) ;
183 
184  /// Copy constructor
185  CbcLotsizeBranchingObject ( const CbcLotsizeBranchingObject &);
186   
187  /// Assignment operator
188  CbcLotsizeBranchingObject & operator= (const CbcLotsizeBranchingObject& rhs);
189
190  /// Clone
191  virtual CbcBranchingObject * clone() const;
192
193  /// Destructor
194  virtual ~CbcLotsizeBranchingObject ();
195 
196  using CbcBranchingObject::branch ;
197  /** \brief Sets the bounds for the variable according to the current arm
198             of the branch and advances the object state to the next arm.
199  */
200  virtual double branch();
201
202#if 0
203  // No need to override. Default works fine.
204  /** Reset every information so that the branching object appears to point to
205      the previous child. This method does not need to modify anything in any
206      solver. */
207  virtual void previousBranch();
208#endif
209
210  using CbcBranchingObject::print ;
211  /** \brief Print something about branch - only if log level high
212  */
213  virtual void print();
214
215  /** Return the type (an integer identifier) of \c this */
216  virtual int type() const { return 300; }
217
218  // LL: compareOriginalObject can be inherited from the CbcBranchingObject
219  // since variable_ uniquely defines the lot sizing object.
220
221  /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
222      same type and must have the same original object, but they may have
223      different feasible regions.
224      Return the appropriate CbcRangeCompare value (first argument being the
225      sub/superset if that's the case). In case of overlap (and if \c
226      replaceIfOverlap is true) replace the current branching object with one
227      whose feasible region is the overlap.
228   */
229  virtual CbcRangeCompare compareBranchingObject
230  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
231
232protected:
233  /// Lower [0] and upper [1] bounds for the down arm (way_ = -1)
234  double down_[2];
235  /// Lower [0] and upper [1] bounds for the up arm (way_ = 1)
236  double up_[2];
237};
238
239
240#endif
Note: See TracBrowser for help on using the repository browser.