source: trunk/Cbc/src/CbcBranchCut.hpp @ 2014

Last change on this file since 2014 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: 5.8 KB
Line 
1/* $Id: CbcBranchCut.hpp 1573 2011-01-05 01:12:36Z forrest $ */
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 CbcBranchCut_H
7#define CbcBranchCut_H
8
9#include "CbcBranchBase.hpp"
10#include "OsiRowCut.hpp"
11#include "CoinPackedMatrix.hpp"
12
13/** Define a cut branching class.
14    At present empty - all stuff in descendants
15*/
16
17class CbcBranchCut : public CbcObject {
18
19public:
20
21    // Default Constructor
22    CbcBranchCut ();
23
24    /** In to maintain normal methods
25    */
26    CbcBranchCut (CbcModel * model);
27    // Copy constructor
28    CbcBranchCut ( const CbcBranchCut &);
29
30    /// Clone
31    virtual CbcObject * clone() const;
32
33    // Assignment operator
34    CbcBranchCut & operator=( const CbcBranchCut& rhs);
35
36    // Destructor
37    ~CbcBranchCut ();
38
39    /// Infeasibility
40    virtual double infeasibility(const OsiBranchingInformation * info,
41                                 int &preferredWay) const;
42
43    using CbcObject::feasibleRegion ;
44    /** Set bounds to contain the current solution.
45
46      More precisely, for the variable associated with this object, take the
47      value given in the current solution, force it within the current bounds
48      if required, then set the bounds to fix the variable at the integer
49      nearest the solution value.
50
51      At present this will do nothing
52    */
53    virtual void feasibleRegion();
54
55    /** \brief Return true if branch created by object should fix variables
56    */
57    virtual bool boundBranch() const ;
58
59    /// Creates a branching object
60    virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) ;
61
62    /** \brief Given a valid solution (with reduced costs, etc.),
63        return a branching object which would give a new feasible
64        point in the good direction.
65
66      The preferred branching object will force the variable to be +/-1 from
67      its current value, depending on the reduced cost and objective sense.  If
68      movement in the direction which improves the objective is impossible due
69      to bounds on the variable, the branching object will move in the other
70      direction.  If no movement is possible, the method returns NULL.
71
72      Only the bounds on this variable are considered when determining if the new
73      point is feasible.
74
75      At present this does nothing
76    */
77    virtual CbcBranchingObject * preferredNewFeasible() const;
78
79    /** \brief Given a valid solution (with reduced costs, etc.),
80        return a branching object which would give a new feasible
81        point in a bad direction.
82
83      As for preferredNewFeasible(), but the preferred branching object will
84      force movement in a direction that degrades the objective.
85
86      At present this does nothing
87    */
88    virtual CbcBranchingObject * notPreferredNewFeasible() const ;
89
90    using CbcObject::resetBounds ;
91    /** Reset original upper and lower bound values from the solver.
92
93      Handy for updating bounds held in this object after bounds held in the
94      solver have been tightened.
95     */
96    virtual void resetBounds();
97
98
99protected:
100    /// data
101
102};
103/** Cut branching object
104
105  This object can specify a two-way branch in terms of two cuts
106*/
107
108class CbcCutBranchingObject : public CbcBranchingObject {
109
110public:
111
112    /// Default constructor
113    CbcCutBranchingObject ();
114
115    /** Create a cut branching object
116
117        Cut down will applied on way=-1, up on way==1
118        Assumed down will be first so way_ set to -1
119    */
120    CbcCutBranchingObject (CbcModel * model, OsiRowCut & down, OsiRowCut &up, bool canFix);
121
122    /// Copy constructor
123    CbcCutBranchingObject ( const CbcCutBranchingObject &);
124
125    /// Assignment operator
126    CbcCutBranchingObject & operator= (const CbcCutBranchingObject& rhs);
127
128    /// Clone
129    virtual CbcBranchingObject * clone() const;
130
131    /// Destructor
132    virtual ~CbcCutBranchingObject ();
133
134    using CbcBranchingObject::branch ;
135    /** \brief Sets the bounds for variables or adds a cut depending on the
136               current arm of the branch and advances the object state to the next arm.
137           Returns change in guessed objective on next branch
138    */
139    virtual double branch();
140
141    using CbcBranchingObject::print ;
142    /** \brief Print something about branch - only if log level high
143    */
144    virtual void print();
145
146    /** \brief Return true if branch should fix variables
147    */
148    virtual bool boundBranch() const;
149
150    /** Return the type (an integer identifier) of \c this */
151    virtual CbcBranchObjType type() const {
152        return CutBranchingObj;
153    }
154
155    /** Compare the original object of \c this with the original object of \c
156        brObj. Assumes that there is an ordering of the original objects.
157        This method should be invoked only if \c this and brObj are of the same
158        type.
159        Return negative/0/positive depending on whether \c this is
160        smaller/same/larger than the argument.
161    */
162    virtual int compareOriginalObject(const CbcBranchingObject* brObj) const;
163
164    /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
165        same type and must have the same original object, but they may have
166        different feasible regions.
167        Return the appropriate CbcRangeCompare value (first argument being the
168        sub/superset if that's the case). In case of overlap (and if \c
169        replaceIfOverlap is true) replace the current branching object with one
170        whose feasible region is the overlap.
171     */
172    virtual CbcRangeCompare compareBranchingObject
173    (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
174
175protected:
176    /// Cut for the down arm (way_ = -1)
177    OsiRowCut down_;
178    /// Cut for the up arm (way_ = 1)
179    OsiRowCut up_;
180    /// True if one way can fix variables
181    bool canFix_;
182};
183#endif
Note: See TracBrowser for help on using the repository browser.