source: stable/2.4/Cbc/src/CbcBranchActual.hpp @ 1271

Last change on this file since 1271 was 1271, checked in by forrest, 10 years ago

Creating new stable branch 2.4 from trunk (rev 1270)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 53.2 KB
Line 
1/* $Id: CbcBranchActual.hpp 1271 2009-11-05 15:57:25Z forrest $ */
2// Copyright (C) 2002, International Business Machines
3// Corporation and others.  All Rights Reserved.
4#ifndef CbcBranchActual_H
5#define CbcBranchActual_H
6
7#include "CbcBranchBase.hpp"
8#include "CoinPackedMatrix.hpp"
9class CbcIntegerBranchingObject;
10/// Define a clique class
11
12
13class CbcClique : public CbcObject {
14
15public:
16
17  // Default Constructor
18  CbcClique ();
19
20  /** Useful constructor (which are integer indices)
21      slack can denote a slack in set.
22      If type == NULL then as if 1
23  */
24  CbcClique (CbcModel * model, int cliqueType, int numberMembers,
25             const int * which, const char * type,
26             int identifier,int slack=-1);
27 
28  // Copy constructor
29  CbcClique ( const CbcClique &);
30   
31  /// Clone
32  virtual CbcObject * clone() const;
33
34  // Assignment operator
35  CbcClique & operator=( const CbcClique& rhs);
36
37  // Destructor
38  virtual ~CbcClique ();
39 
40  /// Infeasibility - large is 0.5
41  virtual double infeasibility(const OsiBranchingInformation * info,
42                               int &preferredWay) const;
43
44  using CbcObject::feasibleRegion ;
45  /// This looks at solution and sets bounds to contain solution
46  virtual void feasibleRegion();
47
48  /// Creates a branching object
49  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
50  /// Number of members
51  inline int numberMembers() const
52  {return numberMembers_;}
53
54  /// Number of Non SOS members i.e. fixing to zero is strong
55  inline int numberNonSOSMembers() const
56  {return numberNonSOSMembers_;}
57
58  /// Members (indices in range 0 ... numberIntegers_-1)
59  inline const int * members() const
60  {return members_;}
61
62  /** Type of each member i.e. which way is strong 0=non SOS, 1 =SOS,
63      index is 0 ... numberMembers_-1 */
64  inline char type(int index) const
65  {if (type_) return type_[index]; else return 1;}
66
67  /// Clique type - 0 <=, 1 ==
68  inline int cliqueType() const
69  {return cliqueType_;}
70  /// Redoes data when sequence numbers change
71  virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns);
72
73protected:
74  /// data
75  /// Number of members
76  int numberMembers_;
77
78  /// Number of Non SOS members i.e. fixing to zero is strong
79  int numberNonSOSMembers_;
80
81  /// Members (indices in range 0 ... numberIntegers_-1)
82  int * members_;
83
84  /// Type of each member 0=SOS, 1 =clique
85  char * type_;
86
87  /// Clique type - 0 <=, 1 ==
88   int cliqueType_;
89
90  /// Which one is slack (if any) sequence within this set
91  int slack_;
92};
93
94/** Define Special Ordered Sets of type 1 and 2.  These do not have to be
95    integer - so do not appear in lists of integers.
96   
97    which_ points directly to columns of matrix
98*/
99
100
101class CbcSOS : public CbcObject {
102
103public:
104
105  // Default Constructor
106  CbcSOS ();
107
108  /** Useful constructor - which are indices
109      and  weights are also given.  If null then 0,1,2..
110      type is SOS type
111  */
112  CbcSOS (CbcModel * model, int numberMembers,
113           const int * which, const double * weights, int identifier,
114          int type=1);
115 
116  // Copy constructor
117  CbcSOS ( const CbcSOS &);
118   
119  /// Clone
120  virtual CbcObject * clone() const;
121
122  // Assignment operator
123  CbcSOS & operator=( const CbcSOS& rhs);
124
125  // Destructor
126  virtual ~CbcSOS ();
127 
128  /// Infeasibility - large is 0.5
129  virtual double infeasibility(const OsiBranchingInformation * info,
130                               int &preferredWay) const;
131
132  using CbcObject::feasibleRegion ;
133  /// This looks at solution and sets bounds to contain solution
134  virtual void feasibleRegion();
135
136  /// Creates a branching object
137  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
138
139
140
141  /** Pass in information on branch just done and create CbcObjectUpdateData instance.
142      If object does not need data then backward pointer will be NULL.
143      Assumes can get information from solver */
144  virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface * solver, 
145                                                        const CbcNode * node,
146                                                        const CbcBranchingObject * branchingObject);
147  /// Update object by CbcObjectUpdateData
148  virtual void updateInformation(const CbcObjectUpdateData & data) ;
149  using CbcObject::solverBranch ;
150  /** Create an OsiSolverBranch object
151
152      This returns NULL if branch not represented by bound changes
153  */
154  virtual OsiSolverBranch * solverBranch() const;
155  /// Redoes data when sequence numbers change
156  virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns);
157 
158  /// Construct an OsiSOS object
159  OsiSOS * osiObject(const OsiSolverInterface * solver) const;
160  /// Number of members
161  inline int numberMembers() const
162  {return numberMembers_;}
163
164  /// Members (indices in range 0 ... numberColumns-1)
165  inline const int * members() const
166  {return members_;}
167
168  /// SOS type
169  inline int sosType() const
170  {return sosType_;}
171  /// Down number times
172  inline int numberTimesDown() const
173  { return numberTimesDown_;}
174  /// Up number times
175  inline int numberTimesUp() const
176  { return numberTimesUp_;}
177
178  /** Array of weights */
179  inline const double * weights() const
180  { return weights_;}
181
182  /// Set number of members
183  inline void setNumberMembers(int n)
184  {numberMembers_ = n;}
185
186  /// Members (indices in range 0 ... numberColumns-1)
187  inline int * mutableMembers() const
188  {return members_;}
189
190  /** Array of weights */
191  inline double * mutableWeights() const
192  { return weights_;}
193
194  /** \brief Return true if object can take part in normal heuristics
195  */
196  virtual bool canDoHeuristics() const 
197  {return (sosType_==1&&integerValued_);}
198  /// Set whether set is integer valued or not
199  inline void setIntegerValued(bool yesNo)
200  { integerValued_=yesNo;}
201private:
202  /// data
203
204  /// Members (indices in range 0 ... numberColumns-1)
205  int * members_;
206  /// Weights
207  double * weights_;
208  /// Current pseudo-shadow price estimate down
209  mutable double shadowEstimateDown_;
210  /// Current pseudo-shadow price estimate up
211  mutable double shadowEstimateUp_;
212  /// Down pseudo ratio
213  double downDynamicPseudoRatio_;
214  /// Up pseudo ratio
215  double upDynamicPseudoRatio_;
216  /// Number of times we have gone down
217  int numberTimesDown_;
218  /// Number of times we have gone up
219  int numberTimesUp_;
220  /// Number of members
221  int numberMembers_;
222  /// SOS type
223  int sosType_;
224  /// Whether integer valued
225  bool integerValued_;
226};
227
228/// Define a single integer class
229
230
231class CbcSimpleInteger : public CbcObject {
232
233public:
234
235  // Default Constructor
236  CbcSimpleInteger ();
237
238  // Useful constructor - passed model and index
239  CbcSimpleInteger (CbcModel * model,  int iColumn, double breakEven=0.5);
240 
241  // Useful constructor - passed model and Osi object
242  CbcSimpleInteger (CbcModel * model,  const OsiSimpleInteger * object);
243 
244  // Copy constructor
245  CbcSimpleInteger ( const CbcSimpleInteger &);
246   
247  /// Clone
248  virtual CbcObject * clone() const;
249
250  // Assignment operator
251  CbcSimpleInteger & operator=( const CbcSimpleInteger& rhs);
252
253  // Destructor
254  virtual ~CbcSimpleInteger ();
255  /// Construct an OsiSimpleInteger object
256  OsiSimpleInteger * osiObject() const;
257  /// Infeasibility - large is 0.5
258  virtual double infeasibility(const OsiBranchingInformation * info,
259                               int &preferredWay) const;
260
261  using CbcObject::feasibleRegion ;
262  /** Set bounds to fix the variable at the current (integer) value.
263
264    Given an integer value, set the lower and upper bounds to fix the
265    variable. Returns amount it had to move variable.
266  */
267  virtual double feasibleRegion(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
268
269  /** Create a branching object and indicate which way to branch first.
270     
271      The branching object has to know how to create branches (fix
272      variables, etc.)
273  */
274  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
275  /// Fills in a created branching object
276  void fillCreateBranch(CbcIntegerBranchingObject * branching, const OsiBranchingInformation * info, int way) ;
277
278  using CbcObject::solverBranch ;
279  /** Create an OsiSolverBranch object
280
281      This returns NULL if branch not represented by bound changes
282  */
283  virtual OsiSolverBranch * solverBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
284
285  /** Set bounds to fix the variable at the current (integer) value.
286
287    Given an integer value, set the lower and upper bounds to fix the
288    variable. The algorithm takes a bit of care in order to compensate for
289    minor numerical inaccuracy.
290  */
291  virtual void feasibleRegion();
292
293  /** Column number if single column object -1 otherwise,
294      so returns >= 0
295      Used by heuristics
296  */
297  virtual int columnNumber() const;
298  /// Set column number
299  inline void setColumnNumber(int value)
300  { columnNumber_ = value;}
301
302  /** Reset variable bounds to their original values.
303 
304    Bounds may be tightened, so it may be good to be able to set this info in object.
305   */
306  virtual void resetBounds(const OsiSolverInterface * solver) ;
307  /**  Change column numbers after preprocessing
308   */
309  virtual void resetSequenceEtc(int numberColumns, const int * originalColumns) ;
310  /// Original bounds
311  inline double originalLowerBound() const
312  { return originalLower_;}
313  inline void setOriginalLowerBound(double value)
314  { originalLower_=value;}
315  inline double originalUpperBound() const
316  { return originalUpper_;}
317  inline void setOriginalUpperBound(double value)
318  { originalUpper_=value;}
319  /// Breakeven e.g 0.7 -> >= 0.7 go up first
320  inline double breakEven() const
321  { return breakEven_;}
322  /// Set breakeven e.g 0.7 -> >= 0.7 go up first
323  inline void setBreakEven(double value)
324  { breakEven_=value;}
325
326
327protected:
328  /// data
329
330  /// Original lower bound
331  double originalLower_;
332  /// Original upper bound
333  double originalUpper_;
334  /// Breakeven i.e. >= this preferred is up
335  double breakEven_;
336  /// Column number in model
337  int columnNumber_;
338  /// If -1 down always chosen first, +1 up always, 0 normal
339  int preferredWay_;
340};
341/** Define an n-way class for variables.
342    Only valid value is one at UB others at LB
343    Normally 0-1
344*/
345
346
347class CbcNWay : public CbcObject {
348
349public:
350
351  // Default Constructor
352  CbcNWay ();
353
354  /** Useful constructor (which are matrix indices)
355  */
356  CbcNWay (CbcModel * model, int numberMembers,
357             const int * which, int identifier);
358 
359  // Copy constructor
360  CbcNWay ( const CbcNWay &);
361   
362  /// Clone
363  virtual CbcObject * clone() const;
364
365  /// Assignment operator
366  CbcNWay & operator=( const CbcNWay& rhs);
367
368  /// Destructor
369  virtual ~CbcNWay ();
370
371  /// Set up a consequence for a single member
372  void setConsequence(int iColumn, const CbcConsequence & consequence);
373 
374  /// Applies a consequence for a single member
375  void applyConsequence(int iSequence, int state) const;
376 
377  /// Infeasibility - large is 0.5 (and 0.5 will give this)
378  virtual double infeasibility(const OsiBranchingInformation * info,
379                               int &preferredWay) const;
380
381  using CbcObject::feasibleRegion ;
382  /// This looks at solution and sets bounds to contain solution
383  virtual void feasibleRegion();
384
385  /// Creates a branching object
386  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
387
388  /// Number of members
389  inline int numberMembers() const
390  {return numberMembers_;}
391
392  /// Members (indices in range 0 ... numberColumns-1)
393  inline const int * members() const
394  {return members_;}
395  /// Redoes data when sequence numbers change
396  virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns);
397
398protected:
399  /// data
400  /// Number of members
401  int numberMembers_;
402
403  /// Members (indices in range 0 ... numberColumns-1)
404  int * members_;
405  /// Consequences (normally NULL)
406  CbcConsequence ** consequence_;
407};
408
409/** Simple branching object for an integer variable
410
411  This object can specify a two-way branch on an integer variable. For each
412  arm of the branch, the upper and lower bounds on the variable can be
413  independently specified.
414 
415  Variable_ holds the index of the integer variable in the integerVariable_
416  array of the model.
417*/
418
419class CbcIntegerBranchingObject : public CbcBranchingObject {
420
421public:
422
423  /// Default constructor
424  CbcIntegerBranchingObject ();
425
426  /** Create a standard floor/ceiling branch object
427
428    Specifies a simple two-way branch. Let \p value = x*. One arm of the
429    branch will be lb <= x <= floor(x*), the other ceil(x*) <= x <= ub.
430    Specify way = -1 to set the object state to perform the down arm first,
431    way = 1 for the up arm.
432  */
433  CbcIntegerBranchingObject (CbcModel *model, int variable,
434                             int way , double value) ;
435 
436  /** Create a degenerate branch object
437
438    Specifies a `one-way branch'. Calling branch() for this object will
439    always result in lowerValue <= x <= upperValue. Used to fix a variable
440    when lowerValue = upperValue.
441  */
442
443  CbcIntegerBranchingObject (CbcModel *model, int variable, int way,
444                             double lowerValue, double upperValue) ;
445 
446  /// Copy constructor
447  CbcIntegerBranchingObject ( const CbcIntegerBranchingObject &);
448   
449  /// Assignment operator
450  CbcIntegerBranchingObject & operator= (const CbcIntegerBranchingObject& rhs);
451
452  /// Clone
453  virtual CbcBranchingObject * clone() const;
454
455  /// Destructor
456  virtual ~CbcIntegerBranchingObject ();
457
458  /// Does part of constructor
459  void fillPart ( int variable, int way , double value) ;
460  using CbcBranchingObject::branch ;
461  /** \brief Sets the bounds for the variable according to the current arm
462             of the branch and advances the object state to the next arm.
463             Returns change in guessed objective on next branch
464  */
465  virtual double branch();
466  /** Update bounds in solver as in 'branch' and update given bounds.
467      branchState is -1 for 'down' +1 for 'up' */
468  virtual void fix(OsiSolverInterface * solver,
469                   double * lower, double * upper,
470                   int branchState) const ;
471
472#if 0
473  // No need to override. Default works fine.
474  /** Reset every information so that the branching object appears to point to
475      the previous child. This method does not need to modify anything in any
476      solver. */
477  virtual void previousBranch();
478#endif
479
480  using CbcBranchingObject::print ;
481  /** \brief Print something about branch - only if log level high
482  */
483  virtual void print();
484
485  /// Lower and upper bounds for down branch
486  inline const double * downBounds() const
487  { return down_;}
488  /// Lower and upper bounds for up branch
489  inline const double * upBounds() const
490  { return up_;}
491  /// Set lower and upper bounds for down branch
492  inline void setDownBounds(const double bounds[2])
493  { memcpy(down_,bounds,2*sizeof(double));}
494  /// Set lower and upper bounds for up branch
495  inline void setUpBounds(const double bounds[2])
496  { memcpy(up_,bounds,2*sizeof(double));}
497#ifdef FUNNY_BRANCHING
498  /** Which variable (top bit if upper bound changing,
499      next bit if on down branch */
500  inline const int * variables() const
501  { return variables_;}
502  // New bound
503  inline const double * newBounds() const
504  { return newBounds_;}
505  /// Number of bound changes
506  inline int numberExtraChangedBounds() const
507  { return numberExtraChangedBounds_;}
508  /// Just apply extra bounds to one variable - COIN_DBL_MAX ignore
509  int applyExtraBounds(int iColumn, double lower, double upper, int way) ;
510  /// Deactivate bounds for branching
511  void deactivate();
512  /// Are active bounds for branching
513  inline bool active() const
514  { return (down_[1]!=-COIN_DBL_MAX);}
515#endif
516
517  /** Return the type (an integer identifier) of \c this */
518  virtual int type() const { return 100; }
519
520  /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
521      same type and must have the same original object, but they may have
522      different feasible regions.
523      Return the appropriate CbcRangeCompare value (first argument being the
524      sub/superset if that's the case). In case of overlap (and if \c
525      replaceIfOverlap is true) replace the current branching object with one
526      whose feasible region is the overlap.
527   */
528  virtual CbcRangeCompare compareBranchingObject
529  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
530
531protected:
532  /// Lower [0] and upper [1] bounds for the down arm (way_ = -1)
533  double down_[2];
534  /// Lower [0] and upper [1] bounds for the up arm (way_ = 1)
535  double up_[2];
536#ifdef FUNNY_BRANCHING
537  /** Which variable (top bit if upper bound changing)
538      next bit if changing on down branch only */
539  int * variables_;
540  // New bound
541  double * newBounds_;
542  /// Number of Extra bound changes
543  int numberExtraChangedBounds_;
544#endif
545};
546
547
548/// Define a single integer class but with pseudo costs
549
550
551class CbcSimpleIntegerPseudoCost : public CbcSimpleInteger {
552
553public:
554
555  // Default Constructor
556  CbcSimpleIntegerPseudoCost ();
557
558  // Useful constructor - passed model index
559  CbcSimpleIntegerPseudoCost (CbcModel * model, int iColumn, double breakEven=0.5);
560 
561  // Useful constructor - passed and model index and pseudo costs
562  CbcSimpleIntegerPseudoCost (CbcModel * model, int iColumn, 
563                              double downPseudoCost, double upPseudoCost);
564  // Useful constructor - passed and model index and pseudo costs
565  CbcSimpleIntegerPseudoCost (CbcModel * model, int dummy,int iColumn, 
566                              double downPseudoCost, double upPseudoCost);
567 
568  // Copy constructor
569  CbcSimpleIntegerPseudoCost ( const CbcSimpleIntegerPseudoCost &);
570   
571  /// Clone
572  virtual CbcObject * clone() const;
573
574  // Assignment operator
575  CbcSimpleIntegerPseudoCost & operator=( const CbcSimpleIntegerPseudoCost& rhs);
576
577  // Destructor
578  virtual ~CbcSimpleIntegerPseudoCost ();
579 
580  /// Infeasibility - large is 0.5
581  virtual double infeasibility(const OsiBranchingInformation * info,
582                               int &preferredWay) const;
583
584  /// Creates a branching object
585  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
586
587  /// Down pseudo cost
588  inline double downPseudoCost() const
589  { return downPseudoCost_;}
590  /// Set down pseudo cost
591  inline void setDownPseudoCost(double value)
592  { downPseudoCost_=value;}
593
594  /// Up pseudo cost
595  inline double upPseudoCost() const
596  { return upPseudoCost_;}
597  /// Set up pseudo cost
598  inline void setUpPseudoCost(double value)
599  { upPseudoCost_=value;}
600
601  /// Up down separator
602  inline double upDownSeparator() const
603  { return upDownSeparator_;}
604  /// Set up down separator
605  inline void setUpDownSeparator(double value)
606  { upDownSeparator_=value;}
607
608  /// Return "up" estimate
609  virtual double upEstimate() const;
610  /// Return "down" estimate (default 1.0e-5)
611  virtual double downEstimate() const;
612 
613  /// method - see below for details
614  inline int method() const
615  { return method_;}
616  /// Set method
617  inline void setMethod(int value)
618  { method_=value;}
619
620protected:
621  /// data
622
623  /// Down pseudo cost
624  double downPseudoCost_;
625  /// Up pseudo cost
626  double upPseudoCost_;
627  /** Up/down separator
628      If >0.0 then do first branch up if value-floor(value)
629      >= this value
630  */
631  double upDownSeparator_;
632  /** Method -
633      0 - normal - return min (up,down)
634      1 - if before any solution return CoinMax(up,down)
635      2 - if before branched solution return CoinMax(up,down)
636      3 - always return CoinMax(up,down)
637  */
638  int method_;
639};
640
641
642/** Simple branching object for an integer variable with pseudo costs
643
644  This object can specify a two-way branch on an integer variable. For each
645  arm of the branch, the upper and lower bounds on the variable can be
646  independently specified.
647 
648  Variable_ holds the index of the integer variable in the integerVariable_
649  array of the model.
650*/
651
652class CbcIntegerPseudoCostBranchingObject : public CbcIntegerBranchingObject {
653
654public:
655
656  /// Default constructor
657  CbcIntegerPseudoCostBranchingObject ();
658
659  /** Create a standard floor/ceiling branch object
660
661    Specifies a simple two-way branch. Let \p value = x*. One arm of the
662    branch will be is lb <= x <= floor(x*), the other ceil(x*) <= x <= ub.
663    Specify way = -1 to set the object state to perform the down arm first,
664    way = 1 for the up arm.
665  */
666  CbcIntegerPseudoCostBranchingObject (CbcModel *model, int variable,
667                             int way , double value) ;
668 
669  /** Create a degenerate branch object
670
671    Specifies a `one-way branch'. Calling branch() for this object will
672    always result in lowerValue <= x <= upperValue. Used to fix a variable
673    when lowerValue = upperValue.
674  */
675
676  CbcIntegerPseudoCostBranchingObject (CbcModel *model, int variable, int way,
677                             double lowerValue, double upperValue) ;
678 
679  /// Copy constructor
680  CbcIntegerPseudoCostBranchingObject ( const CbcIntegerPseudoCostBranchingObject &);
681   
682  /// Assignment operator
683  CbcIntegerPseudoCostBranchingObject & operator= (const CbcIntegerPseudoCostBranchingObject& rhs);
684
685  /// Clone
686  virtual CbcBranchingObject * clone() const;
687
688  /// Destructor
689  virtual ~CbcIntegerPseudoCostBranchingObject ();
690 
691  using CbcBranchingObject::branch ;
692  /** \brief Sets the bounds for the variable according to the current arm
693             of the branch and advances the object state to the next arm.
694             This version also changes guessed objective value
695  */
696  virtual double branch();
697
698  /// Change in guessed
699  inline double changeInGuessed() const
700  { return changeInGuessed_;}
701  /// Set change in guessed
702  inline void setChangeInGuessed(double value)
703  { changeInGuessed_=value;}
704
705  /** Return the type (an integer identifier) of \c this */
706  virtual int type() const { return 101; }
707
708  /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
709      same type and must have the same original object, but they may have
710      different feasible regions.
711      Return the appropriate CbcRangeCompare value (first argument being the
712      sub/superset if that's the case). In case of overlap (and if \c
713      replaceIfOverlap is true) replace the current branching object with one
714      whose feasible region is the overlap.
715   */
716  virtual CbcRangeCompare compareBranchingObject
717  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
718
719protected:
720  /// Change in guessed objective value for next branch
721  double changeInGuessed_;
722};
723
724
725/** Branching object for unordered cliques
726
727    Intended for cliques which are long enough to make it worthwhile
728    but <= 64 members.  There will also be ones for long cliques.
729
730    Variable_ is the clique id number (redundant, as the object also holds a
731    pointer to the clique.
732 */
733class CbcCliqueBranchingObject : public CbcBranchingObject {
734
735public:
736
737  // Default Constructor
738  CbcCliqueBranchingObject ();
739
740  // Useful constructor
741  CbcCliqueBranchingObject (CbcModel * model,  const CbcClique * clique,
742                            int way,
743                            int numberOnDownSide, const int * down,
744                            int numberOnUpSide, const int * up);
745 
746  // Copy constructor
747  CbcCliqueBranchingObject ( const CbcCliqueBranchingObject &);
748   
749  // Assignment operator
750  CbcCliqueBranchingObject & operator=( const CbcCliqueBranchingObject& rhs);
751
752  /// Clone
753  virtual CbcBranchingObject * clone() const;
754
755  // Destructor
756  virtual ~CbcCliqueBranchingObject ();
757 
758  using CbcBranchingObject::branch ;
759  /// Does next branch and updates state
760  virtual double branch();
761
762#if 0
763  // No need to override. Default works fine.
764  /** Reset every information so that the branching object appears to point to
765      the previous child. This method does not need to modify anything in any
766      solver. */
767  virtual void previousBranch();
768#endif
769
770  using CbcBranchingObject::print ;
771  /** \brief Print something about branch - only if log level high
772  */
773  virtual void print();
774
775  /** Return the type (an integer identifier) of \c this */
776  virtual int type() const { return 102; }
777
778  /** Compare the original object of \c this with the original object of \c
779      brObj. Assumes that there is an ordering of the original objects.
780      This method should be invoked only if \c this and brObj are of the same
781      type.
782      Return negative/0/positive depending on whether \c this is
783      smaller/same/larger than the argument.
784  */
785  virtual int compareOriginalObject(const CbcBranchingObject* brObj) const;
786
787  /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
788      same type and must have the same original object, but they may have
789      different feasible regions.
790      Return the appropriate CbcRangeCompare value (first argument being the
791      sub/superset if that's the case). In case of overlap (and if \c
792      replaceIfOverlap is true) replace the current branching object with one
793      whose feasible region is the overlap.
794   */
795  virtual CbcRangeCompare compareBranchingObject
796  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
797
798private:
799  /// data
800  const CbcClique * clique_;
801  /// downMask - bit set to fix to weak bounds, not set to leave unfixed
802  unsigned int downMask_[2];
803  /// upMask - bit set to fix to weak bounds, not set to leave unfixed
804  unsigned int upMask_[2];
805};
806
807
808/** Unordered Clique Branching Object class.
809    These are for cliques which are > 64 members
810    Variable is number of clique.
811 */
812class CbcLongCliqueBranchingObject : public CbcBranchingObject {
813
814public:
815
816  // Default Constructor
817  CbcLongCliqueBranchingObject ();
818
819  // Useful constructor
820  CbcLongCliqueBranchingObject (CbcModel * model,  const CbcClique * clique,
821                                 int way,
822                            int numberOnDownSide, const int * down,
823                            int numberOnUpSide, const int * up);
824 
825  // Copy constructor
826  CbcLongCliqueBranchingObject ( const CbcLongCliqueBranchingObject &);
827   
828  // Assignment operator
829  CbcLongCliqueBranchingObject & operator=( const CbcLongCliqueBranchingObject& rhs);
830
831  /// Clone
832  virtual CbcBranchingObject * clone() const;
833
834  // Destructor
835  virtual ~CbcLongCliqueBranchingObject ();
836 
837  using CbcBranchingObject::branch ;
838  /// Does next branch and updates state
839  virtual double branch();
840
841#if 0
842  // No need to override. Default works fine.
843  /** Reset every information so that the branching object appears to point to
844      the previous child. This method does not need to modify anything in any
845      solver. */
846  virtual void previousBranch();
847#endif
848
849  using CbcBranchingObject::print ;
850  /** \brief Print something about branch - only if log level high
851  */
852  virtual void print();
853
854  /** Return the type (an integer identifier) of \c this */
855  virtual int type() const { return 103; }
856
857  /** Compare the original object of \c this with the original object of \c
858      brObj. Assumes that there is an ordering of the original objects.
859      This method should be invoked only if \c this and brObj are of the same
860      type.
861      Return negative/0/positive depending on whether \c this is
862      smaller/same/larger than the argument.
863  */
864  virtual int compareOriginalObject(const CbcBranchingObject* brObj) const;
865
866  /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
867      same type and must have the same original object, but they may have
868      different feasible regions.
869      Return the appropriate CbcRangeCompare value (first argument being the
870      sub/superset if that's the case). In case of overlap (and if \c
871      replaceIfOverlap is true) replace the current branching object with one
872      whose feasible region is the overlap.
873   */
874  virtual CbcRangeCompare compareBranchingObject
875  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
876
877private:
878  /// data
879  const CbcClique * clique_;
880  /// downMask - bit set to fix to weak bounds, not set to leave unfixed
881  unsigned int * downMask_;
882  /// upMask - bit set to fix to weak bounds, not set to leave unfixed
883  unsigned int * upMask_;
884};
885
886/** Branching object for Special ordered sets
887
888    Variable_ is the set id number (redundant, as the object also holds a
889    pointer to the set.
890 */
891class CbcSOSBranchingObject : public CbcBranchingObject {
892
893public:
894
895  // Default Constructor
896  CbcSOSBranchingObject ();
897
898  // Useful constructor
899  CbcSOSBranchingObject (CbcModel * model,  const CbcSOS * clique,
900                            int way,
901                         double separator);
902 
903  // Copy constructor
904  CbcSOSBranchingObject ( const CbcSOSBranchingObject &);
905   
906  // Assignment operator
907  CbcSOSBranchingObject & operator=( const CbcSOSBranchingObject& rhs);
908
909  /// Clone
910  virtual CbcBranchingObject * clone() const;
911
912  // Destructor
913  virtual ~CbcSOSBranchingObject ();
914 
915  using CbcBranchingObject::branch ;
916  /// Does next branch and updates state
917  virtual double branch();
918  /** Update bounds in solver as in 'branch' and update given bounds.
919      branchState is -1 for 'down' +1 for 'up' */
920  virtual void fix(OsiSolverInterface * solver,
921                   double * lower, double * upper,
922                   int branchState) const ;
923
924  /** Reset every information so that the branching object appears to point to
925      the previous child. This method does not need to modify anything in any
926      solver. */
927  virtual void previousBranch() {
928    CbcBranchingObject::previousBranch();
929    computeNonzeroRange();
930  }
931
932  using CbcBranchingObject::print ;
933  /** \brief Print something about branch - only if log level high
934  */
935  virtual void print();
936
937  /** Return the type (an integer identifier) of \c this */
938  virtual int type() const { return 104; }
939
940  /** Compare the original object of \c this with the original object of \c
941      brObj. Assumes that there is an ordering of the original objects.
942      This method should be invoked only if \c this and brObj are of the same
943      type.
944      Return negative/0/positive depending on whether \c this is
945      smaller/same/larger than the argument.
946  */
947  virtual int compareOriginalObject(const CbcBranchingObject* brObj) const;
948
949  /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
950      same type and must have the same original object, but they may have
951      different feasible regions.
952      Return the appropriate CbcRangeCompare value (first argument being the
953      sub/superset if that's the case). In case of overlap (and if \c
954      replaceIfOverlap is true) replace the current branching object with one
955      whose feasible region is the overlap.
956   */
957  virtual CbcRangeCompare compareBranchingObject
958  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
959
960  /** Fill out the \c firstNonzero_ and \c lastNonzero_ data members */
961  void computeNonzeroRange();
962
963private:
964  /// data
965  const CbcSOS * set_;
966  /// separator
967  double separator_;
968  /** The following two members describe the range in the members_ of the
969      original object that whose upper bound is not fixed to 0. This is not
970      necessary for Cbc to function correctly, this is there for heuristics so
971      that separate branching decisions on the same object can be pooled into
972      one branching object. */
973  int firstNonzero_;
974  int lastNonzero_;
975};
976
977/** N way branching Object class.
978    Variable is number of set.
979 */
980class CbcNWayBranchingObject : public CbcBranchingObject {
981
982public:
983
984  // Default Constructor
985  CbcNWayBranchingObject ();
986
987  /** Useful constructor - order had matrix indices
988      way_ -1 corresponds to setting first, +1 to second, +3 etc.
989      this is so -1 and +1 have similarity to normal
990  */
991  CbcNWayBranchingObject (CbcModel * model,  const CbcNWay * nway,
992                          int numberBranches, const int * order);
993 
994  // Copy constructor
995  CbcNWayBranchingObject ( const CbcNWayBranchingObject &);
996   
997  // Assignment operator
998  CbcNWayBranchingObject & operator=( const CbcNWayBranchingObject& rhs);
999
1000  /// Clone
1001  virtual CbcBranchingObject * clone() const;
1002
1003  // Destructor
1004  virtual ~CbcNWayBranchingObject ();
1005 
1006  using CbcBranchingObject::branch ;
1007  /// Does next branch and updates state
1008  virtual double branch();
1009
1010#if 0
1011  // FIXME: what do we need to do here?
1012  /** Reset every information so that the branching object appears to point to
1013      the previous child. This method does not need to modify anything in any
1014      solver. */
1015  virtual void previousBranch();
1016#endif
1017
1018  using CbcBranchingObject::print ;
1019  /** \brief Print something about branch - only if log level high
1020  */
1021  virtual void print();
1022  /** The number of branch arms created for this branching object
1023  */
1024  virtual int numberBranches() const
1025  {return numberInSet_;}
1026  /// Is this a two way object (-1 down, +1 up)
1027  virtual bool twoWay() const
1028  { return false;}
1029
1030  /** Return the type (an integer identifier) of \c this */
1031  virtual int type() const { return 105; }
1032
1033  /** Compare the original object of \c this with the original object of \c
1034      brObj. Assumes that there is an ordering of the original objects.
1035      This method should be invoked only if \c this and brObj are of the same
1036      type.
1037      Return negative/0/positive depending on whether \c this is
1038      smaller/same/larger than the argument.
1039  */
1040  virtual int compareOriginalObject(const CbcBranchingObject* brObj) const;
1041
1042  /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
1043      same type and must have the same original object, but they may have
1044      different feasible regions.
1045      Return the appropriate CbcRangeCompare value (first argument being the
1046      sub/superset if that's the case). In case of overlap (and if \c
1047      replaceIfOverlap is true) replace the current branching object with one
1048      whose feasible region is the overlap.
1049   */
1050  virtual CbcRangeCompare compareBranchingObject
1051  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
1052
1053private:
1054  /// order of branching - points back to CbcNWay
1055  int * order_;
1056  /// Points back to object
1057  const CbcNWay * object_;
1058  /// Number in set
1059  int numberInSet_;
1060};
1061
1062/** Branching decision default class
1063
1064  This class implements a simple default algorithm
1065  (betterBranch()) for choosing a branching variable.
1066*/
1067
1068class CbcBranchDefaultDecision : public CbcBranchDecision {
1069public:
1070  // Default Constructor
1071  CbcBranchDefaultDecision ();
1072
1073  // Copy constructor
1074  CbcBranchDefaultDecision ( const CbcBranchDefaultDecision &);
1075
1076  virtual ~CbcBranchDefaultDecision();
1077
1078  /// Clone
1079  virtual CbcBranchDecision * clone() const;
1080
1081  /// Initialize, <i>e.g.</i> before the start of branch selection at a node
1082  virtual void initialize(CbcModel * model);
1083
1084  /** \brief Compare two branching objects. Return nonzero if \p thisOne is
1085             better than \p bestSoFar.
1086
1087    The routine compares branches using the values supplied in \p numInfUp and
1088    \p numInfDn until a solution is found by search, after which it uses the
1089    values supplied in \p changeUp and \p changeDn. The best branching object
1090    seen so far and the associated parameter values are remembered in the
1091    \c CbcBranchDefaultDecision object. The nonzero return value is +1 if the
1092    up branch is preferred, -1 if the down branch is preferred.
1093
1094    As the names imply, the assumption is that the values supplied for
1095    \p numInfUp and \p numInfDn will be the number of infeasibilities reported
1096    by the branching object, and \p changeUp and \p changeDn will be the
1097    estimated change in objective. Other measures can be used if desired.
1098
1099    Because an \c CbcBranchDefaultDecision object remembers the current best
1100    branching candidate (#bestObject_) as well as the values used in the
1101    comparison, the parameter \p bestSoFar is redundant, hence unused.
1102 */
1103  virtual int betterBranch(CbcBranchingObject * thisOne,
1104                            CbcBranchingObject * bestSoFar,
1105                            double changeUp, int numInfUp,
1106                            double changeDn, int numInfDn);
1107  /** Sets or gets best criterion so far */
1108  virtual void setBestCriterion(double value);
1109  virtual double getBestCriterion() const;
1110
1111  /** \brief Compare N branching objects. Return index of best
1112      and sets way of branching in chosen object.
1113   
1114    This routine is used only after strong branching.
1115  */
1116
1117  virtual int
1118  bestBranch (CbcBranchingObject ** objects, int numberObjects, int numberUnsatisfied,
1119              double * changeUp, int * numberInfeasibilitiesUp,
1120              double * changeDown, int * numberInfeasibilitiesDown,
1121              double objectiveValue) ;
1122private:
1123 
1124  /// Illegal Assignment operator
1125  CbcBranchDefaultDecision & operator=(const CbcBranchDefaultDecision& rhs);
1126
1127  /// data
1128
1129  /// "best" so far
1130  double bestCriterion_;
1131
1132  /// Change up for best
1133  double bestChangeUp_;
1134
1135  /// Number of infeasibilities for up
1136  int bestNumberUp_;
1137
1138  /// Change down for best
1139  double bestChangeDown_;
1140
1141  /// Pointer to best branching object
1142  CbcBranchingObject * bestObject_;
1143
1144  /// Number of infeasibilities for down
1145  int bestNumberDown_;
1146
1147};
1148
1149/** Define a follow on class.
1150    The idea of this is that in air-crew scheduling problems crew may fly in on flight A
1151    and out on flight B or on some other flight.  A useful branch is one which on one side
1152    fixes all which go out on flight B to 0, while the other branch fixes all those that do NOT
1153    go out on flight B to 0.
1154
1155    This branching rule should be in addition to normal rules and have a high priority.
1156*/
1157
1158
1159
1160class CbcFollowOn : public CbcObject {
1161
1162public:
1163
1164  // Default Constructor
1165  CbcFollowOn ();
1166
1167  /** Useful constructor
1168  */
1169  CbcFollowOn (CbcModel * model);
1170 
1171  // Copy constructor
1172  CbcFollowOn ( const CbcFollowOn &);
1173   
1174  /// Clone
1175  virtual CbcObject * clone() const;
1176
1177  // Assignment operator
1178  CbcFollowOn & operator=( const CbcFollowOn& rhs);
1179
1180  // Destructor
1181  ~CbcFollowOn ();
1182 
1183  /// Infeasibility - large is 0.5
1184  virtual double infeasibility(const OsiBranchingInformation * info,
1185                               int &preferredWay) const;
1186
1187  using CbcObject::feasibleRegion ;
1188  /// This looks at solution and sets bounds to contain solution
1189  virtual void feasibleRegion();
1190
1191  /// Creates a branching object
1192  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
1193  /// As some computation is needed in more than one place - returns row
1194  virtual int gutsOfFollowOn(int & otherRow, int & preferredWay) const;
1195
1196protected:
1197  /// data
1198  /// Matrix
1199  CoinPackedMatrix matrix_;
1200  /// Matrix by row
1201  CoinPackedMatrix matrixByRow_; 
1202  /// Possible rhs (if 0 then not possible)
1203  int * rhs_;
1204};
1205/** General Branching Object class.
1206    Each way fixes some variables to lower bound
1207 */
1208class CbcFixingBranchingObject : public CbcBranchingObject {
1209
1210public:
1211
1212  // Default Constructor
1213  CbcFixingBranchingObject ();
1214
1215  // Useful constructor
1216  CbcFixingBranchingObject (CbcModel * model, 
1217                            int way,
1218                            int numberOnDownSide, const int * down,
1219                            int numberOnUpSide, const int * up);
1220 
1221  // Copy constructor
1222  CbcFixingBranchingObject ( const CbcFixingBranchingObject &);
1223   
1224  // Assignment operator
1225  CbcFixingBranchingObject & operator=( const CbcFixingBranchingObject& rhs);
1226
1227  /// Clone
1228  virtual CbcBranchingObject * clone() const;
1229
1230  // Destructor
1231  virtual ~CbcFixingBranchingObject ();
1232 
1233  using CbcBranchingObject::branch ;
1234  /// Does next branch and updates state
1235  virtual double branch();
1236
1237#if 0
1238  // No need to override. Default works fine.
1239  /** Reset every information so that the branching object appears to point to
1240      the previous child. This method does not need to modify anything in any
1241      solver. */
1242  virtual void previousBranch();
1243#endif
1244
1245  using CbcBranchingObject::print ;
1246  /** \brief Print something about branch - only if log level high
1247  */
1248  virtual void print();
1249
1250  /** Return the type (an integer identifier) of \c this */
1251  virtual int type() const { return 106; }
1252
1253  /** Compare the original object of \c this with the original object of \c
1254      brObj. Assumes that there is an ordering of the original objects.
1255      This method should be invoked only if \c this and brObj are of the same
1256      type.
1257      Return negative/0/positive depending on whether \c this is
1258      smaller/same/larger than the argument.
1259  */
1260  virtual int compareOriginalObject(const CbcBranchingObject* brObj) const;
1261
1262  /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
1263      same type and must have the same original object, but they may have
1264      different feasible regions.
1265      Return the appropriate CbcRangeCompare value (first argument being the
1266      sub/superset if that's the case). In case of overlap (and if \c
1267      replaceIfOverlap is true) replace the current branching object with one
1268      whose feasible region is the overlap.
1269   */
1270  virtual CbcRangeCompare compareBranchingObject
1271  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
1272
1273private:
1274  /// data
1275  /// Number on down list
1276  int numberDown_;
1277  /// Number on up list
1278  int numberUp_;
1279  /// downList - variables to fix to lb on down branch
1280  int * downList_;
1281  /// upList - variables to fix to lb on up branch
1282  int * upList_;
1283};
1284/** Class for consequent bounds.
1285    When a variable is branched on it normally interacts with other variables by
1286    means of equations.  There are cases where we want to step outside LP and do something
1287    more directly e.g. fix bounds.  This class is for that.
1288
1289    A state of -9999 means at LB, +9999 means at UB,
1290    others mean if fixed to that value.
1291
1292 */
1293
1294class CbcFixVariable : public CbcConsequence {
1295
1296public:
1297
1298  // Default Constructor
1299  CbcFixVariable ();
1300
1301  // One useful Constructor
1302  CbcFixVariable (int numberStates,const int * states, const int * numberNewLower, const int ** newLowerValue,
1303                  const int ** lowerColumn,
1304                  const int * numberNewUpper, const int ** newUpperValue,
1305                  const int ** upperColumn);
1306
1307  // Copy constructor
1308  CbcFixVariable ( const CbcFixVariable & rhs);
1309   
1310  // Assignment operator
1311  CbcFixVariable & operator=( const CbcFixVariable & rhs);
1312
1313  /// Clone
1314  virtual CbcConsequence * clone() const;
1315
1316  /// Destructor
1317  virtual ~CbcFixVariable ();
1318
1319  /** Apply to an LP solver.  Action depends on state
1320   */
1321  virtual void applyToSolver(OsiSolverInterface * solver, int state) const;
1322 
1323protected:
1324  /// Number of states
1325  int numberStates_;
1326  /// Values of integers for various states
1327  int * states_;
1328  /// Start of information for each state (setting new lower)
1329  int * startLower_;
1330  /// Start of information for each state (setting new upper)
1331  int * startUpper_;
1332  /// For each variable new bounds
1333  double * newBound_;
1334  /// Variable
1335  int * variable_;
1336};
1337/** Dummy branching object
1338
1339  This object specifies a one-way dummy branch.
1340  This is so one can carry on branching even when it looks feasible
1341*/
1342
1343class CbcDummyBranchingObject : public CbcBranchingObject {
1344
1345public:
1346
1347  /// Default constructor
1348  CbcDummyBranchingObject (CbcModel * model=NULL);
1349
1350  /// Copy constructor
1351  CbcDummyBranchingObject ( const CbcDummyBranchingObject &);
1352   
1353  /// Assignment operator
1354  CbcDummyBranchingObject & operator= (const CbcDummyBranchingObject& rhs);
1355
1356  /// Clone
1357  virtual CbcBranchingObject * clone() const;
1358
1359  /// Destructor
1360  virtual ~CbcDummyBranchingObject ();
1361 
1362  using CbcBranchingObject::branch ;
1363  /** \brief Dummy branch
1364  */
1365  virtual double branch();
1366
1367#if 0
1368  // No need to override. Default works fine.
1369  /** Reset every information so that the branching object appears to point to
1370      the previous child. This method does not need to modify anything in any
1371      solver. */
1372  virtual void previousBranch();
1373#endif
1374
1375  using CbcBranchingObject::print ;
1376  /** \brief Print something about branch - only if log level high
1377  */
1378  virtual void print();
1379
1380  /** Return the type (an integer identifier) of \c this */
1381  virtual int type() const { return 107; }
1382
1383  /** Compare the original object of \c this with the original object of \c
1384      brObj. Assumes that there is an ordering of the original objects.
1385      This method should be invoked only if \c this and brObj are of the same
1386      type.
1387      Return negative/0/positive depending on whether \c this is
1388      smaller/same/larger than the argument.
1389  */
1390  virtual int compareOriginalObject(const CbcBranchingObject* brObj) const;
1391
1392  /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
1393      same type and must have the same original object, but they may have
1394      different feasible regions.
1395      Return the appropriate CbcRangeCompare value (first argument being the
1396      sub/superset if that's the case). In case of overlap (and if \c
1397      replaceIfOverlap is true) replace the current branching object with one
1398      whose feasible region is the overlap.
1399   */
1400  virtual CbcRangeCompare compareBranchingObject
1401  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
1402
1403};
1404
1405/** Define a catch all class.
1406    This will create a list of subproblems
1407*/
1408
1409
1410class CbcGeneral : public CbcObject {
1411
1412public:
1413
1414  // Default Constructor
1415  CbcGeneral ();
1416
1417  /** Useful constructor
1418      Just needs to point to model.
1419  */
1420  CbcGeneral (CbcModel * model);
1421 
1422  // Copy constructor
1423  CbcGeneral ( const CbcGeneral &);
1424   
1425  /// Clone
1426  virtual CbcObject * clone() const=0;
1427
1428  // Assignment operator
1429  CbcGeneral & operator=( const CbcGeneral& rhs);
1430
1431  // Destructor
1432  ~CbcGeneral ();
1433 
1434  /// Infeasibility - large is 0.5
1435  virtual double infeasibility(const OsiBranchingInformation * info,
1436                               int &preferredWay) const;
1437
1438  using CbcObject::feasibleRegion ;
1439  /// This looks at solution and sets bounds to contain solution
1440  virtual void feasibleRegion()=0;
1441
1442  /// Creates a branching object
1443  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
1444
1445  /// Redoes data when sequence numbers change
1446  virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns)=0;
1447
1448protected:
1449  /// data
1450};
1451#ifdef COIN_HAS_CLP
1452
1453/** Define a catch all class.
1454    This will create a list of subproblems using partial evaluation
1455*/
1456#include "ClpSimplex.hpp"
1457#include "ClpNode.hpp"
1458
1459class CbcGeneralDepth : public CbcGeneral {
1460
1461public:
1462
1463  // Default Constructor
1464  CbcGeneralDepth ();
1465
1466  /** Useful constructor
1467      Just needs to point to model.
1468      Initial version does evaluation to depth N
1469      This is stored in CbcModel but may be
1470      better here
1471  */
1472  CbcGeneralDepth (CbcModel * model, int maximumDepth);
1473 
1474  // Copy constructor
1475  CbcGeneralDepth ( const CbcGeneralDepth &);
1476   
1477  /// Clone
1478  virtual CbcObject * clone() const;
1479
1480  // Assignment operator
1481  CbcGeneralDepth & operator=( const CbcGeneralDepth& rhs);
1482
1483  // Destructor
1484  ~CbcGeneralDepth ();
1485 
1486  /// Infeasibility - large is 0.5
1487  virtual double infeasibility(const OsiBranchingInformation * info,
1488                               int &preferredWay) const;
1489
1490  using CbcObject::feasibleRegion ;
1491  /// This looks at solution and sets bounds to contain solution
1492  virtual void feasibleRegion();
1493
1494  /// Creates a branching object
1495  virtual CbcBranchingObject * createCbcBranch(OsiSolverInterface * solver,const OsiBranchingInformation * info, int way) ;
1496  /// Return maximum number of nodes
1497  inline int maximumNodes() const
1498  { return maximumNodes_;}
1499  /// Get maximum depth
1500  inline int maximumDepth() const
1501  {return maximumDepth_;}
1502  /// Set maximum depth
1503  inline void setMaximumDepth(int value)
1504  {maximumDepth_ = value;}
1505  /// Get which solution
1506  inline int whichSolution() const
1507  {return whichSolution_;}
1508  /// Get ClpNode info
1509  inline ClpNode * nodeInfo(int which)
1510  { return nodeInfo_->nodeInfo_[which];}
1511
1512  /// Redoes data when sequence numbers change
1513  virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns);
1514
1515protected:
1516  /// data
1517  /// Maximum depth
1518  int maximumDepth_;
1519  /// Maximum nodes
1520  int maximumNodes_;
1521  /// Which node has solution (or -1)
1522  mutable int whichSolution_;
1523  /// Number of valid nodes (including whichSolution_)
1524  mutable int numberNodes_;
1525  /// For solving nodes
1526  mutable ClpNodeStuff * nodeInfo_;
1527};
1528
1529/** Defines a general subproblem
1530    Basis will be made more compact later
1531*/
1532class CoinWarmStartDiff;
1533class CbcSubProblem {
1534
1535public:
1536
1537  /// Default constructor
1538  CbcSubProblem ();
1539
1540  /// Constructor from model
1541  CbcSubProblem (const OsiSolverInterface * solver,
1542                 const double * lowerBefore,
1543                 const double * upperBefore,
1544                 const unsigned char * status,
1545                 int depth);
1546
1547  /// Copy constructor
1548  CbcSubProblem ( const CbcSubProblem &);
1549   
1550  /// Assignment operator
1551  CbcSubProblem & operator= (const CbcSubProblem& rhs);
1552
1553  /// Destructor
1554  virtual ~CbcSubProblem ();
1555
1556  /// Apply subproblem (1=bounds, 2=basis, 3=both)
1557  void apply(OsiSolverInterface * model, int what=3) const;
1558
1559public:
1560  /// Value of objective
1561  double objectiveValue_;
1562  /// Sum of infeasibilities
1563  double sumInfeasibilities_;
1564  /** Which variable (top bit if upper bound changing)
1565      next bit if changing on down branch only */
1566  int * variables_;
1567  /// New bound
1568  double * newBounds_;
1569  /// Status
1570  mutable CoinWarmStartBasis * status_;
1571  /// Depth
1572  int depth_;
1573  /// Number of Extra bound changes
1574  int numberChangedBounds_;
1575  /// Number of infeasibilities
1576  int numberInfeasibilities_;
1577};
1578
1579/** Branching object for general objects
1580
1581 */
1582class CbcNode;
1583class CbcGeneralBranchingObject : public CbcBranchingObject {
1584
1585public:
1586
1587  // Default Constructor
1588  CbcGeneralBranchingObject ();
1589
1590  // Useful constructor
1591  CbcGeneralBranchingObject (CbcModel * model);
1592 
1593  // Copy constructor
1594  CbcGeneralBranchingObject ( const CbcGeneralBranchingObject &);
1595   
1596  // Assignment operator
1597  CbcGeneralBranchingObject & operator=( const CbcGeneralBranchingObject& rhs);
1598
1599  /// Clone
1600  virtual CbcBranchingObject * clone() const;
1601
1602  // Destructor
1603  virtual ~CbcGeneralBranchingObject ();
1604 
1605  using CbcBranchingObject::branch ;
1606  /// Does next branch and updates state
1607  virtual double branch();
1608  /** Double checks in case node can change its mind!
1609      Can change objective etc */
1610  virtual void checkIsCutoff(double cutoff);
1611
1612  using CbcBranchingObject::print ;
1613  /** \brief Print something about branch - only if log level high
1614  */
1615  virtual void print();
1616  /// Fill in current objective etc
1617  void state(double & objectiveValue,double & sumInfeasibilities,
1618             int & numberUnsatisfied,int which) const;
1619  /// Set CbcNode
1620  inline void setNode(CbcNode * node)
1621  { node_ = node;}
1622  /** Return the type (an integer identifier) of \c this */
1623  virtual int type() const { return 108; }
1624
1625  /** Compare the original object of \c this with the original object of \c
1626      brObj. Assumes that there is an ordering of the original objects.
1627      This method should be invoked only if \c this and brObj are of the same
1628      type.
1629      Return negative/0/positive depending on whether \c this is
1630      smaller/same/larger than the argument.
1631  */
1632  virtual int compareOriginalObject(const CbcBranchingObject* brObj) const;
1633
1634  /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
1635      same type and must have the same original object, but they may have
1636      different feasible regions.
1637      Return the appropriate CbcRangeCompare value (first argument being the
1638      sub/superset if that's the case). In case of overlap (and if \c
1639      replaceIfOverlap is true) replace the current branching object with one
1640      whose feasible region is the overlap.
1641   */
1642  virtual CbcRangeCompare compareBranchingObject
1643  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
1644  /// Number of subproblems
1645  inline int numberSubProblems() const
1646  { return numberSubProblems_;}
1647  /// Decrement number left and return number
1648  inline int decrementNumberLeft()
1649  { numberSubLeft_--; return numberSubLeft_;}
1650  /// Which node we want to use
1651  inline int whichNode() const
1652  { return whichNode_;}
1653  /// Set which node we want to use
1654  inline void setWhichNode(int value)
1655  { whichNode_ = value;}
1656  // Sub problem
1657  const CbcSubProblem * subProblem(int which) const
1658  { return subProblems_+which;}
1659
1660public:
1661  /// data
1662  // Sub problems
1663  CbcSubProblem * subProblems_;
1664  /// Node
1665  CbcNode * node_;
1666  /// Number of subproblems
1667  int numberSubProblems_;
1668  /// Number of subproblems left
1669  int numberSubLeft_;
1670  /// Which node we want to use (-1 for default)
1671  int whichNode_;
1672  /// Number of rows
1673  int numberRows_;
1674};
1675
1676/** Branching object for general objects - just one
1677
1678 */
1679class CbcOneGeneralBranchingObject : public CbcBranchingObject {
1680
1681public:
1682
1683  // Default Constructor
1684  CbcOneGeneralBranchingObject ();
1685
1686  // Useful constructor
1687  CbcOneGeneralBranchingObject (CbcModel * model,
1688                                 CbcGeneralBranchingObject * object,
1689                                 int whichOne);
1690 
1691  // Copy constructor
1692  CbcOneGeneralBranchingObject ( const CbcOneGeneralBranchingObject &);
1693   
1694  // Assignment operator
1695  CbcOneGeneralBranchingObject & operator=( const CbcOneGeneralBranchingObject& rhs);
1696
1697  /// Clone
1698  virtual CbcBranchingObject * clone() const;
1699
1700  // Destructor
1701  virtual ~CbcOneGeneralBranchingObject ();
1702 
1703  using CbcBranchingObject::branch ;
1704  /// Does next branch and updates state
1705  virtual double branch();
1706  /** Double checks in case node can change its mind!
1707      Can change objective etc */
1708  virtual void checkIsCutoff(double cutoff);
1709
1710  using CbcBranchingObject::print ;
1711  /** \brief Print something about branch - only if log level high
1712  */
1713  virtual void print();
1714  /** Return the type (an integer identifier) of \c this */
1715  virtual int type() const { return 110; }
1716
1717  /** Compare the original object of \c this with the original object of \c
1718      brObj. Assumes that there is an ordering of the original objects.
1719      This method should be invoked only if \c this and brObj are of the same
1720      type.
1721      Return negative/0/positive depending on whether \c this is
1722      smaller/same/larger than the argument.
1723  */
1724  virtual int compareOriginalObject(const CbcBranchingObject* brObj) const;
1725
1726  /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
1727      same type and must have the same original object, but they may have
1728      different feasible regions.
1729      Return the appropriate CbcRangeCompare value (first argument being the
1730      sub/superset if that's the case). In case of overlap (and if \c
1731      replaceIfOverlap is true) replace the current branching object with one
1732      whose feasible region is the overlap.
1733   */
1734  virtual CbcRangeCompare compareBranchingObject
1735  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
1736
1737public:
1738  /// data
1739  /// Object
1740  CbcGeneralBranchingObject * object_;
1741  /// Which one
1742  int whichOne_;
1743};
1744#endif
1745#endif
Note: See TracBrowser for help on using the repository browser.