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

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

qudaratic stuff

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