当前位置: 首页>>代码示例>>C++>>正文


C++ PackedVector::get_index_by_pos方法代码示例

本文整理汇总了C++中PackedVector::get_index_by_pos方法的典型用法代码示例。如果您正苦于以下问题:C++ PackedVector::get_index_by_pos方法的具体用法?C++ PackedVector::get_index_by_pos怎么用?C++ PackedVector::get_index_by_pos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PackedVector的用法示例。


在下文中一共展示了PackedVector::get_index_by_pos方法的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);
            }
    }
}
开发者ID:darabbt,项目名称:les,代码行数:28,代码来源:interaction_graph.cpp

示例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) );
        }
    }
}
开发者ID:darabbt,项目名称:les,代码行数:15,代码来源:milp_problem.cpp

示例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");
    }

}
开发者ID:darabbt,项目名称:les,代码行数:48,代码来源:milp_problem.cpp


注:本文中的PackedVector::get_index_by_pos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。