summaryrefslogtreecommitdiff
path: root/thirdparty/linux/include/coin/CbcBranchCut.hpp
blob: 0fdc940922f4f0f61faac993c680983398c0ff4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/* $Id: CbcBranchCut.hpp 1573 2011-01-05 01:12:36Z lou $ */
// Copyright (C) 2004, International Business Machines
// Corporation and others.  All Rights Reserved.
// This code is licensed under the terms of the Eclipse Public License (EPL).

#ifndef CbcBranchCut_H
#define CbcBranchCut_H

#include "CbcBranchBase.hpp"
#include "OsiRowCut.hpp"
#include "CoinPackedMatrix.hpp"

/** Define a cut branching class.
    At present empty - all stuff in descendants
*/

class CbcBranchCut : public CbcObject {

public:

    // Default Constructor
    CbcBranchCut ();

    /** In to maintain normal methods
    */
    CbcBranchCut (CbcModel * model);
    // Copy constructor
    CbcBranchCut ( const CbcBranchCut &);

    /// Clone
    virtual CbcObject * clone() const;

    // Assignment operator
    CbcBranchCut & operator=( const CbcBranchCut& rhs);

    // Destructor
    ~CbcBranchCut ();

    /// Infeasibility
    virtual double infeasibility(const OsiBranchingInformation * info,
                                 int &preferredWay) const;

    using CbcObject::feasibleRegion ;
    /** Set bounds to contain the current solution.

      More precisely, for the variable associated with this object, take the
      value given in the current solution, force it within the current bounds
      if required, then set the bounds to fix the variable at the integer
      nearest the solution value.

      At present this will do nothing
    */
    virtual void feasibleRegion();

    /** \brief Return true if branch created by object should fix variables
    */
    virtual bool boundBranch() const ;

    /// Creates a branching object
    virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ;

    /** \brief Given a valid solution (with reduced costs, etc.),
        return a branching object which would give a new feasible
        point in the good direction.

      The preferred branching object will force the variable to be +/-1 from
      its current value, depending on the reduced cost and objective sense.  If
      movement in the direction which improves the objective is impossible due
      to bounds on the variable, the branching object will move in the other
      direction.  If no movement is possible, the method returns NULL.

      Only the bounds on this variable are considered when determining if the new
      point is feasible.

      At present this does nothing
    */
    virtual CbcBranchingObject * preferredNewFeasible() const;

    /** \brief Given a valid solution (with reduced costs, etc.),
        return a branching object which would give a new feasible
        point in a bad direction.

      As for preferredNewFeasible(), but the preferred branching object will
      force movement in a direction that degrades the objective.

      At present this does nothing
    */
    virtual CbcBranchingObject * notPreferredNewFeasible() const ;

    using CbcObject::resetBounds ;
    /** Reset original upper and lower bound values from the solver.

      Handy for updating bounds held in this object after bounds held in the
      solver have been tightened.
     */
    virtual void resetBounds();


protected:
    /// data

};
/** Cut branching object

  This object can specify a two-way branch in terms of two cuts
*/

class CbcCutBranchingObject : public CbcBranchingObject {

public:

    /// Default constructor
    CbcCutBranchingObject ();

    /** Create a cut branching object

        Cut down will applied on way=-1, up on way==1
        Assumed down will be first so way_ set to -1
    */
    CbcCutBranchingObject (CbcModel * model, OsiRowCut & down, OsiRowCut &up, bool canFix);

    /// Copy constructor
    CbcCutBranchingObject ( const CbcCutBranchingObject &);

    /// Assignment operator
    CbcCutBranchingObject & operator= (const CbcCutBranchingObject& rhs);

    /// Clone
    virtual CbcBranchingObject * clone() const;

    /// Destructor
    virtual ~CbcCutBranchingObject ();

    using CbcBranchingObject::branch ;
    /** \brief Sets the bounds for variables or adds a cut depending on the
               current arm of the branch and advances the object state to the next arm.
           Returns change in guessed objective on next branch
    */
    virtual double branch();

    using CbcBranchingObject::print ;
    /** \brief Print something about branch - only if log level high
    */
    virtual void print();

    /** \brief Return true if branch should fix variables
    */
    virtual bool boundBranch() const;

    /** Return the type (an integer identifier) of \c this */
    virtual CbcBranchObjType type() const {
        return CutBranchingObj;
    }

    /** Compare the original object of \c this with the original object of \c
        brObj. Assumes that there is an ordering of the original objects.
        This method should be invoked only if \c this and brObj are of the same
        type.
        Return negative/0/positive depending on whether \c this is
        smaller/same/larger than the argument.
    */
    virtual int compareOriginalObject(const CbcBranchingObject* brObj) const;

    /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
        same type and must have the same original object, but they may have
        different feasible regions.
        Return the appropriate CbcRangeCompare value (first argument being the
        sub/superset if that's the case). In case of overlap (and if \c
        replaceIfOverlap is true) replace the current branching object with one
        whose feasible region is the overlap.
     */
    virtual CbcRangeCompare compareBranchingObject
    (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);

protected:
    /// Cut for the down arm (way_ = -1)
    OsiRowCut down_;
    /// Cut for the up arm (way_ = 1)
    OsiRowCut up_;
    /// True if one way can fix variables
    bool canFix_;
};
#endif