Go to the documentation of this file.
13 #include <boost/tokenizer.hpp>
23 : maxNrStudents_(maxNrStudents) {
24 typedef boost::tokenizer<boost::escaped_list_separator<char> > Tokenizer;
29 cerr <<
"Scheduler: could not open file " <<
filename << endl;
30 throw runtime_error(
"Scheduler: could not open file " +
filename);
36 if (getline(is, line,
'\r')) {
38 Tokenizer::iterator it = tok.begin();
39 for (++it; it != tok.end(); ++it)
addFaculty(*it);
44 while (getline(is, line,
'\r')) {
45 if (count++ > 100)
throw runtime_error(
"reached 100 lines, exiting");
47 Tokenizer::iterator it = tok.begin();
50 for (; it != tok.end(); ++it)
available_ += (it->empty()) ?
"0 " :
"1 ";
57 const string& area2,
const string& area3,
58 const string& advisor) {
82 std::optional<size_t> area)
const {
103 std::optional<size_t> slot) {
110 if (
debug) cout <<
"Adding availability of slots" << endl;
116 for (
size_t area = 0; area < 3; area++) {
118 const string& areaName =
s.areaName_[area];
120 if (
debug) cout <<
"Area constraints " << areaName << endl;
124 if (
debug) cout <<
"Advisor constraint " << areaName << endl;
125 assert(
s.advisor_.size() == areaKey.second);
128 if (
debug) cout <<
"Availability of faculty " << areaName << endl;
135 auto q =
p.choose(dummyIndex, *slot);
144 if (
debug) cout <<
"Mutex for faculty" << endl;
152 if (
debug) cout <<
"Adding student-specific constraints" << endl;
164 if (
debug) cout <<
"Mutex for Students" << endl;
168 for (
size_t i2 =
i1 + 1; i2 <
bound; i2++) {
177 cout <<
s <<
" Faculty:" << endl;
181 cout <<
s <<
" Slots:\n";
186 cout <<
"Availability:\n" <<
available_ <<
'\n';
188 cout <<
s <<
" Area constraints:\n";
190 cout << setw(12) << it.first <<
": ";
191 for (
double v : it.second) cout <<
v <<
" ";
196 cout <<
s <<
" Students:\n";
210 size_t slot = assignment.at(
j);
213 for (
size_t area = 0; area < 3; area++) {
214 size_t faculty = assignment.at(
base + area);
224 DiscreteValues::const_iterator it = assignment.begin();
225 for (
size_t area = 0; area < 3; area++, it++) {
226 size_t f = it->second;
234 vector<size_t>&
stats)
const {
237 for (
size_t area = 0; area < 3; area++) {
238 size_t f = assignment.at(
base + area);
251 for (
size_t i = 0;
i <
maxKey; ++
i) defaultKeyOrdering.push_back(
i);
261 throw runtime_error(
"bestSchedule not implemented");
268 throw runtime_error(
"bestAssignment not implemented");
std::shared_ptr< BayesNetType > eliminateSequential(OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
void addFaculty(const std::string &facultyName)
Annotation for function names.
Annotation indicating that a class derives from another given type.
FacultyInArea facultyInArea_
double bound(double a, double min, double max)
std::vector< std::string > slotName_
Key maxKey(const PROBLEM &problem)
std::vector< DiscreteKey > keys_
void accumulateStats(const DiscreteValues &assignment, std::vector< size_t > &stats) const
const KeyFormatter & formatter
DiscreteKeys is a set of keys that can be assembled using the & operator.
void print(const std::string &s="DiscreteFactorGraph", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print
std::vector< Student > students_
void printSpecial(const DiscreteValues &assignment) const
std::vector< std::string > areaName_
DiscreteValues bestSchedule() const
void addSlot(const std::string &slotName)
void addStudentSpecificConstraints(size_t i, std::optional< size_t > slot={})
EIGEN_DEVICE_FUNC const Scalar & q
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
const std::string & studentArea(size_t i, size_t area) const
static constexpr bool debug
void addAllDiff(const DiscreteKey &key1, const DiscreteKey &key2)
Add a binary AllDiff constraint.
DiscreteBayesNet::shared_ptr eliminate() const
std::vector< std::string > facultyName_
std::vector< double > slotsAvailable_
std::map< std::string, size_t > facultyIndex_
void printAssignment(const DiscreteValues &assignment) const
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Scheduler(size_t maxNrStudents)
std::pair< Key, size_t > DiscreteKey
DiscreteValues bestAssignment(const DiscreteValues &bestSchedule) const
size_t nrStudents() const
current number of students
void add(Args &&... args)
Array< int, Dynamic, 1 > v
std::shared_ptr< This > shared_ptr
void print(const std::string &s="Scheduler", const KeyFormatter &formatter=DefaultKeyFormatter) const override
const std::string & studentName(size_t i) const
void buildGraph(size_t mutexBound=7)
const DiscreteKey & key(size_t s, std::optional< size_t > area={}) const
std::uint64_t Key
Integer nonlinear key type.
void addStudent(const std::string &studentName, const std::string &area1, const std::string &area2, const std::string &area3, const std::string &advisor)
const DiscreteKey & studentKey(size_t i) const
size_t nrTimeSlots() const
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:04:02