本文整理汇总了C++中PackedVector::get_num_elements方法的典型用法代码示例。如果您正苦于以下问题:C++ PackedVector::get_num_elements方法的具体用法?C++ PackedVector::get_num_elements怎么用?C++ PackedVector::get_num_elements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PackedVector
的用法示例。
在下文中一共展示了PackedVector::get_num_elements方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: edge
InteractionGraph::InteractionGraph(MILPP* problem)
: graph_t(problem->get_num_cols())
{
int ri; /* row index */
int ci; /* col index */
int ni; /* neighbor index */
PackedVector* row;
problem_ = problem;
/* Start forming variable neighbourhoods by using constraints */
for (ri = 0; ri < problem->get_num_rows(); ri++)
{
row = problem->get_row(ri);
for (ci = 0; ci < row->get_num_elements(); ci++)
for (ni = 0; ni < row->get_num_elements(); ni++)
{
if ((ci == ni) || /* Skip variables with the same index */
edge(row->get_index_by_pos(ci),
row->get_index_by_pos(ni), *this).second)
continue;
/* Add variable with index n as a neighbor for a
variable with index c*/
add_edge(row->get_index_by_pos(ci),
row->get_index_by_pos(ni), *this);
}
}
}
示例2:
void
MILPP::set_cons_matrix(const PackedMatrix* matrix)
{
cons_matrix_ = *matrix;
for (int i = 0; i < get_num_rows(); i++)
{
PackedVector* row = get_row(i);
for (int j = 0; j < row->get_num_elements(); j++)
{
col_to_row_mapping_[ row->get_index_by_pos(j) ]->insert(i);
row_to_col_mapping_[i]->insert( row->get_index_by_pos(j) );
}
}
}
示例3: printf
void
MILPP::print()
{
int i;
int j;
int offset;
/* Print objective function sense and its coefficients */
for (int i = 0; i < get_num_cols(); ++i)
{
if (i) printf(" + ");
printf("%.1fx%d", get_obj_coef(i), i);
}
printf(" -> %s\n", obj_sense_to_string());
/* Print constraints represented by rows */
printf("subject to\n");
for (i = 0; i < cons_matrix_.get_num_rows(); i++)
{
int t = 0; /* start from col zero */
PackedVector* row = cons_matrix_.get_vector(i);
printf("(%d) ", i);
for (j = 0; j < row->get_num_elements(); j++)
{
if (j > 0)
printf(" + ");
//printf("[%d|%d]", row->get_index_by_pos(j), t);
if ((offset = row->get_index_by_pos(j) - t) >= 1)
{
if (j > 0)
offset -= 1;
//printf("(%d)", offset);
offset *= 5 + 3;
for (int s = 0; s < offset; s++)
printf(" ");
}
t = row->get_index_by_pos(j);
printf("%.1fx%d", row->get_element_by_pos(j),
row->get_index_by_pos(j));
}
/* Print row sense */
printf(" <= ");
/* Print row upper bound */
printf("%.1f", get_row_upper_bound(i));
printf("\n");
}
}