52 using namespace Gecode;
84 extern const unsigned int n_examples;
124 std::map<std::string, int> courseMap;
126 int numberOfCourses = 0;
127 for (
const Course* co=curr.courses; co->
name != 0; co++) {
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]);
148 t[
i] = curr.courses[
i].credit;
157 for (
const char** prereq = curr.prereqs; *prereq != 0; prereq+=2)
158 rel(*
this, x[courseMap[*prereq]] < x[courseMap[*(prereq+1)]]);
167 if (opt.
branching() == BRANCHING_NAIVE) {
175 ::post(*
this,xv,varsel,valsel);
179 ::post(*
this,xv,varsel,valsel);
187 l.update(*
this, share, bacp.
l);
188 u.update(*
this, share, bacp.
u);
189 x.update(*
this, share, bacp.
x);
194 return new BACP(share,*
this);
203 std::vector<std::list<int> > period(curr.p);
204 for (
int i=x.
size();
i--;)
205 period[x[
i].val()].push_back(
i);
207 os <<
"Solution with load " << u.val() <<
":" << std::endl;
208 for (
int i=0;
i<curr.p;
i++) {
209 os <<
"\tPeriod "<<
i+1<<
": ";
210 for (std::list<int>::iterator
v=period[i].begin();
211 v != period[
i].end(); ++
v) {
212 os << curr.courses[*
v].name <<
" ";
225 template <
bool minimize>
243 ? b.
l[values.
val()].min() < best
244 : b.
l[values.
val()].min() > best) {
246 best = b.
l[val].min();
256 return (a == 0) ? x.
eq(home,n) : x.
gr(home,n);
274 opt.
parse(argc,argv);
275 if (opt.
size() >= n_examples) {
276 std::cerr <<
"Error: size must be between 0 and " << n_examples - 1
280 MinimizeScript::run<BACP,BAB,SizeOptions>(
opt);
295 {
"hcw310", 1},{
"iwg101", 2},{
"mat190", 4},{
"mat192", 4},{
"dew101", 1},
296 {
"fis101", 5},{
"iwi131", 3},{
"mat191", 4},{
"mat193", 4},{
"fis102", 5},{
"hxwxx1", 1},
297 {
"iei134", 3},{
"iei141", 3},{
"mat194", 4},
298 {
"dewxx0", 1},{
"hcw311", 1},{
"iei132", 3},{
"iei133", 3},{
"iei142", 3},{
"iei162", 3},
299 {
"iwn170", 3},{
"mat195", 3},{
"hxwxx2", 1},{
"iei231", 4},{
"iei241", 4},{
"iei271", 3},{
"iei281", 3},{
"iwn261", 3},
300 {
"hfw120", 2},{
"iei233", 4},{
"iei238", 3},{
"iei261", 3},{
"iei272", 3},{
"iei273", 3},{
"iei161", 3},{
"iei232", 3},
301 {
"iei262", 3},{
"iei274", 3},{
"iwi365", 3},{
"iwn270", 3},{
"hrw130", 2},{
"iei218", 3},{
"iei219", 3},{
"iei248", 3},
306 const char* prereqs8[] =
397 const char* prereqs10[] = {
507 const char* prereqs12[] = {
578 { { 8, 10, 24, 2, 10,
590 const unsigned int n_examples =
sizeof(curriculum) /
sizeof(
Curriculum);