Classes | Public Member Functions | Private Types | Private Attributes | List of all members
gtsam::Scheduler Class Reference

#include <Scheduler.h>

Inheritance diagram for gtsam::Scheduler:
Inheritance graph
[legend]

Classes

struct  Student
 

Public Member Functions

void accumulateStats (const DiscreteValues &assignment, std::vector< size_t > &stats) const
 
void addArea (const std::string &facultyName, const std::string &areaName)
 
void addFaculty (const std::string &facultyName)
 
void addSlot (const std::string &slotName)
 
void addStudent (const std::string &studentName, const std::string &area1, const std::string &area2, const std::string &area3, const std::string &advisor)
 
void addStudentSpecificConstraints (size_t i, std::optional< size_t > slot={})
 
DiscreteValues bestAssignment (const DiscreteValues &bestSchedule) const
 
DiscreteValues bestSchedule () const
 
void buildGraph (size_t mutexBound=7)
 
DiscreteBayesNet::shared_ptr eliminate () const
 
const DiscreteKeykey (size_t s, std::optional< size_t > area={}) const
 
size_t nrFaculty () const
 
size_t nrStudents () const
 current number of students More...
 
size_t nrTimeSlots () const
 
void print (const std::string &s="Scheduler", const KeyFormatter &formatter=DefaultKeyFormatter) const override
 
void printAssignment (const DiscreteValues &assignment) const
 
void printSpecial (const DiscreteValues &assignment) const
 
 Scheduler (size_t maxNrStudents)
 
 Scheduler (size_t maxNrStudents, const std::string &filename)
 
void setAvailability (const std::string &available)
 
void setSlotsAvailable (const std::vector< double > &slotsAvailable)
 
const std::string & slotName (size_t s) const
 
const std::string & studentArea (size_t i, size_t area) const
 
const DiscreteKeystudentKey (size_t i) const
 
const std::string & studentName (size_t i) const
 
virtual ~Scheduler ()
 Destructor. More...
 
- Public Member Functions inherited from gtsam::CSP
void addAllDiff (const DiscreteKey &key1, const DiscreteKey &key2)
 Add a binary AllDiff constraint. More...
 
void addAllDiff (const DiscreteKeys &dkeys)
 Add a general AllDiff constraint. More...
 
void addSingleValue (const DiscreteKey &dkey, size_t value)
 Add a unary constraint, allowing only a single value. More...
 
CSP partiallyApply (const Domains &domains) const
 
Domains runArcConsistency (size_t cardinality, size_t maxIterations=10) const
 
bool runArcConsistency (const VariableIndex &index, Domains *domains) const
 Run arc consistency for all variables, return true if any domain changed. More...
 
- Public Member Functions inherited from gtsam::DiscreteFactorGraph
template<typename... Args>
void add (Args &&... args)
 
 DiscreteFactorGraph ()
 

map from keys to values

More...
 
template<typename ITERATOR >
 DiscreteFactorGraph (ITERATOR firstFactor, ITERATOR lastFactor)
 
template<class CONTAINER >
 DiscreteFactorGraph (const CONTAINER &factors)
 
template<class DERIVEDFACTOR >
 DiscreteFactorGraph (const FactorGraph< DERIVEDFACTOR > &graph)
 
DiscreteKeys discreteKeys () const
 Return the DiscreteKeys in this factor graph. More...
 
KeySet keys () const
 
DiscreteLookupDAG maxProduct (OptionalOrderingType orderingType={}) const
 Implement the max-product algorithm. More...
 
DiscreteLookupDAG maxProduct (const Ordering &ordering) const
 Implement the max-product algorithm. More...
 
double operator() (const DiscreteValues &values) const
 
DiscreteValues optimize (OptionalOrderingType orderingType={}) const
 Find the maximum probable explanation (MPE) by doing max-product. More...
 
DiscreteValues optimize (const Ordering &ordering) const
 Find the maximum probable explanation (MPE) by doing max-product. More...
 
DecisionTreeFactor product () const
 
DiscreteBayesNet sumProduct (OptionalOrderingType orderingType={}) const
 Implement the sum-product algorithm. More...
 
DiscreteBayesNet sumProduct (const Ordering &ordering) const
 Implement the sum-product algorithm. More...
 
bool equals (const This &fg, double tol=1e-9) const
 
std::string markdown (const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DiscreteFactor::Names &names={}) const
 Render as markdown tables. More...
 
std::string html (const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DiscreteFactor::Names &names={}) const
 Render as html tables. More...
 
- Public Member Functions inherited from gtsam::FactorGraph< DiscreteFactor >
 FactorGraph (std::initializer_list< std::shared_ptr< DERIVEDFACTOR >> sharedFactors)
 
virtual ~FactorGraph ()=default
 
void reserve (size_t size)
 
IsDerived< DERIVEDFACTOR > push_back (std::shared_ptr< DERIVEDFACTOR > factor)
 Add a factor directly using a shared_ptr. More...
 
IsDerived< DERIVEDFACTOR > push_back (const DERIVEDFACTOR &factor)
 
IsDerived< DERIVEDFACTOR > emplace_shared (Args &&... args)
 Emplace a shared pointer to factor of given type. More...
 
IsDerived< DERIVEDFACTOR > add (std::shared_ptr< DERIVEDFACTOR > factor)
 add is a synonym for push_back. More...
 
HasDerivedElementType< ITERATOR > push_back (ITERATOR firstFactor, ITERATOR lastFactor)
 
HasDerivedValueType< ITERATOR > push_back (ITERATOR firstFactor, ITERATOR lastFactor)
 Push back many factors with an iterator (factors are copied) More...
 
HasDerivedElementType< CONTAINER > push_back (const CONTAINER &container)
 
HasDerivedValueType< CONTAINER > push_back (const CONTAINER &container)
 Push back non-pointer objects in a container (factors are copied). More...
 
void add (const FACTOR_OR_CONTAINER &factorOrContainer)
 
std::enable_if< std::is_base_of< This, typename CLIQUE::FactorGraphType >::value >::type push_back (const BayesTree< CLIQUE > &bayesTree)
 
FactorIndices add_factors (const CONTAINER &factors, bool useEmptySlots=false)
 
bool equals (const This &fg, double tol=1e-9) const
 Check equality up to tolerance. More...
 
size_t size () const
 
bool empty () const
 
const sharedFactor at (size_t i) const
 
sharedFactorat (size_t i)
 
const sharedFactor operator[] (size_t i) const
 
sharedFactoroperator[] (size_t i)
 
const_iterator begin () const
 
const_iterator end () const
 
sharedFactor front () const
 
sharedFactor back () const
 
double error (const HybridValues &values) const
 
iterator begin ()
 
iterator end ()
 
virtual void resize (size_t size)
 
void remove (size_t i)
 
void replace (size_t index, sharedFactor factor)
 
iterator erase (iterator item)
 
iterator erase (iterator first, iterator last)
 
void dot (std::ostream &os, const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DotWriter &writer=DotWriter()) const
 Output to graphviz format, stream version. More...
 
std::string dot (const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DotWriter &writer=DotWriter()) const
 Output to graphviz format string. More...
 
void saveGraph (const std::string &filename, const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DotWriter &writer=DotWriter()) const
 output to file with graphviz format. More...
 
size_t nrFactors () const
 
KeySet keys () const
 
KeyVector keyVector () const
 
bool exists (size_t idx) const
 
- Public Member Functions inherited from gtsam::EliminateableFactorGraph< DiscreteFactorGraph >
std::shared_ptr< BayesTreeTypeeliminateMultifrontal (OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesTreeTypeeliminateMultifrontal (const Ordering &ordering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::pair< std::shared_ptr< BayesTreeType >, std::shared_ptr< FactorGraphType > > eliminatePartialMultifrontal (const Ordering &ordering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::pair< std::shared_ptr< BayesTreeType >, std::shared_ptr< FactorGraphType > > eliminatePartialMultifrontal (const KeyVector &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::pair< std::shared_ptr< BayesNetType >, std::shared_ptr< FactorGraphType > > eliminatePartialSequential (const Ordering &ordering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::pair< std::shared_ptr< BayesNetType >, std::shared_ptr< FactorGraphType > > eliminatePartialSequential (const KeyVector &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesNetTypeeliminateSequential (OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesNetTypeeliminateSequential (const Ordering &ordering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< FactorGraphTypemarginal (const KeyVector &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesNetTypemarginalMultifrontalBayesNet (const Ordering &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesNetTypemarginalMultifrontalBayesNet (const KeyVector &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesNetTypemarginalMultifrontalBayesNet (const Ordering &variables, const Ordering &marginalizedVariableOrdering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesNetTypemarginalMultifrontalBayesNet (const KeyVector &variables, const Ordering &marginalizedVariableOrdering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesTreeTypemarginalMultifrontalBayesTree (const Ordering &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesTreeTypemarginalMultifrontalBayesTree (const KeyVector &variables, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesTreeTypemarginalMultifrontalBayesTree (const Ordering &variables, const Ordering &marginalizedVariableOrdering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 
std::shared_ptr< BayesTreeTypemarginalMultifrontalBayesTree (const KeyVector &variables, const Ordering &marginalizedVariableOrdering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
 

Private Types

typedef std::map< std::string, std::vector< double > > FacultyInArea
 

Private Attributes

std::vector< std::string > areaName_
 
std::string available_
 
FacultyInArea facultyInArea_
 
std::map< std::string, size_tfacultyIndex_
 
std::vector< std::string > facultyName_
 
size_t maxNrStudents_
 
std::vector< std::string > slotName_
 
std::vector< double > slotsAvailable_
 
std::vector< Studentstudents_
 

Additional Inherited Members

- Public Types inherited from gtsam::CSP
using Values = DiscreteValues
 backwards compatibility More...
 
- Public Types inherited from gtsam::DiscreteFactorGraph
using Base = FactorGraph< DiscreteFactor >
 base factor graph type More...
 
using BaseEliminateable = EliminateableFactorGraph< This >
 for elimination More...
 
using Indices = KeyVector
 
using shared_ptr = std::shared_ptr< This >
 shared_ptr to This More...
 
using This = DiscreteFactorGraph
 this class More...
 
using Values = DiscreteValues
 backwards compatibility More...
 
- Public Types inherited from gtsam::FactorGraph< DiscreteFactor >
typedef FastVector< sharedFactor >::const_iterator const_iterator
 
typedef DiscreteFactor FactorType
 factor type More...
 
typedef FastVector< sharedFactor >::iterator iterator
 
typedef std::shared_ptr< DiscreteFactorsharedFactor
 Shared pointer to a factor. More...
 
typedef sharedFactor value_type
 
- Public Types inherited from gtsam::EliminateableFactorGraph< DiscreteFactorGraph >
typedef EliminationTraitsType::BayesNetType BayesNetType
 Bayes net type produced by sequential elimination. More...
 
typedef EliminationTraitsType::BayesTreeType BayesTreeType
 Bayes tree type produced by multifrontal elimination. More...
 
typedef EliminationTraitsType::ConditionalType ConditionalType
 Conditional type stored in the Bayes net produced by elimination. More...
 
typedef std::function< EliminationResult(const FactorGraphType &, const Ordering &)> Eliminate
 The function type that does a single dense elimination step on a subgraph. More...
 
typedef std::pair< std::shared_ptr< ConditionalType >, std::shared_ptr< _FactorType > > EliminationResult
 
typedef EliminationTraits< FactorGraphTypeEliminationTraitsType
 Typedef to the specific EliminationTraits for this graph. More...
 
typedef EliminationTraitsType::EliminationTreeType EliminationTreeType
 Elimination tree type that can do sequential elimination of this graph. More...
 
typedef EliminationTraitsType::JunctionTreeType JunctionTreeType
 Junction tree type that can do multifrontal elimination of this graph. More...
 
typedef std::optional< Ordering::OrderingTypeOptionalOrderingType
 Typedef for an optional ordering type. More...
 
typedef std::optional< std::reference_wrapper< const VariableIndex > > OptionalVariableIndex
 
- Protected Member Functions inherited from gtsam::FactorGraph< DiscreteFactor >
bool isEqual (const FactorGraph &other) const
 Check exact equality of the factor pointers. Useful for derived ==. More...
 
 FactorGraph ()
 
 FactorGraph (ITERATOR firstFactor, ITERATOR lastFactor)
 
 FactorGraph (const CONTAINER &factors)
 
- Protected Attributes inherited from gtsam::FactorGraph< DiscreteFactor >
FastVector< sharedFactorfactors_
 

Detailed Description

Scheduler class Creates one variable for each student, and three variables for each of the student's areas, for a total of 4*nrStudents variables. The "student" variable will determine when the student takes the qual. The "area" variables determine which faculty are on his/her committee.

Definition at line 22 of file Scheduler.h.

Member Typedef Documentation

◆ FacultyInArea

typedef std::map<std::string, std::vector<double> > gtsam::Scheduler::FacultyInArea
private

area constraints

Definition at line 54 of file Scheduler.h.

Constructor & Destructor Documentation

◆ Scheduler() [1/2]

gtsam::Scheduler::Scheduler ( size_t  maxNrStudents)
inline

Constructor We need to know the number of students in advance for ordering keys. then add faculty, slots, areas, availability, students, in that order

Definition at line 69 of file Scheduler.h.

◆ ~Scheduler()

virtual gtsam::Scheduler::~Scheduler ( )
inlinevirtual

Destructor.

Definition at line 72 of file Scheduler.h.

◆ Scheduler() [2/2]

gtsam::Scheduler::Scheduler ( size_t  maxNrStudents,
const std::string &  filename 
)

Constructor that reads in faculty, slots, availibility. Still need to add areas and students after this

Definition at line 22 of file Scheduler.cpp.

Member Function Documentation

◆ accumulateStats()

void gtsam::Scheduler::accumulateStats ( const DiscreteValues assignment,
std::vector< size_t > &  stats 
) const

Accumulate faculty stats

Definition at line 233 of file Scheduler.cpp.

◆ addArea()

void gtsam::Scheduler::addArea ( const std::string &  facultyName,
const std::string &  areaName 
)
inline

Definition at line 95 of file Scheduler.h.

◆ addFaculty()

void gtsam::Scheduler::addFaculty ( const std::string &  facultyName)
inline

Definition at line 74 of file Scheduler.h.

◆ addSlot()

void gtsam::Scheduler::addSlot ( const std::string &  slotName)
inline

Definition at line 84 of file Scheduler.h.

◆ addStudent()

void gtsam::Scheduler::addStudent ( const std::string &  studentName,
const std::string &  area1,
const std::string &  area2,
const std::string &  area3,
const std::string &  advisor 
)

addStudent has to be called after adding slots and faculty

Definition at line 56 of file Scheduler.cpp.

◆ addStudentSpecificConstraints()

void gtsam::Scheduler::addStudentSpecificConstraints ( size_t  i,
std::optional< size_t slot = {} 
)

Add student-specific constraints to the graph

Definition at line 102 of file Scheduler.cpp.

◆ bestAssignment()

DiscreteValues gtsam::Scheduler::bestAssignment ( const DiscreteValues bestSchedule) const

find the corresponding most desirable committee assignment

Definition at line 266 of file Scheduler.cpp.

◆ bestSchedule()

DiscreteValues gtsam::Scheduler::bestSchedule ( ) const

find the assignment of students to slots with most possible committees

Definition at line 259 of file Scheduler.cpp.

◆ buildGraph()

void gtsam::Scheduler::buildGraph ( size_t  mutexBound = 7)

Main routine that builds factor graph

Definition at line 149 of file Scheduler.cpp.

◆ eliminate()

DiscreteBayesNet::shared_ptr gtsam::Scheduler::eliminate ( ) const

Eliminate, return a Bayes net

Definition at line 246 of file Scheduler.cpp.

◆ key()

const DiscreteKey & gtsam::Scheduler::key ( size_t  s,
std::optional< size_t area = {} 
) const

get key for student and area, 0 is time slot itself

Definition at line 81 of file Scheduler.cpp.

◆ nrFaculty()

size_t gtsam::Scheduler::nrFaculty ( ) const
inline

Definition at line 79 of file Scheduler.h.

◆ nrStudents()

size_t gtsam::Scheduler::nrStudents ( ) const
inline

current number of students

Definition at line 119 of file Scheduler.h.

◆ nrTimeSlots()

size_t gtsam::Scheduler::nrTimeSlots ( ) const
inline

Definition at line 86 of file Scheduler.h.

◆ print()

void gtsam::Scheduler::print ( const std::string &  s = "Scheduler",
const KeyFormatter formatter = DefaultKeyFormatter 
) const
overridevirtual

print

Reimplemented from gtsam::DiscreteFactorGraph.

Definition at line 176 of file Scheduler.cpp.

◆ printAssignment()

void gtsam::Scheduler::printAssignment ( const DiscreteValues assignment) const

Print readable form of assignment

Definition at line 205 of file Scheduler.cpp.

◆ printSpecial()

void gtsam::Scheduler::printSpecial ( const DiscreteValues assignment) const

Special print for single-student case

Definition at line 223 of file Scheduler.cpp.

◆ setAvailability()

void gtsam::Scheduler::setAvailability ( const std::string &  available)
inline

boolean std::string of nrTimeSlots * nrFaculty

Definition at line 82 of file Scheduler.h.

◆ setSlotsAvailable()

void gtsam::Scheduler::setSlotsAvailable ( const std::vector< double > &  slotsAvailable)
inline

slots available, boolean

Definition at line 91 of file Scheduler.h.

◆ slotName()

const std::string& gtsam::Scheduler::slotName ( size_t  s) const
inline

Definition at line 88 of file Scheduler.h.

◆ studentArea()

const string & gtsam::Scheduler::studentArea ( size_t  i,
size_t  area 
) const

Definition at line 96 of file Scheduler.cpp.

◆ studentKey()

const DiscreteKey & gtsam::Scheduler::studentKey ( size_t  i) const

Definition at line 91 of file Scheduler.cpp.

◆ studentName()

const string & gtsam::Scheduler::studentName ( size_t  i) const

Definition at line 86 of file Scheduler.cpp.

Member Data Documentation

◆ areaName_

std::vector<std::string> gtsam::Scheduler::areaName_
private

Definition at line 51 of file Scheduler.h.

◆ available_

std::string gtsam::Scheduler::available_
private

nrTimeSlots * nrFaculty availability constraints

Definition at line 58 of file Scheduler.h.

◆ facultyInArea_

FacultyInArea gtsam::Scheduler::facultyInArea_
private

Definition at line 55 of file Scheduler.h.

◆ facultyIndex_

std::map<std::string, size_t> gtsam::Scheduler::facultyIndex_
private

faculty identifiers

Definition at line 50 of file Scheduler.h.

◆ facultyName_

std::vector<std::string> gtsam::Scheduler::facultyName_
private

Definition at line 51 of file Scheduler.h.

◆ maxNrStudents_

size_t gtsam::Scheduler::maxNrStudents_
private

Maximum number of students

Definition at line 44 of file Scheduler.h.

◆ slotName_

std::vector<std::string> gtsam::Scheduler::slotName_
private

Definition at line 51 of file Scheduler.h.

◆ slotsAvailable_

std::vector<double> gtsam::Scheduler::slotsAvailable_
private

which slots are good

Definition at line 61 of file Scheduler.h.

◆ students_

std::vector<Student> gtsam::Scheduler::students_
private

discrete keys, indexed by student and area index

Definition at line 47 of file Scheduler.h.


The documentation for this class was generated from the following files:


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:47:08