Пример #1
0
void LpSolveInterface::GraphParsingState::SetObjectiveFunction(lprec* model) {
  set_minim(CHECK_NOTNULL(model));
  int num_x_vars = edge_to_crossing_variable_indices_.size();
  unique_ptr<int[]> indices(new int[num_x_vars]);
  unique_ptr<REAL[]> coeffs(new REAL[num_x_vars]);
  int added = 0;
  for (const pair<int, int>& e : edge_to_crossing_variable_indices_) {
    indices[added] = e.second;
    Edge* edge = graph_->internal_edges().at(e.first);
    coeffs[added++] = (REAL)(edge->Weight());
  }
  set_obj_fnex(model, num_x_vars, coeffs.get(), indices.get());
}
Пример #2
0
int Edge::compareTo(Edge that){
	if(this->Weight() < that.Weight()) return 1;
	else if(this->Weight() > that.Weight()) return -1;
	else	return 0;
}