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

Last change on this file since 2464 was 2464, checked in by unxusr, 9 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: 4.8 KB
Line 
1// $Id: CbcNWay.hpp 2464 2019-01-03 19:03:23Z unxusr $
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/9/2009-- carved out of CbcBranchActual
7
8/** Define an n-way class for variables.
9    Only valid value is one at UB others at LB
10    Normally 0-1
11*/
12#ifndef CbcNWay_H
13#define CbcNWay_H
14
15class CbcNWay : public CbcObject {
16
17public:
18  // Default Constructor
19  CbcNWay();
20
21  /** Useful constructor (which are matrix indices)
22    */
23  CbcNWay(CbcModel *model, int numberMembers,
24    const int *which, int identifier);
25
26  // Copy constructor
27  CbcNWay(const CbcNWay &);
28
29  /// Clone
30  virtual CbcObject *clone() const;
31
32  /// Assignment operator
33  CbcNWay &operator=(const CbcNWay &rhs);
34
35  /// Destructor
36  virtual ~CbcNWay();
37
38  /// Set up a consequence for a single member
39  void setConsequence(int iColumn, const CbcConsequence &consequence);
40
41  /// Applies a consequence for a single member
42  void applyConsequence(int iSequence, int state) const;
43
44  /// Infeasibility - large is 0.5 (and 0.5 will give this)
45  virtual double infeasibility(const OsiBranchingInformation *info,
46    int &preferredWay) const;
47
48  using CbcObject::feasibleRegion;
49  /// This looks at solution and sets bounds to contain solution
50  virtual void feasibleRegion();
51
52  /// Creates a branching object
53  virtual CbcBranchingObject *createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way);
54
55  /// Number of members
56  inline int numberMembers() const
57  {
58    return numberMembers_;
59  }
60
61  /// Members (indices in range 0 ... numberColumns-1)
62  inline const int *members() const
63  {
64    return members_;
65  }
66  /// Redoes data when sequence numbers change
67  virtual void redoSequenceEtc(CbcModel *model, int numberColumns, const int *originalColumns);
68
69protected:
70  /// data
71  /// Number of members
72  int numberMembers_;
73
74  /// Members (indices in range 0 ... numberColumns-1)
75  int *members_;
76  /// Consequences (normally NULL)
77  CbcConsequence **consequence_;
78};
79/** N way branching Object class.
80    Variable is number of set.
81 */
82class CbcNWayBranchingObject : public CbcBranchingObject {
83
84public:
85  // Default Constructor
86  CbcNWayBranchingObject();
87
88  /** Useful constructor - order had matrix indices
89        way_ -1 corresponds to setting first, +1 to second, +3 etc.
90        this is so -1 and +1 have similarity to normal
91    */
92  CbcNWayBranchingObject(CbcModel *model, const CbcNWay *nway,
93    int numberBranches, const int *order);
94
95  // Copy constructor
96  CbcNWayBranchingObject(const CbcNWayBranchingObject &);
97
98  // Assignment operator
99  CbcNWayBranchingObject &operator=(const CbcNWayBranchingObject &rhs);
100
101  /// Clone
102  virtual CbcBranchingObject *clone() const;
103
104  // Destructor
105  virtual ~CbcNWayBranchingObject();
106
107  using CbcBranchingObject::branch;
108  /// Does next branch and updates state
109  virtual double branch();
110
111#ifdef JJF_ZERO
112  // FIXME: what do we need to do here?
113  /** Reset every information so that the branching object appears to point to
114        the previous child. This method does not need to modify anything in any
115        solver. */
116  virtual void previousBranch();
117#endif
118
119  using CbcBranchingObject::print;
120  /** \brief Print something about branch - only if log level high
121    */
122  virtual void print();
123  /** The number of branch arms created for this branching object
124    */
125  virtual int numberBranches() const
126  {
127    return numberInSet_;
128  }
129  /// Is this a two way object (-1 down, +1 up)
130  virtual bool twoWay() const
131  {
132    return false;
133  }
134
135  /** Return the type (an integer identifier) of \c this */
136  virtual CbcBranchObjType type() const
137  {
138    return NWayBranchObj;
139  }
140
141  /** Compare the original object of \c this with the original object of \c
142        brObj. Assumes that there is an ordering of the original objects.
143        This method should be invoked only if \c this and brObj are of the same
144        type.
145        Return negative/0/positive depending on whether \c this is
146        smaller/same/larger than the argument.
147    */
148  virtual int compareOriginalObject(const CbcBranchingObject *brObj) const;
149
150  /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
151        same type and must have the same original object, but they may have
152        different feasible regions.
153        Return the appropriate CbcRangeCompare value (first argument being the
154        sub/superset if that's the case). In case of overlap (and if \c
155        replaceIfOverlap is true) replace the current branching object with one
156        whose feasible region is the overlap.
157     */
158  virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap = false);
159
160private:
161  /// order of branching - points back to CbcNWay
162  int *order_;
163  /// Points back to object
164  const CbcNWay *object_;
165  /// Number in set
166  int numberInSet_;
167};
168#endif
Note: See TracBrowser for help on using the repository browser.