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

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

changes

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