Go to the documentation of this file.
   13 #include <boost/tokenizer.hpp> 
   24     : maxNrStudents_(maxNrStudents) {
 
   25   typedef boost::tokenizer<boost::escaped_list_separator<char> > Tokenizer;
 
   30     cerr << 
"Scheduler: could not open file " << 
filename << endl;
 
   31     throw runtime_error(
"Scheduler: could not open file " + 
filename);
 
   37   if (getline(is, line, 
'\r')) {
 
   39     Tokenizer::iterator it = tok.begin();
 
   40     for (++it; it != tok.end(); ++it) 
addFaculty(*it);
 
   45   while (getline(is, line, 
'\r')) {
 
   46     if (count++ > 100) 
throw runtime_error(
"reached 100 lines, exiting");
 
   48     Tokenizer::iterator it = tok.begin();
 
   51     for (; it != tok.end(); ++it) 
available_ += (it->empty()) ? 
"0 " : 
"1 ";
 
   58                            const string& area2, 
const string& area3,
 
   59                            const string& advisor) {
 
   83                                   std::optional<size_t> area)
 const {
 
  104                                               std::optional<size_t> slot) {
 
  111     if (
debug) cout << 
"Adding availability of slots" << endl;
 
  117   for (
size_t area = 0; area < 3; area++) {
 
  119     const string& areaName = 
s.areaName_[area];
 
  121     if (
debug) cout << 
"Area constraints " << areaName << endl;
 
  125     if (
debug) cout << 
"Advisor constraint " << areaName << endl;
 
  126     assert(
s.advisor_.size() == areaKey.second);
 
  129     if (
debug) cout << 
"Availability of faculty " << areaName << endl;
 
  136       auto q = 
p.choose(dummyIndex, *slot);
 
  145   if (
debug) cout << 
"Mutex for faculty" << endl;
 
  153   if (
debug) cout << 
"Adding student-specific constraints" << endl;
 
  165     if (
debug) cout << 
"Mutex for Students" << endl;
 
  169       for (
size_t i2 = 
i1 + 1; i2 < 
bound; i2++) {
 
  178   cout << 
s << 
" Faculty:" << endl;
 
  182   cout << 
s << 
" Slots:\n";
 
  187   cout << 
"Availability:\n" << 
available_ << 
'\n';
 
  189   cout << 
s << 
" Area constraints:\n";
 
  191     cout << setw(12) << it.first << 
": ";
 
  192     for (
double v : it.second) cout << 
v << 
" ";
 
  197   cout << 
s << 
" Students:\n";
 
  211     size_t slot = assignment.at(
j);
 
  214     for (
size_t area = 0; area < 3; area++) {
 
  215       size_t faculty = assignment.at(
base + area);
 
  225   DiscreteValues::const_iterator it = assignment.begin();
 
  226   for (
size_t area = 0; area < 3; area++, it++) {
 
  227     size_t f = it->second;
 
  235                                 vector<size_t>& 
stats)
 const {
 
  238     for (
size_t area = 0; area < 3; area++) {
 
  239       size_t f = assignment.at(
base + area);
 
  252   for (
size_t i = 0; 
i < 
maxKey; ++
i) defaultKeyOrdering.push_back(
i);
 
  262   throw runtime_error(
"bestSchedule not implemented");
 
  269   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 Wed May 28 2025 03:03:01