source: trunk/Cbc/src/CbcFollowOn.hpp @ 1432

Last change on this file since 1432 was 1432, checked in by bjarni, 9 years ago

Added extra return at end of each source file where needed, to remove possible linefeed conflicts (NightlyBuild? errors)

File size: 4.5 KB
Line 
1// Edwin 11/10/2009-- carved out of CbcBranchActual
2#ifndef CbcFollowOn_H
3#define CbcFollowOn_H
4
5#include "CbcBranchBase.hpp"
6#include "CoinPackedMatrix.hpp"
7
8/** Define a follow on class.
9    The idea of this is that in air-crew scheduling problems crew may fly in on flight A
10    and out on flight B or on some other flight.  A useful branch is one which on one side
11    fixes all which go out on flight B to 0, while the other branch fixes all those that do NOT
12    go out on flight B to 0.
13
14    This branching rule should be in addition to normal rules and have a high priority.
15*/
16
17class CbcFollowOn : public CbcObject {
18
19public:
20
21    // Default Constructor
22    CbcFollowOn ();
23
24    /** Useful constructor
25    */
26    CbcFollowOn (CbcModel * model);
27
28    // Copy constructor
29    CbcFollowOn ( const CbcFollowOn &);
30
31    /// Clone
32    virtual CbcObject * clone() const;
33
34    // Assignment operator
35    CbcFollowOn & operator=( const CbcFollowOn& rhs);
36
37    // Destructor
38    ~CbcFollowOn ();
39
40    /// Infeasibility - large is 0.5
41    virtual double infeasibility(const OsiBranchingInformation * info,
42                                 int &preferredWay) const;
43
44    using CbcObject::feasibleRegion ;
45    /// This looks at solution and sets bounds to contain solution
46    virtual void feasibleRegion();
47
48    /// Creates a branching object
49    virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ;
50    /// As some computation is needed in more than one place - returns row
51    virtual int gutsOfFollowOn(int & otherRow, int & preferredWay) const;
52
53protected:
54    /// data
55    /// Matrix
56    CoinPackedMatrix matrix_;
57    /// Matrix by row
58    CoinPackedMatrix matrixByRow_;
59    /// Possible rhs (if 0 then not possible)
60    int * rhs_;
61};
62
63/** General Branching Object class.
64    Each way fixes some variables to lower bound
65 */
66class CbcFixingBranchingObject : public CbcBranchingObject {
67
68public:
69
70    // Default Constructor
71    CbcFixingBranchingObject ();
72
73    // Useful constructor
74    CbcFixingBranchingObject (CbcModel * model,
75                              int way,
76                              int numberOnDownSide, const int * down,
77                              int numberOnUpSide, const int * up);
78
79    // Copy constructor
80    CbcFixingBranchingObject ( const CbcFixingBranchingObject &);
81
82    // Assignment operator
83    CbcFixingBranchingObject & operator=( const CbcFixingBranchingObject& rhs);
84
85    /// Clone
86    virtual CbcBranchingObject * clone() const;
87
88    // Destructor
89    virtual ~CbcFixingBranchingObject ();
90
91    using CbcBranchingObject::branch ;
92    /// Does next branch and updates state
93    virtual double branch();
94
95#ifdef JJF_ZERO
96    // No need to override. Default works fine.
97    /** Reset every information so that the branching object appears to point to
98        the previous child. This method does not need to modify anything in any
99        solver. */
100    virtual void previousBranch();
101#endif
102
103    using CbcBranchingObject::print ;
104    /** \brief Print something about branch - only if log level high
105    */
106    virtual void print();
107
108    /** Return the type (an integer identifier) of \c this */
109    virtual CbcBranchObjType type() const {
110        return FollowOnBranchObj;
111    }
112
113    /** Compare the original object of \c this with the original object of \c
114        brObj. Assumes that there is an ordering of the original objects.
115        This method should be invoked only if \c this and brObj are of the same
116        type.
117        Return negative/0/positive depending on whether \c this is
118        smaller/same/larger than the argument.
119    */
120    virtual int compareOriginalObject(const CbcBranchingObject* brObj) const;
121
122    /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
123        same type and must have the same original object, but they may have
124        different feasible regions.
125        Return the appropriate CbcRangeCompare value (first argument being the
126        sub/superset if that's the case). In case of overlap (and if \c
127        replaceIfOverlap is true) replace the current branching object with one
128        whose feasible region is the overlap.
129     */
130    virtual CbcRangeCompare compareBranchingObject
131    (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
132
133private:
134    /// data
135    /// Number on down list
136    int numberDown_;
137    /// Number on up list
138    int numberUp_;
139    /// downList - variables to fix to lb on down branch
140    int * downList_;
141    /// upList - variables to fix to lb on up branch
142    int * upList_;
143};
144
145#endif
146
Note: See TracBrowser for help on using the repository browser.