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)]]);
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) {
239 os << curr.courses[*
v].name <<
" ";
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 MinimizeScript::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);