source: trunk/Cbc/examples/CbcBranchLink.hpp

Last change on this file was 2469, checked in by unxusr, 6 weeks ago

formatting

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1// $Id: CbcBranchLink.hpp 2469 2019-01-06 23:17:46Z forrest $
2// Copyright (C) 2005, 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 CbcBranchLink_H
7#define CbcBranchLink_H
8
9#include "CbcBranchBase.hpp"
10
11/** Define Special Linked Ordered Sets.
12
13*/
14
15class CbcLink : public CbcObject {
16
17public:
18  // Default Constructor
19  CbcLink();
20
21  /** Useful constructor - A valid solution is if all variables are zero
22      apart from k*numberLink to (k+1)*numberLink-1 where k is 0 through
23      numberInSet-1.  The length of weights array is numberInSet.
24      For this constructor the variables in matrix are the numberInSet*numberLink
25      starting at first. If weights null then 0,1,2..
26  */
27  CbcLink(CbcModel *model, int numberMembers,
28    int numberLinks, int first,
29    const double *weights, int setNumber);
30  /** Useful constructor - A valid solution is if all variables are zero
31      apart from k*numberLink to (k+1)*numberLink-1 where k is 0 through
32      numberInSet-1.  The length of weights array is numberInSet.
33      For this constructor the variables are given by list - grouped.
34      If weights null then 0,1,2..
35  */
36  CbcLink(CbcModel *model, int numberMembers,
37    int numberLinks, int typeSOS, const int *which,
38    const double *weights, int setNumber);
39
40  // Copy constructor
41  CbcLink(const CbcLink &);
42
43  /// Clone
44  virtual CbcObject *clone() const;
45
46  // Assignment operator
47  CbcLink &operator=(const CbcLink &rhs);
48
49  // Destructor
50  ~CbcLink();
51
52  /// Infeasibility - large is 0.5
53  virtual double infeasibility(int &preferredWay) const;
54
55  /// This looks at solution and sets bounds to contain solution
56  virtual void feasibleRegion();
57  /// Creates a branching object
58  virtual CbcBranchingObject *createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way);
59
60  /// Number of members
61  inline int numberMembers() const
62  {
63    return numberMembers_;
64  }
65
66  /// Number of links for each member
67  inline int numberLinks() const
68  {
69    return numberLinks_;
70  }
71
72  /// Which variables
73  inline const int *which() const
74  {
75    return which_;
76  }
77
78  /** Array of weights */
79  inline const double *weights() const
80  {
81    return weights_;
82  }
83
84private:
85  /// data
86
87  /// Weights
88  double *weights_;
89
90  /// Number of members
91  int numberMembers_;
92  /// Number of links
93  int numberLinks_;
94  /// Members
95  int *which_;
96  /// Type 1 or 2
97  int sosType_;
98};
99/** Branching object for Special ordered sets
100
101    Variable_ is the set id number (redundant, as the object also holds a
102    pointer to the set.
103 */
104class CbcLinkBranchingObject : public CbcBranchingObject {
105
106public:
107  // Default Constructor
108  CbcLinkBranchingObject();
109
110  // Useful constructor
111  CbcLinkBranchingObject(CbcModel *model, const CbcLink *set,
112    int way,
113    double separator);
114
115  // Copy constructor
116  CbcLinkBranchingObject(const CbcLinkBranchingObject &);
117
118  // Assignment operator
119  CbcLinkBranchingObject &operator=(const CbcLinkBranchingObject &rhs);
120
121  /// Clone
122  virtual CbcBranchingObject *clone() const;
123
124  // Destructor
125  virtual ~CbcLinkBranchingObject();
126
127  /// Does next branch and updates state
128  virtual double branch();
129
130  /** \brief Print something about branch - only if log level high
131  */
132  virtual void print();
133  /** Return the type (an integer identifier) of \c this */
134  virtual CbcBranchObjType type() const
135  {
136    return CbcBranchObjType(0);
137  } /*FIXME what type() should be returned here? */
138
139  /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
140      same type and must have the same original object, but they may have
141      different feasible regions.
142      Return the appropriate CbcRangeCompare value (first argument being the
143      sub/superset if that's the case). In case of overlap (and if \c
144      replaceIfOverlap is true) replace the current branching object with one
145      whose feasible region is the overlap.
146   */
147  virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap = false);
148
149private:
150  /// data
151  const CbcLink *set_;
152  /// separator
153  double separator_;
154};
155#endif
Note: See TracBrowser for help on using the repository browser.