source: releases/2.7.1/Cbc/src/CbcFollowOn.hpp @ 1995

Last change on this file since 1995 was 1573, checked in by lou, 8 years ago

Change to EPL license notice.

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