Skip to content

Commit

Permalink
Local and provided connections (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-m committed Jun 12, 2012
1 parent b049a54 commit f6c2546
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/abstract_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class abstract_solver {
}
for (int s = 0; s < problem->stageCount(); ++s) {
set_intvar(problem->rankY(*i, s), sprint_var("y%d'%d", i->getID(), s));
set_intvar(problem->rankZ(*i, s), sprint_var("z%d'%d", i->getID(), s));
}
}

Expand Down
34 changes: 34 additions & 0 deletions src/constraint_generation.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,40 @@ int generate_constraints(PSLProblem *problem, abstract_solver &solver, abstract_
solver.add_constraint_geq(0);
}

///////////
//Number of local connections
for (int s = 0; s < problem->stageCount(); ++s) {
solver.new_constraint();
solver.set_constraint_coeff(problem->rankZ(*i, s),1);
for(AncestorIterator p = i->abegin() ; p!= i->aend() ; p++) {
solver.set_constraint_coeff( problem->rankZ(*p, *i, s), 1);
}
if(s == 0) {
//special case: initial broadcast (s=0)
solver.set_constraint_coeff( problem->rankX(*i), -1);
solver.add_constraint_eq(0);
} else {
//standard case: groups of clients
solver.add_constraint_eq(i->getType()->getDemand(s-1));
}


}

///////////
//the number of provided connections is the sum of the numbers of local and outgoing connections.
// for (int s = 0; s < problem->stageCount(); ++s) {
// solver.new_constraint();
// solver.set_constraint_coeff(problem->rankY(*i, s),1);
// solver.set_constraint_coeff(problem->rankZ(*i, s), -1);
// for(NodeIterator p = i->nbegin() ; p!= i->nend() ; p++) {
// solver.set_constraint_coeff( problem->rankZ(*i, *p, s), 1);
// }
// solver.add_constraint_eq(i->getType()->getDemand(s));
// }



///////////
//Additional constraints for the initial broadcast(s=0)
if(i->isRoot()) {
Expand Down

0 comments on commit f6c2546

Please sign in to comment.