source: trunk/Cbc/examples/CbcBranchLink.hpp @ 1422

Last change on this file since 1422 was 932, checked in by forrest, 11 years ago

allow Compare

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