10 #include <gtsam_unstable/discrete/CSP.h> 29 std::vector<DiscreteKey> keys_;
30 std::vector<std::string> areaName_;
31 std::vector<double> advisor_;
32 Student(
size_t nrFaculty,
size_t advisorIndex) :
33 keys_(3), areaName_(3), advisor_(nrFaculty, 1.0) {
34 advisor_[advisorIndex] = 0.0;
38 cout << name_ <<
": ";
39 for (
size_t area = 0; area < 3; area++)
40 cout << areaName_[area] <<
" ";
46 size_t maxNrStudents_;
49 std::vector<Student> students_;
52 std::map<std::string, size_t> facultyIndex_;
53 std::vector<std::string> facultyName_, slotName_, areaName_;
56 typedef std::map<std::string, std::vector<double> > FacultyInArea;
57 FacultyInArea facultyInArea_;
60 std::string available_;
63 std::vector<double> slotsAvailable_;
72 Scheduler(
size_t maxNrStudents):maxNrStudents_(maxNrStudents) {
75 void addFaculty(
const std::string& facultyName) {
76 facultyIndex_[facultyName] = nrFaculty();
77 facultyName_.push_back(facultyName);
80 size_t nrFaculty()
const {
81 return facultyName_.size();
86 available_ = available;
89 void addSlot(
const std::string& slotName) {
90 slotName_.push_back(slotName);
93 size_t nrTimeSlots()
const {
94 return slotName_.size();
97 const std::string& slotName(
size_t s)
const {
103 slotsAvailable_ = slotsAvailable;
106 void addArea(
const std::string& facultyName,
const std::string& areaName) {
107 areaName_.push_back(areaName);
108 std::vector<double>& table = facultyInArea_[areaName];
109 if (table.empty()) table.resize(nrFaculty(), 0);
110 table[facultyIndex_[facultyName]] = 1;
117 Scheduler(
size_t maxNrStudents,
const std::string& filename);
120 const DiscreteKey& key(
size_t s, boost::optional<size_t> area = boost::none)
const;
123 void addStudent(
const std::string& studentName,
const std::string& area1,
124 const std::string& area2,
const std::string& area3,
125 const std::string& advisor);
129 return students_.size();
132 const std::string& studentName(
size_t i)
const;
134 const std::string& studentArea(
size_t i,
size_t area)
const;
137 void addStudentSpecificConstraints(
size_t i, boost::optional<size_t> slot = boost::none);
140 void buildGraph(
size_t mutexBound = 7);
143 void print(
const std::string& s =
"Scheduler")
const;
146 void printAssignment(sharedValues assignment)
const;
149 void printSpecial(sharedValues assignment)
const;
152 void accumulateStats(sharedValues assignment,
153 std::vector<size_t>& stats)
const;
156 DiscreteBayesNet::shared_ptr eliminate()
const;
159 sharedValues optimalAssignment()
const;
162 sharedValues bestSchedule()
const;
165 sharedValues bestAssignment(sharedValues bestSchedule)
const;
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:141
size_t nrStudents() const
current number of students
Definition: Scheduler.h:128
void setAvailability(const std::string &available)
boolean std::string of nrTimeSlots * nrFaculty
Definition: Scheduler.h:85
Constraint Satisfaction Problem class A specialization of a DiscreteFactorGraph.
Definition: CSP.h:21
Scheduler(size_t maxNrStudents)
Constructor WE need to know the number of students in advance for ordering keys.
Definition: Scheduler.h:72
void setSlotsAvailable(const std::vector< double > &slotsAvailable)
slots available, boolean
Definition: Scheduler.h:102
std::pair< Key, size_t > DiscreteKey
Key type for discrete conditionals Includes name and cardinality.
Definition: DiscreteKey.h:34
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Scheduler class Creates one variable for each student, and three variables for each of the student's ...
Definition: Scheduler.h:21