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

Last change on this file since 2464 was 2464, checked in by unxusr, 5 months ago

.clang-format with proposal for formatting code

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