source: trunk/Cbc/src/CbcBranchLotsize.hpp

Last change on this file was 2465, checked in by unxusr, 9 months ago

script to format sources

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