10#include <gtsam_unstable/discrete/CSP.h>
27 std::vector<DiscreteKey> keys_;
28 std::vector<std::string> areaName_;
29 std::vector<double> advisor_;
30 Student(
size_t nrFaculty,
size_t advisorIndex)
31 : keys_(3), areaName_(3), advisor_(nrFaculty, 1.0) {
32 advisor_[advisorIndex] = 0.0;
36 cout << name_ <<
": ";
37 for (
size_t area = 0; area < 3; area++) cout << areaName_[area] <<
" ";
43 size_t maxNrStudents_;
46 std::vector<Student> students_;
49 std::map<std::string, size_t> facultyIndex_;
50 std::vector<std::string> facultyName_, slotName_, areaName_;
53 typedef std::map<std::string, std::vector<double> > FacultyInArea;
54 FacultyInArea facultyInArea_;
57 std::string available_;
60 std::vector<double> slotsAvailable_;
68 Scheduler(
size_t maxNrStudents) : maxNrStudents_(maxNrStudents) {}
73 void addFaculty(
const std::string& facultyName) {
74 facultyIndex_[facultyName] = nrFaculty();
75 facultyName_.push_back(facultyName);
78 size_t nrFaculty()
const {
return facultyName_.size(); }
83 void addSlot(
const std::string& slotName) { slotName_.push_back(slotName); }
85 size_t nrTimeSlots()
const {
return slotName_.size(); }
87 const std::string& slotName(
size_t s)
const {
return slotName_[s]; }
91 slotsAvailable_ = slotsAvailable;
94 void addArea(
const std::string& facultyName,
const std::string& areaName) {
95 areaName_.push_back(areaName);
96 std::vector<double>& table =
97 facultyInArea_[areaName];
98 if (table.empty()) table.resize(nrFaculty(), 0);
99 table[facultyIndex_[facultyName]] = 1;
106 Scheduler(
size_t maxNrStudents,
const std::string& filename);
110 boost::optional<size_t> area = boost::none)
const;
113 void addStudent(
const std::string& studentName,
const std::string& area1,
114 const std::string& area2,
const std::string& area3,
115 const std::string& advisor);
120 const std::string& studentName(
size_t i)
const;
122 const std::string& studentArea(
size_t i,
size_t area)
const;
125 void addStudentSpecificConstraints(
126 size_t i, boost::optional<size_t> slot = boost::none);
129 void buildGraph(
size_t mutexBound = 7);
133 const std::string& s =
"Scheduler",
134 const KeyFormatter& formatter = DefaultKeyFormatter)
const override;
137 void printAssignment(sharedValues assignment)
const;
140 void printSpecial(sharedValues assignment)
const;
143 void accumulateStats(sharedValues assignment,
144 std::vector<size_t>& stats)
const;
147 DiscreteBayesNet::shared_ptr eliminate()
const;
150 sharedValues optimalAssignment()
const;
153 sharedValues bestSchedule()
const;
156 sharedValues bestAssignment(sharedValues bestSchedule)
const;
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:155
std::pair< Key, size_t > DiscreteKey
Key type for discrete conditionals Includes name and cardinality.
Definition: DiscreteKey.h:34
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:35
Constraint Satisfaction Problem class A specialization of a DiscreteFactorGraph.
Definition: CSP.h:21
Scheduler class Creates one variable for each student, and three variables for each of the student's ...
Definition: Scheduler.h:21
void setSlotsAvailable(const std::vector< double > &slotsAvailable)
slots available, boolean
Definition: Scheduler.h:90
Scheduler(size_t maxNrStudents)
Constructor We need to know the number of students in advance for ordering keys.
Definition: Scheduler.h:68
size_t nrStudents() const
current number of students
Definition: Scheduler.h:118
void setAvailability(const std::string &available)
boolean std::string of nrTimeSlots * nrFaculty
Definition: Scheduler.h:81
virtual ~Scheduler()
Destructor.
Definition: Scheduler.h:71