示例#1
0
文件: MtxLP.cpp 项目: kierzek/MUFINS
void MtxLP::getObjective(stomap* rv, bool withzeroes) const{
    for (int i = 1; i <= get_num_cols(); i++){
        double coef = get_obj_coef(i);
        if (withzeroes || coef != 0)
            (*rv)[get_col_name(i)] = coef;
    }
}
示例#2
0
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");
    }

}
示例#3
0
文件: MtxLP.cpp 项目: kierzek/MUFINS
double MtxLP::getObjCoef(string name) const{
    return get_obj_coef(ncol(name));
}