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

Last change on this file since 1461 was 1389, checked in by caphillSNL, 10 years ago

Start at adding documentation, removing magic numbers, removing dead code, etc.
Added an enum for type in classes derived from CbCBranchingObject. It's safer,
handier for debugging (inspection in a debugger), and clearly shows the relationship
between the dozen or so special numbers. Numbers are the same as they were before to
ensure no changes in correctness.

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