source: branches/devel/Cbc/src/CbcLinked.hpp @ 493

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

for quadratic integer etc

File size: 27.0 KB
Line 
1// Copyright (C) 2006, International Business Machines
2// Corporation and others.  All Rights Reserved.
3#ifndef CglLinked_H
4#define CglLinked_H
5/* THIS CONTAINS STUFF THAT SHOULD BE IN
6   OsiSolverLink
7   OsiBranchLink
8   CglTemporary
9*/
10#ifdef COIN_HAS_ASL
11#define COIN_HAS_LINK
12#endif
13#ifdef COIN_HAS_LINK
14#include "OsiClpSolverInterface.hpp"
15#include "CoinModel.hpp"
16class CbcModel;
17class CoinPackedMatrix;
18class OsiLinkedBound;
19class OsiObject;
20//#############################################################################
21
22/**
23   
24This is to allow the user to replace initialSolve and resolve
25This version changes coefficients
26*/
27
28class OsiSolverLink : public OsiClpSolverInterface {
29 
30public:
31  //---------------------------------------------------------------------------
32  /**@name Solve methods */
33  //@{
34  /// Solve initial LP relaxation
35  virtual void initialSolve();
36 
37  /// Resolve an LP relaxation after problem modification
38  virtual void resolve();
39
40  /**
41     Problem specific
42     Returns -1 if node fathomed and no solution
43              0 if did nothing
44              1 if node fathomed and solution
45     allFixed is true if all LinkedBound variables are fixed
46  */
47  virtual int fathom(bool allFixed) {return 0;};
48  //@}
49 
50 
51  /**@name Constructors and destructors */
52  //@{
53  /// Default Constructor
54  OsiSolverLink ();
55 
56  /** This creates from a coinModel object
57
58      if errors.then number of sets is -1
59     
60      This creates linked ordered sets information.  It assumes -
61
62      for product terms syntax is yy*f(zz)
63      also just f(zz) is allowed
64      and even a constant
65
66      modelObject not const as may be changed as part of process.
67  */
68  OsiSolverLink(  CoinModel & modelObject);
69  // Other way with existing object
70  void load(  CoinModel & modelObject,bool tightenBounds=false);
71  /// Clone
72  virtual OsiSolverInterface * clone(bool copyData=true) const;
73 
74  /// Copy constructor
75  OsiSolverLink (const OsiSolverLink &);
76 
77  /// Assignment operator
78  OsiSolverLink & operator=(const OsiSolverLink& rhs);
79 
80  /// Destructor
81  virtual ~OsiSolverLink ();
82 
83  //@}
84 
85 
86  /**@name Sets and Gets */
87  //@{
88  /// Add a bound modifier
89  void addBoundModifier(bool upperBoundAffected, bool useUpperBound, int whichVariable, int whichVariableAffected, 
90                        double multiplier=1.0);
91  /// Update coefficients - returns number updated if in updating mode
92  int updateCoefficients(ClpSimplex * solver, CoinPackedMatrix * matrix);
93  /// Objective value of best solution found internally
94  inline double bestObjectiveValue() const
95  { return bestObjectiveValue_;};
96  /// Set objective value of best solution found internally
97  inline void setBestObjectiveValue(double value)
98  { bestObjectiveValue_ = value;};
99  /// Best solution found internally
100  inline const double * bestSolution() const
101  { return bestSolution_;};
102  /// Set best solution found internally
103  void setBestSolution(const double * solution, int numberColumns);
104  /// Set special options
105  inline void setSpecialOptions2(int value)
106  { specialOptions2_=value;};
107  /// Say convex (should work it out)
108  inline void sayConvex()
109  { specialOptions2_ |= 4;};
110  /// Get special options
111  inline int specialOptions2() const
112  { return specialOptions2_;};
113  /** Clean copy of matrix
114      So we can add rows
115  */
116  CoinPackedMatrix * cleanMatrix() const
117  { return matrix_;};
118  /// Copy of quadratic model if one
119  ClpSimplex * quadraticModel() const
120  { return quadraticModel_;};
121  /// Default meshSize
122  inline double defaultMeshSize() const
123  { return defaultMeshSize_;};
124  inline void setDefaultMeshSize(double value)
125  { defaultMeshSize_=value;};
126  /// Default maximumbound
127  inline double defaultBound() const
128  { return defaultBound_;};
129  inline void setDefaultBound(double value)
130  { defaultBound_=value;};
131  /// Set integer priority
132  inline void setIntegerPriority(int value)
133  { integerPriority_=value;};
134  /// Get integer priority
135  inline int integerPriority() const
136  { return integerPriority_;};
137  /// Set biLinear priority
138  inline void setBiLinearPriority(int value)
139  { biLinearPriority_=value;};
140  /// Get biLinear priority
141  inline int biLinearPriority() const
142  { return biLinearPriority_;};
143  /// Set Cbc Model
144  inline void setCbcModel(CbcModel * model)
145  { cbcModel_=model;};
146  //@}
147 
148  //---------------------------------------------------------------------------
149 
150protected:
151 
152 
153  /**@name functions */
154  //@{
155  /// Do real work of initialize
156  void initialize(ClpSimplex * & solver, OsiObject ** & object) const;
157  /// Do real work of delete
158  void gutsOfDestructor(bool justNullify=false);
159  /// Do real work of copy
160  void gutsOfCopy(const OsiSolverLink & rhs) ;
161  //@}
162 
163  /**@name Private member data */
164  //@{
165  /** Clean copy of matrix
166      Marked coefficients will be multiplied by L or U
167  */
168  CoinPackedMatrix * matrix_;
169  /// Copy of quadratic model if one
170  ClpSimplex * quadraticModel_;
171  /// Pointer back to CbcModel
172  CbcModel * cbcModel_;
173  /// Model in CoinModel format
174  CoinModel coinModel_;
175  /// Number of variables in tightening phase
176  int numberVariables_;
177  /// Information
178  OsiLinkedBound * info_;
179  /**
180     0 bit (1) - don't do mini B&B
181     1 bit (2) - quadratic only in objective
182     2 bit (4) - convex
183  */
184  int specialOptions2_;
185  /// Objective transfer row if one
186  int objectiveRow_;
187  /// Objective transfer variable if one
188  int objectiveVariable_;
189  /// Objective value of best solution found internally
190  double bestObjectiveValue_;
191  /// Default mesh
192  double defaultMeshSize_;
193  /// Default maximum bound
194  double defaultBound_;
195  /// Best solution found internally
196  double * bestSolution_;
197  /// Priority for integers
198  int integerPriority_;
199  /// Priority for bilinear
200  int biLinearPriority_;
201  //@}
202};
203/**
204   List of bounds which depend on other bounds
205*/
206
207class OsiLinkedBound {
208 
209public:
210  //---------------------------------------------------------------------------
211  /**@name Action methods */
212  //@{
213  /// Update other bounds
214  void updateBounds(ClpSimplex * solver);
215  //@}
216 
217 
218  /**@name Constructors and destructors */
219  //@{
220  /// Default Constructor
221  OsiLinkedBound ();
222  /// Useful Constructor
223  OsiLinkedBound(OsiSolverInterface * model, int variable,
224                 int numberAffected, const int * positionL, 
225                 const int * positionU, const double * multiplier);
226 
227  /// Copy constructor
228  OsiLinkedBound (const OsiLinkedBound &);
229 
230  /// Assignment operator
231  OsiLinkedBound & operator=(const OsiLinkedBound& rhs);
232 
233  /// Destructor
234  ~OsiLinkedBound ();
235 
236  //@}
237 
238  /**@name Sets and Gets */
239  //@{
240  /// Get variable
241  inline int variable() const
242  { return variable_;};
243  /// Add a bound modifier
244  void addBoundModifier(bool upperBoundAffected, bool useUpperBound, int whichVariable, 
245                        double multiplier=1.0);
246  //@}
247 
248private:
249  typedef struct {
250    /*
251      0 - LB of variable affected
252      1 - UB of variable affected
253      2 - element in position (affected) affected
254    */
255    unsigned int affect:2;
256    unsigned int ubUsed:1; // nonzero if UB of this variable is used
257    /*
258       0 - use x*multiplier
259       1 - use multiplier/x
260       2 - if UB use min of current upper and x*multiplier, if LB use max of current lower and x*multiplier
261    */
262    unsigned int type:4; // type of computation
263    unsigned int affected:25; // variable or element affected
264    float multiplier; // to use in computation
265  } boundElementAction;
266 
267  /**@name Private member data */
268  //@{
269  /// Pointer back to model
270  OsiSolverInterface * model_;
271  /// Variable
272  int variable_;
273  /// Number of variables/elements affected
274  int numberAffected_;
275  /// Maximum number of variables/elements affected
276  int maximumAffected_;
277  /// Actions
278  boundElementAction * affected_;
279  //@}
280};
281#include "CbcHeuristic.hpp"
282/** heuristic - just picks up any good solution
283 */
284
285class CbcHeuristicDynamic3 : public CbcHeuristic {
286public:
287 
288  // Default Constructor
289  CbcHeuristicDynamic3 ();
290 
291  /* Constructor with model
292   */
293  CbcHeuristicDynamic3 (CbcModel & model);
294 
295  // Copy constructor
296  CbcHeuristicDynamic3 ( const CbcHeuristicDynamic3 &);
297 
298  // Destructor
299  ~CbcHeuristicDynamic3 ();
300 
301  /// Clone
302  virtual CbcHeuristic * clone() const;
303 
304  /// update model
305  virtual void setModel(CbcModel * model);
306 
307  /** returns 0 if no solution, 1 if valid solution.
308      Sets solution values if good, sets objective value (only if good)
309      We leave all variables which are at one at this node of the
310      tree to that value and will
311      initially set all others to zero.  We then sort all variables in order of their cost
312      divided by the number of entries in rows which are not yet covered.  We randomize that
313      value a bit so that ties will be broken in different ways on different runs of the heuristic.
314      We then choose the best one and set it to one and repeat the exercise. 
315     
316  */
317  virtual int solution(double & objectiveValue,
318                       double * newSolution);
319  /// Resets stuff if model changes
320  virtual void resetModel(CbcModel * model);
321  /// Returns true if can deal with "odd" problems e.g. sos type 2
322  virtual bool canDealWithOdd() const
323  { return true;};
324 
325protected:
326private:
327  /// Illegal Assignment operator
328  CbcHeuristicDynamic3 & operator=(const CbcHeuristicDynamic3& rhs);
329};
330
331#include "OsiBranchingObject.hpp"
332
333/** Define Special Linked Ordered Sets.
334
335*/
336class CoinWarmStartBasis;
337
338class OsiOldLink : public OsiSOS {
339
340public:
341
342  // Default Constructor
343  OsiOldLink ();
344
345  /** Useful constructor - A valid solution is if all variables are zero
346      apart from k*numberLink to (k+1)*numberLink-1 where k is 0 through
347      numberInSet-1.  The length of weights array is numberInSet.
348      For this constructor the variables in matrix are the numberInSet*numberLink
349      starting at first. If weights null then 0,1,2..
350  */
351  OsiOldLink (const OsiSolverInterface * solver, int numberMembers,
352           int numberLinks, int first,
353           const double * weights, int setNumber);
354  /** Useful constructor - A valid solution is if all variables are zero
355      apart from k*numberLink to (k+1)*numberLink-1 where k is 0 through
356      numberInSet-1.  The length of weights array is numberInSet.
357      For this constructor the variables are given by list - grouped.
358      If weights null then 0,1,2..
359  */
360  OsiOldLink (const OsiSolverInterface * solver, int numberMembers,
361           int numberLinks, int typeSOS, const int * which,
362           const double * weights, int setNumber);
363 
364  // Copy constructor
365  OsiOldLink ( const OsiOldLink &);
366   
367  /// Clone
368  virtual OsiObject * clone() const;
369
370  // Assignment operator
371  OsiOldLink & operator=( const OsiOldLink& rhs);
372
373  // Destructor
374  virtual ~OsiOldLink ();
375 
376  /// Infeasibility - large is 0.5
377  virtual double infeasibility(const OsiBranchingInformation * info,int & whichWay) const;
378
379  /** Set bounds to fix the variable at the current (integer) value.
380
381    Given an integer value, set the lower and upper bounds to fix the
382    variable. Returns amount it had to move variable.
383  */
384  virtual double feasibleRegion(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
385
386  /** Creates a branching object
387
388    The preferred direction is set by \p way, 0 for down, 1 for up.
389  */
390  virtual OsiBranchingObject * createBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) const;
391
392  /// Redoes data when sequence numbers change
393  virtual void resetSequenceEtc(int numberColumns, const int * originalColumns);
394
395  /// Number of links for each member
396  inline int numberLinks() const
397  {return numberLinks_;};
398
399  /** \brief Return true if object can take part in normal heuristics
400  */
401  virtual bool canDoHeuristics() const 
402  {return false;};
403  /** \brief Return true if branch should only bound variables
404  */
405  virtual bool boundBranch() const 
406  {return false;};
407
408private:
409  /// data
410
411  /// Number of links
412  int numberLinks_;
413};
414/** Branching object for Linked ordered sets
415
416 */
417class OsiOldLinkBranchingObject : public OsiSOSBranchingObject {
418
419public:
420
421  // Default Constructor
422  OsiOldLinkBranchingObject ();
423
424  // Useful constructor
425  OsiOldLinkBranchingObject (OsiSolverInterface * solver,  const OsiOldLink * originalObject,
426                          int way,
427                          double separator);
428 
429  // Copy constructor
430  OsiOldLinkBranchingObject ( const OsiOldLinkBranchingObject &);
431   
432  // Assignment operator
433  OsiOldLinkBranchingObject & operator=( const OsiOldLinkBranchingObject& rhs);
434
435  /// Clone
436  virtual OsiBranchingObject * clone() const;
437
438  // Destructor
439  virtual ~OsiOldLinkBranchingObject ();
440 
441  /// Does next branch and updates state
442  virtual double branch(OsiSolverInterface * solver);
443
444  /** \brief Print something about branch - only if log level high
445  */
446  virtual void print(const OsiSolverInterface * solver=NULL);
447private:
448  /// data
449};
450/** Define data for one link
451   
452*/
453
454
455class OsiOneLink {
456
457public:
458
459  // Default Constructor
460  OsiOneLink ();
461
462  /** Useful constructor -
463     
464  */
465  OsiOneLink (const OsiSolverInterface * solver, int xRow, int xColumn, int xyRow,
466              const char * functionString);
467 
468  // Copy constructor
469  OsiOneLink ( const OsiOneLink &);
470   
471  // Assignment operator
472  OsiOneLink & operator=( const OsiOneLink& rhs);
473
474  // Destructor
475  virtual ~OsiOneLink ();
476 
477  /// data
478
479  /// Row which defines x (if -1 then no x)
480  int xRow_;
481  /// Column which defines x
482  int xColumn_;
483  /// Output row
484  int xyRow;
485  /// Function
486  std::string function_;
487};
488/** Define Special Linked Ordered Sets. New style
489
490    members and weights may be stored in SOS object
491
492    This is for y and x*f(y) and z*g(y) etc
493
494*/
495
496
497class OsiLink : public OsiSOS {
498
499public:
500
501  // Default Constructor
502  OsiLink ();
503
504  /** Useful constructor -
505     
506  */
507  OsiLink (const OsiSolverInterface * solver, int yRow,
508           int yColumn, double meshSize);
509 
510  // Copy constructor
511  OsiLink ( const OsiLink &);
512   
513  /// Clone
514  virtual OsiObject * clone() const;
515
516  // Assignment operator
517  OsiLink & operator=( const OsiLink& rhs);
518
519  // Destructor
520  virtual ~OsiLink ();
521 
522  /// Infeasibility - large is 0.5
523  virtual double infeasibility(const OsiBranchingInformation * info,int & whichWay) const;
524
525  /** Set bounds to fix the variable at the current (integer) value.
526
527    Given an integer value, set the lower and upper bounds to fix the
528    variable. Returns amount it had to move variable.
529  */
530  virtual double feasibleRegion(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
531
532  /** Creates a branching object
533
534    The preferred direction is set by \p way, 0 for down, 1 for up.
535  */
536  virtual OsiBranchingObject * createBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) const;
537
538  /// Redoes data when sequence numbers change
539  virtual void resetSequenceEtc(int numberColumns, const int * originalColumns);
540
541  /// Number of links for each member
542  inline int numberLinks() const
543  {return numberLinks_;};
544
545  /** \brief Return true if object can take part in normal heuristics
546  */
547  virtual bool canDoHeuristics() const 
548  {return false;};
549  /** \brief Return true if branch should only bound variables
550  */
551  virtual bool boundBranch() const 
552  {return false;};
553
554private:
555  /// data
556  /// Current increment for y points
557  double meshSize_;
558  /// Links
559  OsiOneLink * data_;
560  /// Number of links
561  int numberLinks_;
562  /// Row which defines y
563  int yRow_;
564  /// Column which defines y
565  int yColumn_;
566};
567/** Branching object for Linked ordered sets
568
569 */
570class OsiLinkBranchingObject : public OsiTwoWayBranchingObject {
571
572public:
573
574  // Default Constructor
575  OsiLinkBranchingObject ();
576
577  // Useful constructor
578  OsiLinkBranchingObject (OsiSolverInterface * solver,  const OsiLink * originalObject,
579                          int way,
580                          double separator);
581 
582  // Copy constructor
583  OsiLinkBranchingObject ( const OsiLinkBranchingObject &);
584   
585  // Assignment operator
586  OsiLinkBranchingObject & operator=( const OsiLinkBranchingObject& rhs);
587
588  /// Clone
589  virtual OsiBranchingObject * clone() const;
590
591  // Destructor
592  virtual ~OsiLinkBranchingObject ();
593 
594  /// Does next branch and updates state
595  virtual double branch(OsiSolverInterface * solver);
596
597  /** \brief Print something about branch - only if log level high
598  */
599  virtual void print(const OsiSolverInterface * solver=NULL);
600private:
601  /// data
602};
603/** Define BiLinear objects
604
605    This models x*y where one or both are integer
606
607*/
608
609
610class OsiBiLinear : public OsiObject2 {
611
612public:
613
614  // Default Constructor
615  OsiBiLinear ();
616
617  /** Useful constructor -
618      This Adds in rows and variables to construct valid Linked Ordered Set
619      Adds extra constraints to match other x/y
620      So note not const solver
621  */
622  OsiBiLinear (OsiSolverInterface * solver, int xColumn,
623               int yColumn, int xyRow, double coefficient,
624               double xMesh, double yMesh,
625               int numberExistingObjects=0,const OsiObject ** objects=NULL );
626 
627  // Copy constructor
628  OsiBiLinear ( const OsiBiLinear &);
629   
630  /// Clone
631  virtual OsiObject * clone() const;
632
633  // Assignment operator
634  OsiBiLinear & operator=( const OsiBiLinear& rhs);
635
636  // Destructor
637  virtual ~OsiBiLinear ();
638 
639  /// Infeasibility - large is 0.5
640  virtual double infeasibility(const OsiBranchingInformation * info,int & whichWay) const;
641
642  /** Set bounds to fix the variable at the current (integer) value.
643
644    Given an integer value, set the lower and upper bounds to fix the
645    variable. Returns amount it had to move variable.
646  */
647  virtual double feasibleRegion(OsiSolverInterface * solver, const OsiBranchingInformation * info) const;
648
649  /** Creates a branching object
650
651    The preferred direction is set by \p way, 0 for down, 1 for up.
652  */
653  virtual OsiBranchingObject * createBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) const;
654
655  /// Redoes data when sequence numbers change
656  virtual void resetSequenceEtc(int numberColumns, const int * originalColumns);
657
658  // This does NOT set mutable stuff
659  virtual double checkInfeasibility(const OsiBranchingInformation * info) const;
660 
661  /** \brief Return true if object can take part in normal heuristics
662  */
663  virtual bool canDoHeuristics() const 
664  {return false;};
665  /** \brief Return true if branch should only bound variables
666  */
667  virtual bool boundBranch() const 
668  { return (branchingStrategy_&4)!=0;};
669  /// X column
670  inline int xColumn() const
671  { return xColumn_;};
672  /// Y column
673  inline int yColumn() const
674  { return yColumn_;};
675  /// X row
676  inline int xRow() const
677  { return xRow_;};
678  /// Y row
679  inline int yRow() const
680  { return yRow_;};
681  /// XY row
682  inline int xyRow() const
683  { return xyRow_;};
684  /// Coefficient
685  inline double coefficient() const
686  { return coefficient_;};
687  /// Set coefficient
688  inline void setCoefficient(double value)
689  { coefficient_ = value;};
690  /// First lambda (of 4)
691  inline int firstLambda() const
692  { return firstLambda_;};
693  /// X satisfied if less than this away from mesh
694  inline double xSatisfied() const
695  { return xSatisfied_;};
696  inline void setXSatisfied(double value)
697  { xSatisfied_=value;};
698  /// Y satisfied if less than this away from mesh
699  inline double ySatisfied() const
700  { return ySatisfied_;};
701  inline void setYSatisfied(double value)
702  { ySatisfied_=value;};
703  /// X meshSize
704  inline double xMeshSize() const
705  { return xMeshSize_;};
706  inline void setXMeshSize(double value)
707  { xMeshSize_=value;};
708  /// Y meshSize
709  inline double yMeshSize() const
710  { return yMeshSize_;};
711  inline void setYMeshSize(double value)
712  { yMeshSize_=value;};
713  /// XY satisfied if two version differ by less than this
714  inline double xySatisfied() const
715  { return xySatisfied_;};
716  inline void setXYSatisfied(double value)
717  { xySatisfied_=value;};
718  /** branching strategy etc
719      bottom 2 bits
720      0 branch on either, 1 branch on x, 2 branch on y
721      next bit
722      4 set to say don't update coefficients
723      next bit
724      8 set to say don't use in feasible region
725  */
726  inline int branchingStrategy() const
727  { return branchingStrategy_;};
728  inline void setBranchingStrategy(int value)
729  { branchingStrategy_=value;};
730  /** Simple quadratic bound marker.
731      0 no
732      1 L if coefficient pos, G if negative i.e. value is ub on xy
733      2 G if coefficient pos, L if negative i.e. value is lb on xy
734      3 E
735      If bound then real coefficient is 1.0 and coefficient_ is bound
736  */
737  inline int boundType() const
738  { return boundType_;};
739  inline void setBoundType(int value)
740  { boundType_ = value;};
741  /// Does work of branching
742  void newBounds(OsiSolverInterface * solver, int way, short xOrY, double separator) const;
743  /// Updates coefficients - returns number updated
744  int updateCoefficients(const double * lower, const double * upper, double * objective,
745                          CoinPackedMatrix * matrix, CoinWarmStartBasis * basis) const;
746  /// Returns true value of single xyRow coefficient
747  double xyCoefficient(const double * solution) const;
748  /// Get LU coefficients from matrix
749  void getCoefficients(const OsiSolverInterface * solver,double xB[2], double yB[2], double xybar[4]) const;
750  /// Compute lambdas (third entry in each .B is current value) (nonzero if bad)
751  double computeLambdas(const double xB[3], const double yB[3],const double xybar[4],double lambda[4]) const;
752
753protected:
754  /// Compute lambdas if coefficients not changing
755  void computeLambdas(const OsiSolverInterface * solver,double lambda[4]) const;
756  /// data
757 
758  /// Coefficient
759  double coefficient_;
760  /// x mesh
761  double xMeshSize_;
762  /// y mesh
763  double yMeshSize_;
764  /// x satisfied if less than this away from mesh
765  double xSatisfied_;
766  /// y satisfied if less than this away from mesh
767  double ySatisfied_;
768  /// xy satisfied if less than this away from true
769  double xySatisfied_;
770  /// value of x or y to branch about
771  mutable double xyBranchValue_;
772  /// x column
773  int xColumn_;
774  /// y column
775  int yColumn_;
776  /// First lambda (of 4)
777  int firstLambda_;
778  /** branching strategy etc
779      bottom 2 bits
780      0 branch on either, 1 branch on x, 2 branch on y
781      next bit
782      4 set to say don't update coefficients
783      next bit
784      8 set to say don't use in feasible region
785  */
786  int branchingStrategy_;
787  /** Simple quadratic bound marker.
788      0 no
789      1 L if coefficient pos, G if negative i.e. value is ub on xy
790      2 G if coefficient pos, L if negative i.e. value is lb on xy
791      3 E
792      If bound then real coefficient is 1.0 and coefficient_ is bound
793  */
794  int boundType_;
795  /// x row
796  int xRow_;
797  /// y row (-1 if x*x)
798  int yRow_;
799  /// Output row
800  int xyRow_;
801  /// Convexity row
802  int convexity_;
803  /// Which chosen -1 none, 0 x, 1 y
804  mutable short chosen_;
805};
806/** Branching object for BiLinear objects
807
808 */
809class OsiBiLinearBranchingObject : public OsiTwoWayBranchingObject {
810
811public:
812
813  // Default Constructor
814  OsiBiLinearBranchingObject ();
815
816  // Useful constructor
817  OsiBiLinearBranchingObject (OsiSolverInterface * solver,  const OsiBiLinear * originalObject,
818                          int way,
819                          double separator, int chosen);
820 
821  // Copy constructor
822  OsiBiLinearBranchingObject ( const OsiBiLinearBranchingObject &);
823   
824  // Assignment operator
825  OsiBiLinearBranchingObject & operator=( const OsiBiLinearBranchingObject& rhs);
826
827  /// Clone
828  virtual OsiBranchingObject * clone() const;
829
830  // Destructor
831  virtual ~OsiBiLinearBranchingObject ();
832 
833  /// Does next branch and updates state
834  virtual double branch(OsiSolverInterface * solver);
835
836  /** \brief Print something about branch - only if log level high
837  */
838  virtual void print(const OsiSolverInterface * solver=NULL);
839  /** \brief Return true if branch should only bound variables
840  */
841  virtual bool boundBranch() const; 
842private:
843  /// data
844  /// 1 means branch on x, 2 branch on y
845  short chosen_;
846};
847/** Define Continuous BiLinear objects for an == bound
848
849    This models x*y = b where both are continuous
850
851*/
852
853
854class OsiBiLinearEquality : public OsiBiLinear {
855
856public:
857
858  // Default Constructor
859  OsiBiLinearEquality ();
860
861  /** Useful constructor -
862      This Adds in rows and variables to construct Ordered Set
863      for x*y = b
864      So note not const solver
865  */
866  OsiBiLinearEquality (OsiSolverInterface * solver, int xColumn,
867               int yColumn, int xyRow, double rhs,
868                       double xMesh);
869 
870  // Copy constructor
871  OsiBiLinearEquality ( const OsiBiLinearEquality &);
872   
873  /// Clone
874  virtual OsiObject * clone() const;
875
876  // Assignment operator
877  OsiBiLinearEquality & operator=( const OsiBiLinearEquality& rhs);
878
879  // Destructor
880  virtual ~OsiBiLinearEquality ();
881 
882  /// Possible improvement
883  virtual double improvement(const OsiSolverInterface * solver) const;
884  /** change grid
885      if type 0 then use solution and make finer
886      if 1 then back to original
887      returns mesh size
888  */
889  double newGrid(OsiSolverInterface * solver, int type) const;
890  /// Number of points
891  inline int numberPoints() const
892  { return numberPoints_;};
893  inline void setNumberPoints(int value)
894  { numberPoints_ = value;};
895
896private:
897  /// Number of points
898  int numberPoints_;
899};
900/// Define a single integer class - but one where you kep branching until fixed even if satsified
901
902
903class OsiSimpleFixedInteger : public OsiSimpleInteger {
904
905public:
906
907  /// Default Constructor
908  OsiSimpleFixedInteger ();
909
910  /// Useful constructor - passed solver index
911  OsiSimpleFixedInteger (const OsiSolverInterface * solver, int iColumn);
912 
913  /// Useful constructor - passed solver index and original bounds
914  OsiSimpleFixedInteger (int iColumn, double lower, double upper);
915 
916  /// Useful constructor - passed simple integer
917  OsiSimpleFixedInteger (const OsiSimpleInteger &);
918 
919  /// Copy constructor
920  OsiSimpleFixedInteger ( const OsiSimpleFixedInteger &);
921   
922  /// Clone
923  virtual OsiObject * clone() const;
924
925  /// Assignment operator
926  OsiSimpleFixedInteger & operator=( const OsiSimpleFixedInteger& rhs);
927
928  /// Destructor
929  virtual ~OsiSimpleFixedInteger ();
930 
931  /// Infeasibility - large is 0.5
932  virtual double infeasibility(const OsiBranchingInformation * info, int & whichWay) const;
933  /** Creates a branching object
934
935    The preferred direction is set by \p way, 0 for down, 1 for up.
936  */
937  virtual OsiBranchingObject * createBranch(OsiSolverInterface * solver, const OsiBranchingInformation * info, int way) const;
938protected:
939  /// data
940 
941};
942
943#include <string>
944
945#include "CglStored.hpp"
946
947class CoinWarmStartBasis;
948/** Stored Temporary Cut Generator Class - destroyed after first use */
949class CglTemporary : public CglStored {
950 
951public:
952   
953 
954  /**@name Generate Cuts */
955  //@{
956  /** Generate Mixed Integer Stored cuts for the model of the
957      solver interface, si.
958
959      Insert the generated cuts into OsiCut, cs.
960
961      This generator just looks at previously stored cuts
962      and inserts any that are violated by enough
963  */
964  virtual void generateCuts( const OsiSolverInterface & si, OsiCuts & cs,
965                             const CglTreeInfo info = CglTreeInfo()) const;
966  //@}
967
968  /**@name Constructors and destructors */
969  //@{
970  /// Default constructor
971  CglTemporary ();
972 
973  /// Copy constructor
974  CglTemporary (const CglTemporary & rhs);
975
976  /// Clone
977  virtual CglCutGenerator * clone() const;
978
979  /// Assignment operator
980  CglTemporary &
981    operator=(const CglTemporary& rhs);
982 
983  /// Destructor
984  virtual
985    ~CglTemporary ();
986  //@}
987     
988private:
989 
990 // Private member methods
991
992  // Private member data
993};
994#endif
995#endif
Note: See TracBrowser for help on using the repository browser.