Go to the documentation of this file.
80 extern const unsigned int n_examples;
121 std::map<std::string, int> courseMap;
123 int numberOfCourses = 0;
125 courseMap[co->name] = numberOfCourses++;
126 maxCredit += co->credit;
136 u =
IntVar(*
this, 0, maxCredit);
140 for (
int j=0; j<
p; j++) {
143 for (
int i=0;
i<numberOfCourses;
i++) {
144 rel(*
this, (
x[
i]==j) == xij[
i]);
154 for (
const char** prereq = curr.
prereqs; *prereq != 0; prereq+=2)
155 rel(*
this,
x[courseMap[*prereq]] <
x[courseMap[*(prereq+1)]]);
164 switch (
opt.branching()) {
165 case BRANCHING_NAIVE:
171 case BRANCHING_LOAD_REV:
178 const BACP&
b = static_cast<const BACP&>(home);
183 if (
b.l[
values.val()].min() < best) {
185 best =
b.l[val].min();
194 const BACP&
b = static_cast<const BACP&>(home);
199 if (
b.l[
values.val()].min() > best) {
201 best =
b.l[val].min();
211 l.update(*
this, bacp.
l);
212 u.update(*
this, bacp.
u);
218 return new BACP(*
this);
227 std::vector<std::list<int> > period(curr.
p);
228 for (
int i=
x.size();
i--;)
229 period[
x[
i].val()].push_back(
i);
231 os <<
"Solution with load " <<
u.val() <<
":" << std::endl;
232 for (
int i=0;
i<curr.
p;
i++) {
233 os <<
"\tPeriod "<<
i+1<<
": ";
234 for (std::list<int>::iterator
v=period[
i].begin();
235 v != period[
i].end(); ++
v) {
259 if (
opt.size() >= n_examples) {
260 std::cerr <<
"Error: size must be between 0 and " << n_examples - 1
264 IntMinimizeScript::run<BACP,BAB,SizeOptions>(
opt);
279 {
"hcw310", 1},{
"iwg101", 2},{
"mat190", 4},{
"mat192", 4},{
"dew101", 1},
280 {
"fis101", 5},{
"iwi131", 3},{
"mat191", 4},{
"mat193", 4},{
"fis102", 5},{
"hxwxx1", 1},
281 {
"iei134", 3},{
"iei141", 3},{
"mat194", 4},
282 {
"dewxx0", 1},{
"hcw311", 1},{
"iei132", 3},{
"iei133", 3},{
"iei142", 3},{
"iei162", 3},
283 {
"iwn170", 3},{
"mat195", 3},{
"hxwxx2", 1},{
"iei231", 4},{
"iei241", 4},{
"iei271", 3},{
"iei281", 3},{
"iwn261", 3},
284 {
"hfw120", 2},{
"iei233", 4},{
"iei238", 3},{
"iei261", 3},{
"iei272", 3},{
"iei273", 3},{
"iei161", 3},{
"iei232", 3},
285 {
"iei262", 3},{
"iei274", 3},{
"iwi365", 3},{
"iwn270", 3},{
"hrw130", 2},{
"iei218", 3},{
"iei219", 3},{
"iei248", 3},
290 const char* prereqs8[] =
381 const char* prereqs10[] = {
491 const char* prereqs12[] = {
562 { { 8, 10, 24, 2, 10,
574 const unsigned int n_examples =
sizeof(curriculum) /
sizeof(
Curriculum);
void values(Home home, const IntVarArgs &x, IntSet y, IntPropLevel ipl)
Post constraint .
struct Gecode::@602::NNF::@65::@66 b
For binary nodes (and, or, eqv)
Post propagator for SetVar x
IntVarArray q
Number of courses assigned to a period.
int b
Maximum academic load.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
unsigned int size(I &i)
Size of all ranges of range iterator i.
int d
Maximum amount of courses.
Value iterator for integer variables.
virtual Space * copy(void)
Copy during cloning.
int main(int argc, char *argv[])
Main-function.
static int load(const Space &home, IntVar x, int)
Value selection function for load branching.
IntValBranch INT_VAL(IntBranchVal v, IntBranchCommit c)
Select value as defined by the value function v and commit function c Uses a commit function as defau...
BACP(const SizeOptions &opt)
Actual model.
const char ** prereqs
Prerequisites.
IntVarArray l
Academic load for each period.
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf, FloatVarValPrint vvp)
Branch over x with variable selection vars and value selection vals.
void iterations(unsigned int i)
Set default number of iterations.
Place based on maximum-load.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
Simple fail-first branching.
static int load_rev(const Space &home, IntVar x, int)
Value selection function for reverse load branching.
union Gecode::@602::NNF::@65 u
Union depending on nodetype t.
Gecode toplevel namespace
struct Gecode::@602::NNF::@65::@67 a
For atomic nodes.
int a
Minimum academic load.
Place based on minimum-load.
Passing Boolean variables.
Parametric base-class for scripts.
void branching(int v)
Set default branching value.
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
const int max
Largest allowed integer value.
BACP(BACP &bacp)
Constructor for copying bacp.
IntVar u
Maximum academic load.
virtual void print(std::ostream &os) const
Print solution.
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatVal c)
Post propagator for .
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl)
Select variable with smallest domain size.
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Example: The balanced academic curriculum problem
virtual IntVar cost(void) const
Return solution cost.
void update(Space &home, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
const int min
Smallest allowed integer value.
IntVarArray x
Period to which a course is assigned.
const char * name
Course name.
void solutions(unsigned int n)
Set default number of solutions to search for.
Gecode::FloatVal c(-8, 8)
const Curriculum curr
The curriculum to be scheduled.
int c
Minimum amount of courses.
Passing integer arguments.
Gecode::IntArgs i({1, 2, 3, 4})
int p
Number of positive literals for node type.
Options for scripts with additional size parameter
const Course * courses
Courses.