source: trunk/Cbc/src/CbcFollowOn.hpp

Last change on this file was 2465, checked in by unxusr, 8 months ago

script to format sources

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
RevLine 
[1573]1// $Id: CbcFollowOn.hpp 2465 2019-01-03 19:26:52Z 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
[1357]6// Edwin 11/10/2009-- carved out of CbcBranchActual
[1573]7
[1357]8#ifndef CbcFollowOn_H
9#define CbcFollowOn_H
10
11#include "CbcBranchBase.hpp"
[1882]12#include "OsiRowCut.hpp"
13#include "CoinHelperFunctions.hpp"
[1357]14#include "CoinPackedMatrix.hpp"
15
16/** Define a follow on class.
17    The idea of this is that in air-crew scheduling problems crew may fly in on flight A
18    and out on flight B or on some other flight.  A useful branch is one which on one side
19    fixes all which go out on flight B to 0, while the other branch fixes all those that do NOT
20    go out on flight B to 0.
21
22    This branching rule should be in addition to normal rules and have a high priority.
23*/
24
25class CbcFollowOn : public CbcObject {
26
27public:
[2464]28  // Default Constructor
29  CbcFollowOn();
[1357]30
[2464]31  /** Useful constructor
[1357]32    */
[2464]33  CbcFollowOn(CbcModel *model);
[1357]34
[2464]35  // Copy constructor
36  CbcFollowOn(const CbcFollowOn &);
[1357]37
[2464]38  /// Clone
39  virtual CbcObject *clone() const;
[1357]40
[2464]41  // Assignment operator
42  CbcFollowOn &operator=(const CbcFollowOn &rhs);
[1357]43
[2464]44  // Destructor
45  ~CbcFollowOn();
[1357]46
[2464]47  /// Infeasibility - large is 0.5
48  virtual double infeasibility(const OsiBranchingInformation *info,
49    int &preferredWay) const;
[1357]50
[2464]51  using CbcObject::feasibleRegion;
52  /// This looks at solution and sets bounds to contain solution
53  virtual void feasibleRegion();
[1357]54
[2464]55  /// Creates a branching object
56  virtual CbcBranchingObject *createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way);
57  /// As some computation is needed in more than one place - returns row
58  virtual int gutsOfFollowOn(int &otherRow, int &preferredWay) const;
[1357]59
60protected:
[2464]61  /// data
62  /// Matrix
63  CoinPackedMatrix matrix_;
64  /// Matrix by row
65  CoinPackedMatrix matrixByRow_;
66  /// Possible rhs (if 0 then not possible)
67  int *rhs_;
[1357]68};
69
70/** General Branching Object class.
71    Each way fixes some variables to lower bound
72 */
73class CbcFixingBranchingObject : public CbcBranchingObject {
74
75public:
[2464]76  // Default Constructor
77  CbcFixingBranchingObject();
[1357]78
[2464]79  // Useful constructor
80  CbcFixingBranchingObject(CbcModel *model,
81    int way,
82    int numberOnDownSide, const int *down,
83    int numberOnUpSide, const int *up);
[1357]84
[2464]85  // Copy constructor
86  CbcFixingBranchingObject(const CbcFixingBranchingObject &);
[1357]87
[2464]88  // Assignment operator
89  CbcFixingBranchingObject &operator=(const CbcFixingBranchingObject &rhs);
[1357]90
[2464]91  /// Clone
92  virtual CbcBranchingObject *clone() const;
[1357]93
[2464]94  // Destructor
95  virtual ~CbcFixingBranchingObject();
[1357]96
[2464]97  using CbcBranchingObject::branch;
98  /// Does next branch and updates state
99  virtual double branch();
[1357]100
[1393]101#ifdef JJF_ZERO
[2464]102  // No need to override. Default works fine.
103  /** Reset every information so that the branching object appears to point to
[1357]104        the previous child. This method does not need to modify anything in any
105        solver. */
[2464]106  virtual void previousBranch();
[1357]107#endif
108
[2464]109  using CbcBranchingObject::print;
110  /** \brief Print something about branch - only if log level high
[1357]111    */
[2464]112  virtual void print();
[1357]113
[2464]114  /** Return the type (an integer identifier) of \c this */
115  virtual CbcBranchObjType type() const
116  {
117    return FollowOnBranchObj;
118  }
[1357]119
[2464]120  /** Compare the original object of \c this with the original object of \c
[1357]121        brObj. Assumes that there is an ordering of the original objects.
122        This method should be invoked only if \c this and brObj are of the same
123        type.
124        Return negative/0/positive depending on whether \c this is
125        smaller/same/larger than the argument.
126    */
[2464]127  virtual int compareOriginalObject(const CbcBranchingObject *brObj) const;
[1357]128
[2464]129  /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
[1357]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     */
[2464]137  virtual CbcRangeCompare compareBranchingObject(const CbcBranchingObject *brObj, const bool replaceIfOverlap = false);
[1357]138
139private:
[2464]140  /// data
141  /// Number on down list
142  int numberDown_;
143  /// Number on up list
144  int numberUp_;
145  /// downList - variables to fix to lb on down branch
146  int *downList_;
147  /// upList - variables to fix to lb on up branch
148  int *upList_;
[1357]149};
150
[1880]151/** Define an idiotic idea class.
152    The idea of this is that we take some integer variables away from integer and
153    sum them with some randomness to get signed sum close to 0.5.  We then can
154    branch to exclude that gap.
155
156    This branching rule should be in addition to normal rules and have a high priority.
157*/
158
159class CbcIdiotBranch : public CbcObject {
160
161public:
[2464]162  // Default Constructor
163  CbcIdiotBranch();
[1880]164
[2464]165  /** Useful constructor
[1880]166    */
[2464]167  CbcIdiotBranch(CbcModel *model);
[1880]168
[2464]169  // Copy constructor
170  CbcIdiotBranch(const CbcIdiotBranch &);
[1880]171
[2464]172  /// Clone
173  virtual CbcObject *clone() const;
[1880]174
[2464]175  // Assignment operator
176  CbcIdiotBranch &operator=(const CbcIdiotBranch &rhs);
[1880]177
[2464]178  // Destructor
179  ~CbcIdiotBranch();
[1880]180
[2464]181  /// Infeasibility - large is 0.5
182  virtual double infeasibility(const OsiBranchingInformation *info,
183    int &preferredWay) const;
[1880]184
[2464]185  using CbcObject::feasibleRegion;
186  /// This looks at solution and sets bounds to contain solution
187  virtual void feasibleRegion();
[1880]188
[2464]189  /// Creates a branching object
190  virtual CbcBranchingObject *createCbcBranch(OsiSolverInterface *solver, const OsiBranchingInformation *info, int way);
191  /// Initialize for branching
192  virtual void initializeForBranching(CbcModel *);
193
[1880]194protected:
[2464]195  /// Build "cut"
196  OsiRowCut buildCut(const OsiBranchingInformation *info, int type, int &preferredWay) const;
197  /// data
198  /// Thread specific random number generator
199  mutable CoinThreadRandom randomNumberGenerator_;
200  /// Saved version of thread specific random number generator
201  mutable CoinThreadRandom savedRandomNumberGenerator_;
[1880]202};
203
[1389]204#endif
[2465]205
206/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
207*/
Note: See TracBrowser for help on using the repository browser.