84 extern const unsigned int n_examples;
124 std::map<std::string, int> courseMap;
126 int numberOfCourses = 0;
128 courseMap[co->name] = numberOfCourses++;
129 maxCredit += co->credit;
139 u =
IntVar(*
this, 0, maxCredit);
143 for (
int j=0; j<
p; j++) {
146 for (
int i=0;
i<numberOfCourses;
i++) {
147 rel(*
this, (x[
i]==j) == xij[
i]);
157 for (
const char** prereq = curr.
prereqs; *prereq != 0; prereq+=2)
158 rel(*
this, x[courseMap[*prereq]] < x[courseMap[*(prereq+1)]]);
168 case BRANCHING_NAIVE:
174 case BRANCHING_LOAD_REV:
181 const BACP&
b =
static_cast<const BACP&
>(home);
186 if (b.
l[values.
val()].min() < best) {
188 best = b.
l[val].min();
197 const BACP&
b =
static_cast<const BACP&
>(home);
202 if (b.
l[values.
val()].min() > best) {
204 best = b.
l[val].min();
214 l.
update(*
this, share, bacp.
l);
215 u.
update(*
this, share, bacp.
u);
216 x.
update(*
this, share, bacp.
x);
221 return new BACP(share,*
this);
230 std::vector<std::list<int> > period(curr.
p);
231 for (
int i=x.
size();
i--;)
232 period[x[
i].val()].push_back(
i);
234 os <<
"Solution with load " << u.
val() <<
":" << std::endl;
235 for (
int i=0;
i<curr.
p;
i++) {
236 os <<
"\tPeriod "<<
i+1<<
": ";
237 for (std::list<int>::iterator
v=period[i].begin();
238 v != period[
i].end(); ++
v) {
261 opt.
parse(argc,argv);
262 if (opt.
size() >= n_examples) {
263 std::cerr <<
"Error: size must be between 0 and " << n_examples - 1
267 IntMinimizeScript::run<BACP,BAB,SizeOptions>(
opt);
282 {
"hcw310", 1},{
"iwg101", 2},{
"mat190", 4},{
"mat192", 4},{
"dew101", 1},
283 {
"fis101", 5},{
"iwi131", 3},{
"mat191", 4},{
"mat193", 4},{
"fis102", 5},{
"hxwxx1", 1},
284 {
"iei134", 3},{
"iei141", 3},{
"mat194", 4},
285 {
"dewxx0", 1},{
"hcw311", 1},{
"iei132", 3},{
"iei133", 3},{
"iei142", 3},{
"iei162", 3},
286 {
"iwn170", 3},{
"mat195", 3},{
"hxwxx2", 1},{
"iei231", 4},{
"iei241", 4},{
"iei271", 3},{
"iei281", 3},{
"iwn261", 3},
287 {
"hfw120", 2},{
"iei233", 4},{
"iei238", 3},{
"iei261", 3},{
"iei272", 3},{
"iei273", 3},{
"iei161", 3},{
"iei232", 3},
288 {
"iei262", 3},{
"iei274", 3},{
"iwi365", 3},{
"iwn270", 3},{
"hrw130", 2},{
"iei218", 3},{
"iei219", 3},{
"iei248", 3},
293 const char* prereqs8[] =
384 const char* prereqs10[] = {
494 const char* prereqs12[] = {
565 { { 8, 10, 24, 2, 10,
577 const unsigned int n_examples =
sizeof(curriculum) /
sizeof(
Curriculum);
Value iterator for integer variables.
void size(unsigned int s)
Set default size.
Options for scripts with additional size parameter
int b
Maximum academic load.
void linear(Home home, const FloatVarArgs &x, FloatRelType frt, FloatNum c)
Post propagator for .
void update(Space &home, bool share, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
void parse(int &argc, char *argv[])
Parse options from arguments argv (number is argc)
int c
Minimum amount of courses.
IntVarArray x
Period to which a course is assigned.
IntVarBranch INT_VAR_SIZE_MIN(BranchTbl tbl)
Select variable with smallest domain size.
const Course * courses
Courses.
Example: The balanced academic curriculum problem
const int max
Largest allowed integer value.
int a
Minimum academic load.
Parametric base-class for scripts.
void iterations(unsigned int i)
Set default number of iterations.
const int min
Smallest allowed integer value.
IntVar u
Maximum academic load.
virtual void print(std::ostream &os) const
Print solution.
void update(Space &, bool share, VarArray< Var > &a)
Update array to be a clone of array a.
const char * name
Course name.
Gecode::FloatVal c(-8, 8)
int p
Number of positive literals for node type.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int d
Maximum amount of courses.
virtual IntVar cost(void) const
Return solution cost.
BACP(bool share, BACP &bacp)
Constructor for copying bacp.
Simple fail-first branching.
static int load(const Space &home, IntVar x, int)
Value selection function for load branching.
IntValBranch INT_VAL_MIN(void)
Select smallest value.
IntVarArray l
Academic load for each period.
IntVarArray q
Number of courses assigned to a period.
unsigned int size(I &i)
Size of all ranges of range iterator i.
const char ** prereqs
Prerequisites.
static int load_rev(const Space &home, IntVar x, int)
Value selection function for reverse load branching.
const Curriculum curr
The curriculum to be scheduled.
void branching(int v)
Set default branching value.
Passing integer arguments.
Passing Boolean variables.
union Gecode::@518::NNF::@57 u
Union depending on nodetype t.
void values(Home home, const IntVarArgs &x, IntSet y, IntConLevel icl=ICL_DEF)
Post constraint .
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
Place based on maximum-load.
int val(void) const
Return assigned value.
int main(int argc, char *argv[])
Main-function.
void solutions(unsigned int n)
Set default number of solutions to search for.
virtual Space * copy(bool share)
Copy during cloning.
int val(void) const
Return current value.
Place based on minimum-load.
struct Gecode::@518::NNF::@57::@58 b
For binary nodes (and, or, eqv)
Gecode toplevel namespace
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...
BrancherHandle 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.
int size(void) const
Return size of array (number of elements)
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
BACP(const SizeOptions &opt)
Actual model.