31 OsiRowCut::operator=(rhs);
51 rhs += row().dotProduct(solution);
52 const int * indice =
Q_.getIndices();
53 const double * val =
Q_.getElements();
54 const int * start =
Q_.getVectorStarts();
55 const int * length =
Q_.getVectorLengths();
56 int n =
Q_.getMajorDim();
58 for(
int i = 0 ; i <
n ; i++){
61 for(
int k = s ;
k < s+l ;
k++){
62 if(i == indice[
k]) rhs += solution[i] * solution[indice[
k]] * val[
k];
63 else rhs += 2*solution[i] * solution[indice[
k]] * val[
k];
68 for(
int i = 0 ; i <
n ; i++){
69 for(
int k = 0 ;
k < length[i] ;
k++){
70 if(i == indice[
k]) rhs += solution[i] * solution[indice[
k]] * val[
k];
71 else rhs += 2*solution[i] * solution[indice[
k]] * val[
k];
76 return std::max(lb() - rhs, rhs - ub());
83 std::cout<<
"Quadratic cut has lower bound "<<lb()<<
" and upper bound "<<ub()
86 std::cout<<
"Linear part has "<<row().getNumElements()<<
" non zeroes:"
89 const int& nElem = row().getNumElements();
90 const int * indices = row().getIndices();
91 const double * elements = row().getElements();
93 for(
int i = 0 ; i < nElem ; i++){
94 if(i > 0 && elements[i] > 0.)
96 std::cout<< elements[i] <<
" x["<<indices[i]<<
"]\t";
97 if(i > 0 && i % 5 == 0) std::cout<<std::endl;
100 if(
Q_.getNumElements()){
101 std::cout<<
"Quadratic part is given by the matrix:"<<std::endl;
112 quadCuts_(other.quadCuts_.size()){
113 for(
unsigned int i = 0 ; i <
quadCuts_.size() ; i++){
121 OsiCuts::operator=(rhs);
122 for(
unsigned int i = 0 ; i <
quadCuts_.size() ; i++)
127 for(
unsigned int i = 0 ; i <
quadCuts_.size() ; i++){
135 for(
unsigned int i = 0 ; i <
quadCuts_.size() ; i++)
143 OsiCuts::printCuts();
144 std::cout<<
quadCuts_.size()<<
" quadratic cuts."<<std::endl;
145 for(
unsigned int i = 0 ; i <
quadCuts_.size() ; i++){
virtual OsiRowCut * clone() const
Virtual copy.
Cuts & operator=(const Cuts &rhs)
Assignment operator.
Generalizes OsiCuts to handle quadratic cuts.
Cuts()
Default constructor.
void print() const
Print.
QuadCut & operator=(const QuadCut &rhs)
Assignment operator.
Stores only the upper triangle of a symetric Q.
QuadCutPtrStorage quadCuts_
void fint fint fint fint fint fint fint fint fint fint real real real real real real real real * s
QuadCut()
Default constructor.
void printCuts() const
Print all cuts in the collection.
double violated(const double *solution) const
Compute cut violation.
double c_
Stores the constant part of the cut.
MatrixStorageType type_
Storage type.
CoinPackedMatrix Q_
Stores quadratic part of cut.