| 1 | /* $Id: ClpConstraintQuadratic.hpp 1665 2011-01-04 17:55:54Z lou $ */ | 
|---|
| 2 | // Copyright (C) 2007, International Business Machines | 
|---|
| 3 | // Corporation and others.  All Rights Reserved. | 
|---|
| 4 | // This code is licensed under the terms of the Eclipse Public License (EPL). | 
|---|
| 5 |  | 
|---|
| 6 | #ifndef ClpConstraintQuadratic_H | 
|---|
| 7 | #define ClpConstraintQuadratic_H | 
|---|
| 8 |  | 
|---|
| 9 | #include "ClpConstraint.hpp" | 
|---|
| 10 |  | 
|---|
| 11 | //############################################################################# | 
|---|
| 12 |  | 
|---|
| 13 | /** Quadratic Constraint Class | 
|---|
| 14 |  | 
|---|
| 15 | */ | 
|---|
| 16 |  | 
|---|
| 17 | class ClpConstraintQuadratic : public ClpConstraint { | 
|---|
| 18 |  | 
|---|
| 19 | public: | 
|---|
| 20 |  | 
|---|
| 21 | ///@name Stuff | 
|---|
| 22 | //@{ | 
|---|
| 23 |  | 
|---|
| 24 |  | 
|---|
| 25 | /** Fills gradient.  If Quadratic then solution may be NULL, | 
|---|
| 26 | also returns true value of function and offset so we can use x not deltaX in constraint | 
|---|
| 27 | If refresh is false then uses last solution | 
|---|
| 28 | Uses model for scaling | 
|---|
| 29 | Returns non-zero if gradient udefined at current solution | 
|---|
| 30 | */ | 
|---|
| 31 | virtual int gradient(const ClpSimplex * model, | 
|---|
| 32 | const double * solution, | 
|---|
| 33 | double * gradient, | 
|---|
| 34 | double & functionValue , | 
|---|
| 35 | double & offset, | 
|---|
| 36 | bool useScaling = false, | 
|---|
| 37 | bool refresh = true) const ; | 
|---|
| 38 | /// Resize constraint | 
|---|
| 39 | virtual void resize(int newNumberColumns) ; | 
|---|
| 40 | /// Delete columns in  constraint | 
|---|
| 41 | virtual void deleteSome(int numberToDelete, const int * which) ; | 
|---|
| 42 | /// Scale constraint | 
|---|
| 43 | virtual void reallyScale(const double * columnScale) ; | 
|---|
| 44 | /** Given a zeroed array sets nonquadratic columns to 1. | 
|---|
| 45 | Returns number of nonquadratic columns | 
|---|
| 46 | */ | 
|---|
| 47 | virtual int markNonlinear(char * which) const ; | 
|---|
| 48 | /** Given a zeroed array sets possible nonzero coefficients to 1. | 
|---|
| 49 | Returns number of nonzeros | 
|---|
| 50 | */ | 
|---|
| 51 | virtual int markNonzero(char * which) const; | 
|---|
| 52 | //@} | 
|---|
| 53 |  | 
|---|
| 54 |  | 
|---|
| 55 | ///@name Constructors and destructors | 
|---|
| 56 | //@{ | 
|---|
| 57 | /// Default Constructor | 
|---|
| 58 | ClpConstraintQuadratic(); | 
|---|
| 59 |  | 
|---|
| 60 | /// Constructor from quadratic | 
|---|
| 61 | ClpConstraintQuadratic(int row, int numberQuadraticColumns, int numberColumns, | 
|---|
| 62 | const CoinBigIndex * start, | 
|---|
| 63 | const int * column, const double * element); | 
|---|
| 64 |  | 
|---|
| 65 | /** Copy constructor . | 
|---|
| 66 | */ | 
|---|
| 67 | ClpConstraintQuadratic(const ClpConstraintQuadratic & rhs); | 
|---|
| 68 |  | 
|---|
| 69 | /// Assignment operator | 
|---|
| 70 | ClpConstraintQuadratic & operator=(const ClpConstraintQuadratic& rhs); | 
|---|
| 71 |  | 
|---|
| 72 | /// Destructor | 
|---|
| 73 | virtual ~ClpConstraintQuadratic (); | 
|---|
| 74 |  | 
|---|
| 75 | /// Clone | 
|---|
| 76 | virtual ClpConstraint * clone() const; | 
|---|
| 77 | //@} | 
|---|
| 78 | ///@name Gets and sets | 
|---|
| 79 | //@{ | 
|---|
| 80 | /// Number of coefficients | 
|---|
| 81 | virtual int numberCoefficients() const; | 
|---|
| 82 | /// Number of columns in constraint | 
|---|
| 83 | inline int numberColumns() const { | 
|---|
| 84 | return numberColumns_; | 
|---|
| 85 | } | 
|---|
| 86 | /// Column starts | 
|---|
| 87 | inline CoinBigIndex * start() const { | 
|---|
| 88 | return start_; | 
|---|
| 89 | } | 
|---|
| 90 | /// Columns | 
|---|
| 91 | inline const int * column() const { | 
|---|
| 92 | return column_; | 
|---|
| 93 | } | 
|---|
| 94 | /// Coefficients | 
|---|
| 95 | inline const double * coefficient() const { | 
|---|
| 96 | return coefficient_; | 
|---|
| 97 | } | 
|---|
| 98 | //@} | 
|---|
| 99 |  | 
|---|
| 100 | //--------------------------------------------------------------------------- | 
|---|
| 101 |  | 
|---|
| 102 | private: | 
|---|
| 103 | ///@name Private member data | 
|---|
| 104 | /// Column starts | 
|---|
| 105 | CoinBigIndex * start_; | 
|---|
| 106 | /// Column (if -1 then linear coefficient) | 
|---|
| 107 | int * column_; | 
|---|
| 108 | /// Coefficients | 
|---|
| 109 | double * coefficient_; | 
|---|
| 110 | /// Useful to have number of columns about | 
|---|
| 111 | int numberColumns_; | 
|---|
| 112 | /// Number of coefficients in gradient | 
|---|
| 113 | int numberCoefficients_; | 
|---|
| 114 | /// Number of quadratic columns | 
|---|
| 115 | int numberQuadraticColumns_; | 
|---|
| 116 | //@} | 
|---|
| 117 | }; | 
|---|
| 118 |  | 
|---|
| 119 | #endif | 
|---|
| 120 |  | 
|---|