Cgl  0.60.7
CglTreeInfo.hpp
Go to the documentation of this file.
1 // $Id$
2 // Copyright (C) 2000, 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 CglTreeInfo_H
7 #define CglTreeInfo_H
8 
9 #include "OsiCuts.hpp"
10 #include "OsiSolverInterface.hpp"
11 #include "CoinHelperFunctions.hpp"
12 class CglStored;
15 class CglTreeInfo {
16 public:
18  int level;
21  int pass;
38  int options;
40  bool inTree;
45  int hasParent;
47  OsiSolverInterface *parentSolver;
59  OsiRowCut **strengthenRow;
61  CoinThreadRandom *randomNumberGenerator;
63  CglTreeInfo();
64 
67  const CglTreeInfo &);
69  virtual CglTreeInfo *clone() const;
70 
72  CglTreeInfo &
73  operator=(
74  const CglTreeInfo &rhs);
75 
77  virtual ~CglTreeInfo();
79  virtual bool fixes(int, int, int, bool) { return false; }
82  virtual int initializeFixing(const OsiSolverInterface *) { return 0; }
83 };
84 
86 typedef struct {
87  //unsigned int oneFixed:1; // nonzero if variable to 1 fixes all
88  //unsigned int sequence:31; // variable (in matrix) (but also see cliqueRow_)
89  unsigned int fixes;
90 } CliqueEntry;
91 
93 public:
97  CglTreeProbingInfo(const OsiSolverInterface *model);
98 
101  const CglTreeProbingInfo &);
103  virtual CglTreeInfo *clone() const;
104 
107  operator=(
108  const CglTreeProbingInfo &rhs);
109 
111  virtual ~CglTreeProbingInfo();
112  OsiSolverInterface *analyze(const OsiSolverInterface &si, int createSolver = 0,
113  int numberExtraCliques = 0, const CoinBigIndex *starts = NULL,
114  const CliqueEntry *entries = NULL, const char *type = NULL);
118  virtual bool fixes(int variable, int toValue, int fixedVariable, bool fixedToLower);
121  virtual int initializeFixing(const OsiSolverInterface *model);
123  int fixColumns(OsiSolverInterface &si) const;
125  int fixColumns(int iColumn, int value, OsiSolverInterface &si) const;
127  int packDown();
129  void generateCuts(const OsiSolverInterface &si, OsiCuts &cs,
130  const CglTreeInfo info) const;
133  {
134  convert();
135  return fixEntry_;
136  }
138  inline int *toZero()
139  {
140  convert();
141  return toZero_;
142  }
144  inline int *toOne()
145  {
146  convert();
147  return toOne_;
148  }
150  inline int *integerVariable() const
151  {
152  return integerVariable_;
153  }
155  inline int *backward() const
156  {
157  return backward_;
158  }
160  inline int numberVariables() const
161  {
162  return numberVariables_;
163  }
165  inline int numberIntegers() const
166  {
167  return numberIntegers_;
168  }
169 
170 private:
172  void convert();
173 
174 protected:
178  int *toZero_;
180  int *toOne_;
184  int *backward_;
195 };
196 inline int sequenceInCliqueEntry(const CliqueEntry &cEntry)
197 {
198  return cEntry.fixes & 0x7fffffff;
199 }
200 inline void setSequenceInCliqueEntry(CliqueEntry &cEntry, int sequence)
201 {
202  cEntry.fixes = sequence | (cEntry.fixes & 0x80000000);
203 }
204 inline bool oneFixesInCliqueEntry(const CliqueEntry &cEntry)
205 {
206  return (cEntry.fixes & 0x80000000) != 0;
207 }
208 inline void setOneFixesInCliqueEntry(CliqueEntry &cEntry, bool oneFixes)
209 {
210  cEntry.fixes = (oneFixes ? 0x80000000 : 0) | (cEntry.fixes & 0x7fffffff);
211 }
212 
213 #endif
214 
215 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
216 */
CglTreeProbingInfo::toOne_
int * toOne_
Starts of integer variable going to one.
Definition: CglTreeInfo.hpp:180
CglTreeInfo::options
int options
Options 1 - treat costed integers as important 2 - switch off some stuff as variables semi-integer 4 ...
Definition: CglTreeInfo.hpp:38
CglTreeInfo::randomNumberGenerator
CoinThreadRandom * randomNumberGenerator
Optional pointer to thread specific random number generator.
Definition: CglTreeInfo.hpp:61
CglTreeProbingInfo::toZero_
int * toZero_
Starts of integer variable going to zero.
Definition: CglTreeInfo.hpp:178
CglTreeProbingInfo::fixingEntry_
int * fixingEntry_
Entries for fixing variable when collecting.
Definition: CglTreeInfo.hpp:186
CglTreeProbingInfo::generateCuts
void generateCuts(const OsiSolverInterface &si, OsiCuts &cs, const CglTreeInfo info) const
Generate cuts from implications.
CglTreeInfo::strengthenRow
OsiRowCut ** strengthenRow
Replacement array.
Definition: CglTreeInfo.hpp:59
CglTreeProbingInfo::numberIntegers
int numberIntegers() const
Number of 0-1 variables.
Definition: CglTreeInfo.hpp:165
CglTreeProbingInfo::backward
int * backward() const
Backward look up.
Definition: CglTreeInfo.hpp:155
CglTreeInfo
Information about where the cut generator is invoked from.
Definition: CglTreeInfo.hpp:15
CglTreeInfo::~CglTreeInfo
virtual ~CglTreeInfo()
Destructor.
CglTreeProbingInfo::analyze
OsiSolverInterface * analyze(const OsiSolverInterface &si, int createSolver=0, int numberExtraCliques=0, const CoinBigIndex *starts=NULL, const CliqueEntry *entries=NULL, const char *type=NULL)
CglTreeInfo::clone
virtual CglTreeInfo * clone() const
Clone.
CglStored
Stored Cut Generator Class.
Definition: CglStored.hpp:16
CglTreeProbingInfo::fixEntry_
CliqueEntry * fixEntry_
Entries for fixing variables.
Definition: CglTreeInfo.hpp:176
CglTreeInfo::hasParent
int hasParent
nonzero if called from child of main model 1 if heuristic run 2 if doing full search
Definition: CglTreeInfo.hpp:45
setSequenceInCliqueEntry
void setSequenceInCliqueEntry(CliqueEntry &cEntry, int sequence)
Definition: CglTreeInfo.hpp:200
CliqueEntry::fixes
unsigned int fixes
Definition: CglTreeInfo.hpp:89
oneFixesInCliqueEntry
bool oneFixesInCliqueEntry(const CliqueEntry &cEntry)
Definition: CglTreeInfo.hpp:204
CglTreeInfo::parentSolver
OsiSolverInterface * parentSolver
parent solver
Definition: CglTreeInfo.hpp:47
CglTreeInfo::CglTreeInfo
CglTreeInfo()
Default constructor.
CglTreeProbingInfo::numberVariables
int numberVariables() const
Number of variables.
Definition: CglTreeInfo.hpp:160
CglTreeProbingInfo::clone
virtual CglTreeInfo * clone() const
Clone.
CglTreeProbingInfo::fixes
virtual bool fixes(int variable, int toValue, int fixedVariable, bool fixedToLower)
Take action if cut generator can fix a variable (toValue -1 for down, +1 for up) Returns true if stil...
CglTreeProbingInfo::convert
void convert()
Converts to ordered.
CglTreeProbingInfo::numberIntegers_
int numberIntegers_
Number of 0-1 variables.
Definition: CglTreeInfo.hpp:190
CglTreeProbingInfo::integerVariable_
int * integerVariable_
List of 0-1 integer variables.
Definition: CglTreeInfo.hpp:182
CglTreeInfo::operator=
CglTreeInfo & operator=(const CglTreeInfo &rhs)
Assignment operator.
CglTreeProbingInfo::maximumEntries_
int maximumEntries_
Maximum number in fixEntry_.
Definition: CglTreeInfo.hpp:192
CglTreeProbingInfo::backward_
int * backward_
Backward look up.
Definition: CglTreeInfo.hpp:184
CglTreeInfo::formulation_rows
int formulation_rows
The number of rows in the original formulation.
Definition: CglTreeInfo.hpp:24
CglTreeProbingInfo::numberVariables_
int numberVariables_
Number of variables.
Definition: CglTreeInfo.hpp:188
CglTreeInfo::pass
int pass
How many times the cut generator was already invoked in this search tree node.
Definition: CglTreeInfo.hpp:21
CglTreeProbingInfo::~CglTreeProbingInfo
virtual ~CglTreeProbingInfo()
Destructor.
CglTreeProbingInfo::integerVariable
int * integerVariable() const
List of 0-1 integer variables.
Definition: CglTreeInfo.hpp:150
CglTreeProbingInfo::initializeFixing
virtual int initializeFixing(const OsiSolverInterface *model)
Initalizes fixing arrays etc - returns >0 if we want to save info 0 if we don't and -1 if is to be us...
CglTreeProbingInfo::numberEntries_
int numberEntries_
Number entries in fixingEntry_ (and fixEntry_) or -2 if correct style.
Definition: CglTreeInfo.hpp:194
CglTreeProbingInfo::operator=
CglTreeProbingInfo & operator=(const CglTreeProbingInfo &rhs)
Assignment operator.
CglTreeInfo::inTree
bool inTree
Set true if in tree (to avoid ambiguity at first branch)
Definition: CglTreeInfo.hpp:40
CglTreeProbingInfo::packDown
int packDown()
Packs down entries.
CglTreeProbingInfo
Definition: CglTreeInfo.hpp:92
sequenceInCliqueEntry
int sequenceInCliqueEntry(const CliqueEntry &cEntry)
Definition: CglTreeInfo.hpp:196
CliqueEntry
Derived class to pick up probing info.
Definition: CglTreeInfo.hpp:86
CglTreeProbingInfo::toZero
int * toZero()
Starts of integer variable going to zero.
Definition: CglTreeInfo.hpp:138
CglTreeInfo::originalColumns
int * originalColumns
Original columns (if preprocessed)
Definition: CglTreeInfo.hpp:49
CglTreeProbingInfo::CglTreeProbingInfo
CglTreeProbingInfo()
Default constructor.
CglTreeProbingInfo::toOne
int * toOne()
Starts of integer variable going to one.
Definition: CglTreeInfo.hpp:144
CglTreeProbingInfo::fixEntries
CliqueEntry * fixEntries()
Entries for fixing variables.
Definition: CglTreeInfo.hpp:132
CglTreeInfo::level
int level
The level of the search tree node.
Definition: CglTreeInfo.hpp:18
CglTreeInfo::fixes
virtual bool fixes(int, int, int, bool)
Take action if cut generator can fix a variable (toValue -1 for down, +1 for up)
Definition: CglTreeInfo.hpp:79
CglTreeProbingInfo::fixColumns
int fixColumns(OsiSolverInterface &si) const
Fix entries in a solver using implications.
CglTreeInfo::initializeFixing
virtual int initializeFixing(const OsiSolverInterface *)
Initalizes fixing arrays etc - returns >0 if we want to save info 0 if we don't and -1 if is to be us...
Definition: CglTreeInfo.hpp:82
setOneFixesInCliqueEntry
void setOneFixesInCliqueEntry(CliqueEntry &cEntry, bool oneFixes)
Definition: CglTreeInfo.hpp:208