source: trunk/Cbc/examples/CbcBranchLink.hpp

Last change on this file was 1900, checked in by forrest, 5 years ago

fix some examples and a bug on repeated use of same CbcModel?

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