source: trunk/Cbc/src/CbcBranchLotsize.hpp @ 2122

Last change on this file since 2122 was 1573, checked in by lou, 9 years ago

Change to EPL license notice.

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