Timetabler
custom_parser.cpp
1 #include "custom_parser.h"
2 
3 #include <algorithm>
4 #include <cstdlib>
5 #include <iostream>
6 #include <string>
7 #include <tao/pegtl.hpp>
8 #include <vector>
9 #include "clauses.h"
10 #include "global.h"
11 #include "utils.h"
12 
21 Clauses makeAntecedent(Object &obj, int course) {
22  Clauses ante, clause;
23  if (obj.instructorValues.size() > 0) {
24  clause = obj.constraintEncoder->hasFieldTypeListedValues(
25  course, FieldType::instructor, obj.instructorValues);
26  ante = ante & clause;
27  }
28  if (obj.programValues.size() > 0) {
29  clause = obj.constraintEncoder->hasFieldTypeListedValues(
30  course, FieldType::program, obj.programValues);
31  ante = ante & clause;
32  }
33  if (obj.segmentValues.size() > 0) {
34  clause = obj.constraintEncoder->hasFieldTypeListedValues(
35  course, FieldType::segment, obj.segmentValues);
36  ante = ante & clause;
37  }
38  if (obj.isMinorValues.size() > 0) {
39  clause = obj.constraintEncoder->hasFieldTypeListedValues(
40  course, FieldType::isMinor, obj.isMinorValues);
41  ante = ante & clause;
42  }
43  return ante;
44 }
45 
55 Clauses makeConsequent(Object &obj, int course, int i) {
56  Clauses cons, clause;
57  if (obj.classSame) {
58  for (unsigned j = i + 1; j < obj.courseValues.size(); j++) {
59  Clauses a = makeAntecedent(obj, obj.courseValues[j]);
60  Clauses b = obj.constraintEncoder->hasSameFieldTypeAndValue(
61  course, obj.courseValues[j], FieldType::classroom);
62  a = a >> b;
63  cons = cons & a;
64  }
65  }
66  if (obj.classNotSame) {
67  for (unsigned j = i + 1; j < obj.courseValues.size(); j++) {
68  Clauses a = makeAntecedent(obj, obj.courseValues[j]);
69  Clauses b = obj.constraintEncoder->hasSameFieldTypeAndValue(
70  course, obj.courseValues[j], FieldType::classroom);
71  a = a >> (~b);
72  cons = cons & a;
73  }
74  }
75  if (obj.slotSame) {
76  for (unsigned j = i + 1; j < obj.courseValues.size(); j++) {
77  Clauses a = makeAntecedent(obj, obj.courseValues[j]);
78  Clauses b = obj.constraintEncoder->hasSameFieldTypeAndValue(
79  course, obj.courseValues[j], FieldType::slot);
80  a = a >> b;
81  cons = cons & a;
82  }
83  }
84  if (obj.slotNotSame) {
85  for (unsigned j = i + 1; j < obj.courseValues.size(); j++) {
86  Clauses a = makeAntecedent(obj, obj.courseValues[j]);
87  Clauses b = obj.constraintEncoder->hasSameFieldTypeAndValue(
88  course, obj.courseValues[j], FieldType::slot);
89  a = a >> (~b);
90  cons = cons & a;
91  }
92  }
93  if (obj.classValues.size() > 0) {
94  clause = obj.constraintEncoder->hasFieldTypeListedValues(
95  course, FieldType::classroom, obj.classValues);
96  cons = cons & clause;
97  }
98  if (obj.slotValues.size() > 0) {
99  clause = obj.constraintEncoder->hasFieldTypeListedValues(
100  course, FieldType::slot, obj.slotValues);
101  cons = cons & clause;
102  }
103  return cons;
104 }
105 
106 namespace pegtl = tao::TAO_PEGTL_NAMESPACE;
107 
108 namespace custom_constraint_grammar {
109 
110 template <typename Rule>
111 struct action : pegtl::nothing<Rule> {};
112 
116 struct integer
117  : pegtl::seq<pegtl::opt<pegtl::one<'-'>>, pegtl::plus<pegtl::digit>> {};
118 template <>
119 struct action<integer> {
120  template <typename Input>
121  static void apply(const Input &in, Object &obj) {
122  obj.integer = std::stoi(in.string());
123  }
124 };
125 
129 struct instr : TAO_PEGTL_KEYWORD("IN") {};
130 
135 struct notstr : TAO_PEGTL_KEYWORD("NOT") {};
136 template <>
137 struct action<notstr> {
138  template <typename Input>
139  static void apply(const Input &in, Object &obj) {
140  obj.isNot = true;
141  }
142 };
143 
147 struct andstr : TAO_PEGTL_KEYWORD("AND") {};
148 
152 struct orstr : TAO_PEGTL_KEYWORD("OR") {};
153 
157 struct exceptstr : TAO_PEGTL_KEYWORD("EXCEPT") {};
158 
163 struct classroomstr : TAO_PEGTL_KEYWORD("CLASSROOM") {};
164 template <>
166  template <typename Input>
167  static void apply(const Input &in, Object &obj) {
168  obj.fieldType = FieldValuesType::CLASSROOM;
169  }
170 };
171 
175 struct slotstr : TAO_PEGTL_KEYWORD("SLOT") {};
176 template <>
177 struct action<slotstr> {
178  template <typename Input>
179  static void apply(const Input &in, Object &obj) {
180  obj.fieldType = FieldValuesType::SLOT;
181  }
182 };
183 
187 struct coursestr : TAO_PEGTL_KEYWORD("COURSE") {};
188 template <>
189 struct action<coursestr> {
190  template <typename Input>
191  static void apply(const Input &in, Object &obj) {
192  obj.fieldType = FieldValuesType::COURSE;
193  }
194 };
195 
199 struct instructorstr : TAO_PEGTL_KEYWORD("INSTRUCTOR") {};
200 template <>
202  template <typename Input>
203  static void apply(const Input &in, Object &obj) {
204  obj.fieldType = FieldValuesType::INSTRUCTOR;
205  }
206 };
207 
211 struct segmentstr : TAO_PEGTL_KEYWORD("SEGMENT") {};
212 template <>
214  template <typename Input>
215  static void apply(const Input &in, Object &obj) {
216  obj.fieldType = FieldValuesType::SEGMENT;
217  }
218 };
219 
223 struct isminorstr : TAO_PEGTL_KEYWORD("ISMINOR") {};
224 template <>
226  template <typename Input>
227  static void apply(const Input &in, Object &obj) {
228  obj.fieldType = FieldValuesType::ISMINOR;
229  }
230 };
231 
235 struct programstr : TAO_PEGTL_KEYWORD("PROGRAM") {};
236 template <>
238  template <typename Input>
239  static void apply(const Input &in, Object &obj) {
240  obj.fieldType = FieldValuesType::PROGRAM;
241  }
242 };
243 
247 struct unbundlestr : TAO_PEGTL_KEYWORD("UNBUNDLE") {};
248 
252 struct weightstr : TAO_PEGTL_KEYWORD("WEIGHT") {};
253 
258 struct fieldtype
259  : pegtl::sor<instructorstr, segmentstr, isminorstr, programstr> {};
260 template <>
261 struct action<fieldtype> {
262  template <typename Input>
263  static void apply(const Input &in, Object &obj) {
264  obj.isNot = false;
265  obj.classSame = false;
266  obj.slotSame = false;
267  obj.classNotSame = false;
268  obj.slotNotSame = false;
269  }
270 };
271 
275 struct value
276  : pegtl::plus<pegtl::sor<pegtl::range<'a', 'z'>, pegtl::range<'A', 'Z'>,
277  pegtl::digit, pegtl::one<'.'>, pegtl::one<'-'>,
278  pegtl::one<'@'>, pegtl::one<'<'>, pegtl::one<'>'>,
279  pegtl::space>> {};
280 template <>
281 struct action<value> {
282  template <typename Input>
283  static void apply(const Input &in, Object &obj) {
284  std::string val = in.string();
285  bool found = false;
286  if (obj.fieldType == FieldValuesType::INSTRUCTOR) {
287  for (unsigned i = 0; i < obj.timetabler->data.instructors.size(); i++) {
288  if (obj.timetabler->data.instructors[i].getName() == val) {
289  found = true;
290  obj.instructorValues.push_back(i);
291  break;
292  }
293  }
294  if (!found) {
295  LOG(ERROR) << "Instructor " << val << " does not exist.";
296  }
297  found = false;
298  } else if (obj.fieldType == FieldValuesType::COURSE) {
299  for (unsigned i = 0; i < obj.timetabler->data.courses.size(); i++) {
300  if (obj.timetabler->data.courses[i].getName() == val) {
301  found = true;
302  obj.courseValues.push_back(i);
303  break;
304  }
305  }
306  if (!found) {
307  LOG(ERROR) << "Course " << val << " does not exist.";
308  }
309  found = false;
310  } else if (obj.fieldType == FieldValuesType::SEGMENT) {
311  for (unsigned i = 0; i < obj.timetabler->data.segments.size(); i++) {
312  if (obj.timetabler->data.segments[i].getName() == val) {
313  found = true;
314  obj.segmentValues.push_back(i);
315  break;
316  }
317  }
318  if (!found) {
319  LOG(ERROR) << "Segment " << val << " does not exist.";
320  }
321  found = false;
322  } else if (obj.fieldType == FieldValuesType::PROGRAM) {
323  for (unsigned i = 0; i < obj.timetabler->data.programs.size(); i++) {
324  if (obj.timetabler->data.programs[i].getNameWithType() == val) {
325  found = true;
326  obj.programValues.push_back(i);
327  break;
328  }
329  }
330  if (!found) {
331  LOG(ERROR) << "Program " << val << " does not exist.";
332  }
333  found = false;
334  } else if (obj.fieldType == FieldValuesType::ISMINOR) {
335  for (unsigned i = 0; i < obj.timetabler->data.isMinors.size(); i++) {
336  if (obj.timetabler->data.isMinors[i].getName() == val) {
337  found = true;
338  obj.isMinorValues.push_back(i);
339  break;
340  }
341  }
342  if (!found) {
343  LOG(ERROR) << "IsMinor " << val << " does not exist.";
344  }
345  found = false;
346  } else if (obj.fieldType == FieldValuesType::CLASSROOM) {
347  for (unsigned i = 0; i < obj.timetabler->data.classrooms.size(); i++) {
348  if (obj.timetabler->data.classrooms[i].getName() == val) {
349  found = true;
350  obj.classValues.push_back(i);
351  break;
352  }
353  }
354  if (!found) {
355  LOG(ERROR) << "Classroom " << val << " does not exist.";
356  }
357  found = false;
358  } else if (obj.fieldType == FieldValuesType::SLOT) {
359  for (unsigned i = 0; i < obj.timetabler->data.slots.size(); i++) {
360  if (obj.timetabler->data.slots[i].getName() == val) {
361  found = true;
362  obj.slotValues.push_back(i);
363  break;
364  }
365  }
366  if (!found) {
367  LOG(ERROR) << "Slot " << val << " does not exist.";
368  }
369  found = false;
370  }
371  }
372 };
373 
377 struct allvalues : pegtl::pad<pegtl::one<'*'>, pegtl::space> {};
378 template <>
379 struct action<allvalues> {
380  template <typename Input>
381  static void apply(const Input &in, Object &obj) {
382  std::string val = in.string();
383  if (obj.fieldType == FieldValuesType::INSTRUCTOR) {
384  for (unsigned i = 0; i < obj.timetabler->data.instructors.size(); i++) {
385  obj.instructorValues.push_back(i);
386  }
387  } else if (obj.fieldType == FieldValuesType::COURSE) {
388  for (unsigned i = 0; i < obj.timetabler->data.courses.size(); i++) {
389  obj.courseValues.push_back(i);
390  }
391  } else if (obj.fieldType == FieldValuesType::SEGMENT) {
392  for (unsigned i = 0; i < obj.timetabler->data.segments.size(); i++) {
393  obj.segmentValues.push_back(i);
394  }
395  } else if (obj.fieldType == FieldValuesType::PROGRAM) {
396  for (unsigned i = 0; i < obj.timetabler->data.programs.size(); i++) {
397  obj.programValues.push_back(i);
398  }
399  } else if (obj.fieldType == FieldValuesType::ISMINOR) {
400  for (unsigned i = 0; i < obj.timetabler->data.isMinors.size(); i++) {
401  obj.isMinorValues.push_back(i);
402  }
403  } else if (obj.fieldType == FieldValuesType::CLASSROOM) {
404  for (unsigned i = 0; i < obj.timetabler->data.classrooms.size(); i++) {
405  obj.classValues.push_back(i);
406  }
407  } else if (obj.fieldType == FieldValuesType::SLOT) {
408  for (unsigned i = 0; i < obj.timetabler->data.slots.size(); i++) {
409  obj.slotValues.push_back(i);
410  }
411  }
412  }
413 };
414 
419 struct sameval : pegtl::pad<TAO_PEGTL_KEYWORD("SAME"), pegtl::space> {};
420 template <>
421 struct action<sameval> {
422  template <typename Input>
423  static void apply(const Input &in, Object &obj) {
424  if (obj.fieldType == FieldValuesType::CLASSROOM) {
425  obj.classSame = true;
426  } else if (obj.fieldType == FieldValuesType::SLOT) {
427  obj.slotSame = true;
428  }
429  }
430 };
431 
436 struct notsameval : pegtl::pad<TAO_PEGTL_KEYWORD("NOTSAME"), pegtl::space> {};
437 template <>
439  template <typename Input>
440  static void apply(const Input &in, Object &obj) {
441  if (obj.fieldType == FieldValuesType::CLASSROOM) {
442  obj.classNotSame = true;
443  } else if (obj.fieldType == FieldValuesType::SLOT) {
444  obj.slotNotSame = true;
445  }
446  }
447 };
448 
453  : pegtl::seq<pegtl::pad<pegtl::one<'{'>, pegtl::space>,
454  pegtl::list<value, pegtl::one<','>, pegtl::space>,
455  pegtl::pad<pegtl::one<'}'>, pegtl::space>> {};
456 
460 struct values : pegtl::sor<allvalues, listvalues, sameval, notsameval> {};
461 
466  : pegtl::seq<pegtl::pad<classroomstr, pegtl::space>, values> {};
467 
471 struct slotdecl : pegtl::seq<pegtl::pad<slotstr, pegtl::space>, values> {};
472 
477  : pegtl::seq<pegtl::pad<coursestr, pegtl::space>, values> {};
478 template <>
480  template <typename Input>
481  static void apply(const Input &in, Object &obj) {
482  obj.courseExcept = false;
483  }
484 };
485 
490  : pegtl::seq<pegtl::pad<coursestr, pegtl::space>,
491  pegtl::pad<exceptstr, pegtl::space>, values> {};
492 template <>
494  template <typename Input>
495  static void apply(const Input &in, Object &obj) {
496  obj.courseExcept = true;
497  }
498 };
499 
503 struct coursedecl : pegtl::sor<coursenoexceptdecl, courseexceptdecl> {};
504 template <>
506  template <typename Input>
507  static void apply(const Input &in, Object &obj) {
508  obj.isNot = false;
509  }
510 };
511 
515 struct decl : pegtl::sor<slotdecl, classroomdecl> {};
516 
520 struct decls : pegtl::list<decl, andstr, pegtl::space> {};
521 
525 struct fielddecl : pegtl::seq<pegtl::pad<fieldtype, pegtl::space>, values> {};
526 
530 struct fielddecls : pegtl::opt<pegtl::list<fielddecl, andstr, pegtl::space>> {};
531 
535 struct constraint_expr : pegtl::seq<coursedecl, fielddecls, pegtl::opt<notstr>,
536  pegtl::pad<instr, pegtl::space>, decls> {};
537 template <>
539  template <typename Input>
540  static void apply(const Input &in, Object &obj) {
541  Clauses clauses;
542  if (obj.courseExcept) {
543  std::vector<int> courseVals;
544  for (unsigned i = 0; i < obj.timetabler->data.courses.size(); i++) {
545  if (std::find(obj.courseValues.begin(), obj.courseValues.end(), i) ==
546  obj.courseValues.end()) {
547  courseVals.push_back(i);
548  }
549  }
550  obj.courseValues = courseVals;
551  }
552  for (unsigned i = 0; i < obj.courseValues.size(); i++) {
553  int course = obj.courseValues[i];
554  Clauses ante, cons, clause;
555  ante = makeAntecedent(obj, course);
556  cons = makeConsequent(obj, course, i);
557  if (obj.isNot) {
558  cons = ~cons;
559  }
560  clause = ante >> cons;
561  clauses = clauses & clause;
562  }
563  obj.constraint = clauses;
564  obj.courseValues.clear();
565  obj.instructorValues.clear();
566  obj.isMinorValues.clear();
567  obj.programValues.clear();
568  obj.segmentValues.clear();
569  obj.classValues.clear();
570  obj.slotValues.clear();
571  obj.isNot = false;
572  obj.classSame = false;
573  obj.slotSame = false;
574  obj.classNotSame = false;
575  obj.slotNotSame = false;
576  }
577 };
578 
579 struct constraint_or;
580 
585  : pegtl::seq<pegtl::if_must<pegtl::pad<pegtl::one<'('>, pegtl::space>,
586  constraint_or,
587  pegtl::pad<pegtl::one<')'>, pegtl::space>>> {};
588 
593  : pegtl::seq<pegtl::pad<notstr, pegtl::space>, constraint_braced> {};
594 template <>
596  template <typename Input>
597  static void apply(const Input &in, Object &obj) {
598  Clauses clauses = obj.constraint;
599  obj.constraint = ~clauses;
600  }
601 };
602 
608  : pegtl::sor<constraint_expr, constraint_not, constraint_braced> {};
609 template <>
611  template <typename Input>
612  static void apply(const Input &in, Object &obj) {
613  obj.constraintVals.push_back(obj.constraint);
614  }
615 };
616 
621 struct constraint_and : pegtl::list<constraint_val, andstr, pegtl::space> {};
622 template <>
624  template <typename Input>
625  static void apply(const Input &in, Object &obj) {
626  Clauses clauses = obj.constraintVals[0];
627  for (unsigned i = 1; i < obj.constraintVals.size(); i++) {
628  clauses = clauses & obj.constraintVals[i];
629  }
630  obj.constraintVals.clear();
631  obj.constraintAnds.push_back(clauses);
632  }
633 };
634 
639 struct constraint_or : pegtl::list<constraint_and, orstr, pegtl::space> {};
640 template <>
642  template <typename Input>
643  static void apply(const Input &in, Object &obj) {
644  Clauses clauses = obj.constraintAnds[0];
645  for (unsigned i = 1; i < obj.constraintAnds.size(); i++) {
646  clauses = clauses | obj.constraintAnds[i];
647  }
648  obj.constraintAnds.clear();
649  obj.constraint = clauses;
650  }
651 };
652 
657  : pegtl::seq<coursedecl, pegtl::pad<unbundlestr, pegtl::space>, fielddecls,
658  pegtl::opt<notstr>, pegtl::pad<instr, pegtl::space>, decl,
659  pegtl::pad<weightstr, pegtl::space>,
660  pegtl::pad<integer, pegtl::space>> {};
661 template <>
663  template <typename Input>
664  static void apply(const Input &in, Object &obj) {
665  if (obj.courseExcept) {
666  std::vector<int> courseVals;
667  for (unsigned i = 0; i < obj.timetabler->data.courses.size(); i++) {
668  if (std::find(obj.courseValues.begin(), obj.courseValues.end(), i) ==
669  obj.courseValues.end()) {
670  courseVals.push_back(i);
671  }
672  }
673  obj.courseValues = courseVals;
674  }
675  for (unsigned i = 0; i < obj.courseValues.size(); i++) {
676  int course = obj.courseValues[i];
677  Clauses ante, cons, clause;
678  ante = makeAntecedent(obj, course);
679  cons = makeConsequent(obj, course, i);
680  if (obj.isNot) {
681  cons = ~cons;
682  }
683  clause = ante >> cons;
684  obj.constraint = clause;
685  obj.timetabler->data.customConstraintVars.push_back(
686  obj.timetabler->newVar());
687  int index = obj.timetabler->data.customConstraintVars.size() - 1;
688  if (obj.integer != 0) {
689  Clauses hardConsequent =
690  CClause(obj.timetabler->data.customConstraintVars[index]) >>
691  obj.constraint;
692  obj.timetabler->addClauses(hardConsequent, -1);
693  }
694  obj.timetabler->data.customMap[index] = course;
695  obj.timetabler->addHighLevelCustomConstraintClauses(index, obj.integer);
696  }
697  obj.courseValues.clear();
698  obj.instructorValues.clear();
699  obj.isMinorValues.clear();
700  obj.programValues.clear();
701  obj.segmentValues.clear();
702  obj.classValues.clear();
703  obj.slotValues.clear();
704  obj.isNot = false;
705  obj.classSame = false;
706  obj.slotSame = false;
707  obj.classNotSame = false;
708  obj.slotNotSame = false;
709  }
710 };
711 
716 struct wconstraint : pegtl::seq<pegtl::pad<constraint_or, pegtl::space>,
717  pegtl::pad<weightstr, pegtl::space>,
718  pegtl::pad<integer, pegtl::space>> {};
719 template <>
721  template <typename Input>
722  static void apply(const Input &in, Object &obj) {
723  obj.timetabler->data.customConstraintVars.push_back(
724  obj.timetabler->newVar());
725  int index = obj.timetabler->data.customConstraintVars.size() - 1;
726  if (obj.integer != 0) {
727  Clauses hardConsequent =
728  CClause(obj.timetabler->data.customConstraintVars[index]) >>
729  obj.constraint;
730  obj.timetabler->addClauses(hardConsequent, -1);
731  }
732  obj.timetabler->addHighLevelCustomConstraintClauses(index, obj.integer);
733  }
734 };
735 
739 struct grammar
740  : pegtl::try_catch<
741  pegtl::must<pegtl::star<pegtl::sor<wconstraint, constraint_unbundle>>,
742  pegtl::eof>> {};
743 
744 template <typename Rule>
745 struct control : pegtl::normal<Rule> {
746  template <typename Input, typename... States>
747  static void raise(const Input &in, States &&...) {
748  LOG(ERROR) << in.position() << " Error parsing custom constraints";
749  }
750 };
751 
752 } // namespace custom_constraint_grammar
753 
762 void parseCustomConstraints(std::string file,
763  ConstraintEncoder *constraintEncoder,
765  Object obj;
766  obj.constraintEncoder = constraintEncoder;
767  obj.timetabler = timetabler;
768  pegtl::file_input<> in(file);
772 }
773 
778  isNot = false;
779  classSame = false;
780  slotSame = false;
781  classNotSame = false;
782  slotNotSame = false;
783 }
Parse "NOTSAME": Used to specify constraints on courses with different field values.
Parse disjunction of constraints The combined clauses for all the constraints are stored in obj...
Parse "SEGMENT": Similar to classroom.
Parse "SAME": Used to specify constraints on courses with same field values.
Parse "NOT": Store that NOT keyword is present in the custom constraint.
Parse courses declaration without except keyword.
Class for representing a clause.
Definition: cclause.h:21
void addHighLevelCustomConstraintClauses(int, int)
Adds high level custom constraint clauses.
Definition: timetabler.cpp:105
Parse a constraint with unbundle keyword.
Object()
Initialize object members.
std::vector< Segment > segments
Definition: data.h:52
Clauses hasSameFieldTypeAndValue(int, int, FieldType)
Gives Clauses that represent that a pair of courses have the same field value for a given FieldType...
Constraint is on one of the instructor, segment, isminor, program. isNot, classSame, slotSame, classNotSame, slotNotSame are reset.
std::vector< Classroom > classrooms
Definition: data.h:44
Parse integer: Store the integer in the object.
std::vector< Slot > slots
Definition: data.h:56
Parse "SLOT": Similar to classroom.
std::vector< Var > customConstraintVars
Definition: data.h:89
std::vector< IsMinor > isMinors
Definition: data.h:60
Parse a value of the field that is specified in the constraint.
Class for time tabler.
Definition: timetabler.h:44
Parse multi decls in consequent of the constraint.
std::vector< Instructor > instructors
Definition: data.h:40
Class for constraint encoder.
Struct for the type used by actions in the parser.
Definition: custom_parser.h:27
Clauses hasFieldTypeListedValues(int, FieldType, std::vector< int >)
Gives Clauses that represent that a Course has a field value for a given FieldType out of a list of p...
Timetabler * timetabler
Definition: main.cpp:90
Parse courses declaration with except keyword.
Parse single decl in consequent of the constraint.
Parse constraint enclosed in braces.
Parse * as all values of the specified field.
Parse "PROGRAM": Similar to classroom.
Parse multi field decls in antecedent of the constraint.
Parse "INSTRUCTOR": Similar to classroom.
std::map< int, unsigned > customMap
Definition: data.h:128
Parse list of values of a field specified in the constraint.
std::vector< Course > courses
Definition: data.h:36
Parse "CLASSROOM": Store the field type to be classroom which will be used while forming the custom c...
Parse a constraint: Constraint expression or negation of some constraint expression or a constraint e...
Parse conjunction of constraints Add all the constraints to obj.constraintAdds.
Class for representing a set of clauses.
Definition: clauses.h:23
Parse "ISMNOR": Similar to classroom.
Var newVar()
Calls the formula to issue a new variable and returns it.
Definition: timetabler.cpp:262
Parse fieldd decl in antecedent of the constraint.
Parse weighted constraint Add the clauses corresponding to the constraint along with its weight...
Parse negation of a constraint.
void parseCustomConstraints(std::string file, ConstraintEncoder *constraintEncoder, Timetabler *timetabler)
Parses custom constraints given in a file and adds them to the solver.
void addClauses(const std::vector< CClause > &, int)
Adds clauses to the solver with specified weights.
Definition: timetabler.cpp:35
Data data
Definition: timetabler.h:63
std::vector< Program > programs
Definition: data.h:48
Parse "COURSE": Similar to classroom.
Parse constraints from the file, generate error on failure.