57 Q_(cut.
Q(), cut.type())
105 for(
int i = 0 ; i <
Q_.
nnz_ ; i++){
111 n =
a_.getNumElements();
115 const int * indices =
a_.getIndices();
116 const double * elems =
a_.getElements();
118 for(
int i = 0 ; i <
n ; i++){
119 std::pair<gStore::iterator, bool> res =
g_.insert(std::make_pair(indices[i], std::make_pair(elems[i],0.)));
127 for(TMat::RowS::const_iterator i = nonEmptyRows.begin() ; i != nonEmptyRows.end() ; i++){
128 std::pair<gStore::iterator, bool> res =
g_.insert(std::make_pair(i->first, std::make_pair(0.,0.)));
137 for(TMat::RowS::const_iterator i = nonEmptyCols.begin() ; i != nonEmptyCols.end() ; i++){
138 std::pair<gStore::iterator, bool> res =
g_.insert(std::make_pair(i->first, std::make_pair(0.,0.)));
147 std::cout<<
"constant term "<<
c_<<std::endl;
148 int * a_ind =
a_.getIndices();
149 const double * a_el =
a_.getElements();
150 int n =
a_.getNumElements();
151 std::cout<<
"Linear term (size "<<n<<
"): ";
152 for(
int i = 0 ; i <
n ; i++)
154 std::cout<<a_el[i]<<
" * x["<<a_ind[i]<<
"]\t";
155 if(i && ( (i % 5) == 0 ) ) std::cout<<std::endl<<
"\t\t";
166 int * a_ind =
a_.getIndices();
167 const double * a_el =
a_.getElements();
168 int n =
a_.getNumElements();
169 for(
int i = 0 ; i <
n ; i++)
171 value += a_el[i] * x[a_ind[i]];
176 for(gStore::iterator i =
g_.begin() ; i !=
g_.end() ; i++){
177 value += i->second.second * x[i->first];
185 return static_cast<int>(
g_.size());}
190 for(gStore::iterator i =
g_.begin() ; i !=
g_.end() ; i++){
191 indices[n++] = i->first + offset;
194 assert(nnz == (
int)
g_.size());
203 for(gStore::iterator i =
g_.begin() ; i !=
g_.end() ; i++){
204 printf(
"x[%i] = %g, ",i->first, x[i->first]);
211 std::cout<<
"Computing gradient"<<std::endl;
213 for(gStore::iterator i =
g_.begin() ; i !=
g_.end() ; i++){
215 printf(
"%i: %g, %g\n", i->first, i->second.second, i->second.first);
217 values[n++] = 2*i->second.second + i->second.first;
219 assert (nnz == (
int)
g_.size());
225 for(gStore::iterator i =
g_.begin() ; i !=
g_.end() ; i++){
226 i->second.second = 0;
232 for(TMat::RowS::const_iterator ii = nonEmptyRows.begin() ; ii != nonEmptyRows.end();
245 for(TMat::RowS::const_iterator ii = nonEmptyCols.begin() ; ii != nonEmptyCols.end();
264 for(
int i = 0 ; i <
Q_.
nnz_ ; i++){
265 std::pair<int, int>
e;
267 AdjustableMat::iterator
pos = H.find(e);
269 if(pos->second.second != -1)
270 pos->second.second++;
274 std::pair<AdjustableMat::iterator, bool> res =
275 H.insert(std::make_pair(e, std::make_pair(H.size(), 1)));
276 assert(res.second ==
true);
284 for(
int i = 0 ; i <
Q_.
nnz_ ; i++){
297 for(
int i = 0 ; i <
Q_.
nnz_ ; i++){
299 printf(
"iRow %i, jCol %i, value %g , nnz %i\n",
int numNonEmptyCols()
Get number of non empty cols.
CoinPackedVector a_
linear term in sparse storage.
void make_upper_triangular(const MatrixStorageType &T)
pos
position where the operator should be printed when printing the expression
void internal_eval_grad(const double *x)
Does internal work to evaluate gradiant of this in x.
std::vector< AdjustableMat::iterator > Q_hessian_idx_
To have fast access to entries in full hessian of Q_.
CouNumber Q(register int k, CouNumber x)
vector< int > rowOrdering_
std::vector< gStore::iterator > a_grad_idx_
To have fast access to gradiant entries for a_.
std::vector< gStore::iterator > Q_col_grad_idx_
To have fast access to gradient entries for cols Q_.
void eval_grad(const int nnz, const double *x, bool new_x, double *values)
Evaluate gradiant of quadratic form.
CoinPackedMatrix & Q()
Return the matrix stored.
void remove_from_hessian(AdjustableMat &H)
Remove row from a bigger hessian.
double eval_f(const double *x, bool new_x)
Evaluate quadratic form.
void add_to_hessian(AdjustableMat &H, bool offset)
Add row to a bigger hessian.
QuadRow()
Default constructor.
std::vector< gStore::iterator > Q_row_grad_idx_
To have fast access to gradient entries for rows Q_.
Stores a quadratic row of the form l < c + ax + x^T Q x < u.
void fint fint fint real fint real real real real real real real real real * e
QuadRow & operator=(const QuadRow &rhs)
Assignment operator.
const RowS & nonEmptyCols() const
Get the list of non empty row.
int nnz_grad()
Get number of non-zeroes in the gradiant.
void gradiant_struct(const int nnz, int *indices, bool offset)
Get structure of gradiant.
void initialize()
Initialize once quadratic form is know.
bool grad_evaled_
Flag indicating if gradiant has been evaluated.
double & c()
Acces the constant.
void eval_hessian(double lambda, double *values)
Return hessian value (i.e.
vector< int > columnOrdering_
std::map< matEntry, matIdx > AdjustableMat
const RowS & nonEmptyRows() const
Get the list of non empty row.
void print()
Print quadratic constraint.
int nnz
ATTENTION: Filter expect the jacobian to be ordered by row.
MatrixStorageType & type()
Acces storage type Acces storage type.
int numNonEmptyRows()
Get number of non empty rows.
void fint fint fint real fint real * x