source: branches/devel/Cbc/examples/CbcBranchLink.hpp @ 424

Last change on this file since 424 was 424, checked in by forrest, 13 years ago

many changes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 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, 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};
88/** Branching object for Special ordered sets
89
90    Variable_ is the set id number (redundant, as the object also holds a
91    pointer to the set.
92 */
93class CbcLinkBranchingObject : public CbcBranchingObject {
94
95public:
96
97  // Default Constructor
98  CbcLinkBranchingObject ();
99
100  // Useful constructor
101  CbcLinkBranchingObject (CbcModel * model,  const CbcLink * set,
102                          int way,
103                          double separator);
104 
105  // Copy constructor
106  CbcLinkBranchingObject ( const CbcLinkBranchingObject &);
107   
108  // Assignment operator
109  CbcLinkBranchingObject & operator=( const CbcLinkBranchingObject& rhs);
110
111  /// Clone
112  virtual CbcBranchingObject * clone() const;
113
114  // Destructor
115  virtual ~CbcLinkBranchingObject ();
116 
117  /// Does next branch and updates state
118  virtual double branch(bool normalBranch=false);
119
120  /** \brief Print something about branch - only if log level high
121  */
122  virtual void print(bool normalBranch);
123private:
124  /// data
125  const CbcLink * set_;
126  /// separator
127  double separator_;
128};
129#endif
Note: See TracBrowser for help on using the repository browser.