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

Last change on this file since 520 was 520, checked in by forrest, 12 years ago

fix bug in ampl interface and try slp

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