10 #define ADD_NO_PRUNING 18 using namespace gtsam;
30 s.
addStudent(
"Young, Carol",
"Controls",
"Autonomy",
"Mechanics",
"Fumin Zhang");
33 s.
addStudent(
"Erdogan, Can",
"Controls",
"AI",
"Perception",
"Mike Stilman");
36 s.
addStudent(
"Arslan, Oktay",
"Controls",
"AI",
"Mechanics",
"Panos Tsiotras");
39 s.
addStudent(
"Bhattacharjee, Tapomayukh",
"Controls",
"AI",
"Mechanics",
"Charlie Kemp");
42 s.
addStudent(
"Grey, Michael",
"Controls",
"AI",
"Mechanics",
"Wayne Book");
45 s.
addStudent(
"O'Flaherty, Rowland",
"Controls",
"AI",
"Mechanics",
"Magnus Egerstedt");
48 s.
addStudent(
"Pickem, Daniel",
"Controls",
"AI",
"Mechanics",
"Jeff Shamma");
51 s.
addStudent(
"Lee, Kimoon",
"Controls",
"Autonomy",
"Mechanics",
"Henrik Christensen");
54 s.
addStudent(
"Melim, Andrew Lyon",
"Controls",
"AI",
"Perception",
"Frank Dellaert");
57 s.
addStudent(
"Jensen, David",
"Controls",
"Autonomy",
"HRI",
"Andrea Thomaz");
60 s.
addStudent(
"Nisbett, Jared",
"Controls",
"Perception",
"Mechanics",
"Magnus Egerstedt");
63 s.
addStudent(
"Pan, Yunpeng",
"Controls",
"Perception",
"Mechanics",
"Wayne Book");
79 string path(
"../../../gtsam_unstable/discrete/examples/");
80 Scheduler s(nrStudents, path +
"Doodle2013.csv");
82 s.
addArea(
"Harvey Lipkin",
"Mechanics");
83 s.
addArea(
"Jun Ueda",
"Mechanics");
84 s.
addArea(
"Mike Stilman",
"Mechanics");
86 s.
addArea(
"Wayne Book",
"Mechanics");
89 s.
addArea(
"Patricio Vela",
"Controls");
90 s.
addArea(
"Magnus Egerstedt",
"Controls");
91 s.
addArea(
"Jun Ueda",
"Controls");
92 s.
addArea(
"Panos Tsiotras",
"Controls");
93 s.
addArea(
"Fumin Zhang",
"Controls");
94 s.
addArea(
"Ayanna Howard",
"Controls");
95 s.
addArea(
"Jeff Shamma",
"Controls");
97 s.
addArea(
"Frank Dellaert",
"Perception");
98 s.
addArea(
"Henrik Christensen",
"Perception");
100 s.
addArea(
"Mike Stilman",
"AI");
103 s.
addArea(
"Charles Isbell",
"AI");
105 s.
addArea(
"Andrea Thomaz",
"AI");
107 s.
addArea(
"Ayanna Howard",
"Autonomy");
108 s.
addArea(
"Charlie Kemp",
"Autonomy");
111 s.
addArea(
"Karen Feigh",
"HRI");
116 for (
size_t i = 0;
i < nrStudents;
i++)
130 SETDEBUG(
"Scheduler::buildGraph",
true);
141 SETDEBUG(
"DiscreteConditional::DiscreteConditional",
true);
149 for (
size_t i=0;
i<100;
i++) {
150 auto assignment = sample(*chordal);
157 if (nz >= 13 && min >=1 && max <= 4) {
158 cout <<
"======================================================\n";
179 SETDEBUG(
"DiscreteConditional::COUNT",
true);
180 SETDEBUG(
"DiscreteConditional::DiscreteConditional", debug);
184 vector<double> slotsAvailable(
largeExample(0).nrTimeSlots(), 1.0);
209 size_t bestSlot = root->argmax();
214 values[dkey.first] = bestSlot;
215 double count = (*root)(
values);
218 slotsAvailable[bestSlot] = 0.0;
219 cout << scheduler.
studentName(NRSTUDENTS - 1 -
s) <<
" = " << scheduler.
slotName(bestSlot) <<
" (" << bestSlot
220 <<
"), count = " << count << endl;
228 size_t slot, vector<Scheduler>& schedulers) {
231 cout <<
" creating sampler for " << scheduler.
studentName(0) << endl;
232 SETDEBUG(
"Scheduler::buildGraph",
false);
236 schedulers.push_back(scheduler);
242 size_t nrFaculty = 17;
244 vector<Scheduler> schedulers;
245 vector<DiscreteBayesNet::shared_ptr> samplers(
NRSTUDENTS);
248 vector<size_t> slots{12,11,13, 21,16,1, 3,2,6, 7,22,4};
253 for (
size_t n = 0;
n < 10000;
n++) {
254 vector<size_t>
stats(nrFaculty, 0);
255 vector<DiscreteValues>
samples;
257 samples.push_back(samplers[i]->sample());
258 schedulers[
i].accumulateStats(samples[i], stats);
260 size_t max = *max_element(stats.begin(), stats.end());
261 size_t min = *min_element(stats.begin(), stats.end());
262 size_t nz = count_if(stats.begin(), stats.end(),
NonZero);
263 if (nz >= 16 && max <= 3) {
264 cout <<
"Sampled schedule " <<
n + 1 <<
", min = " << min <<
", nz = " << nz <<
", max = " << max << endl;
266 cout << schedulers[
i].studentName(0) <<
" : " << schedulers[
i].slotName(
268 schedulers[
i].printSpecial(samples[i]);
DiscreteBayesNet::shared_ptr createSampler(size_t i, size_t slot, vector< Scheduler > &schedulers)
void printAssignment(const DiscreteValues &assignment) const
DecisionTreeFactor product() const
const std::string & studentName(size_t i) const
Scheduler largeExample(size_t nrStudents=NRSTUDENTS, bool addStudents=true)
const std::string & slotName(size_t s) const
void addStudent(const std::string &studentName, const std::string &area1, const std::string &area2, const std::string &area3, const std::string &advisor)
DiscreteValues optimize(OptionalOrderingType orderingType={}) const
Find the maximum probable explanation (MPE) by doing max-product.
void addStudentSpecificConstraints(size_t i, std::optional< size_t > slot={})
static const KeyFormatter DefaultKeyFormatter
static constexpr bool debug
const DiscreteKey & studentKey(size_t i) const
void accumulateStats(const DiscreteValues &assignment, std::vector< size_t > &stats) const
void buildGraph(size_t mutexBound=7)
void dot(std::ostream &os, const KeyFormatter &keyFormatter=DefaultKeyFormatter, bool showZero=true) const
void setSlotsAvailable(const std::vector< double > &slotsAvailable)
size_t nrStudents() const
current number of students
void addStudent(Scheduler &s, size_t i)
void print(const std::string &s="Scheduler", const KeyFormatter &formatter=DefaultKeyFormatter) const override
void solveStaged(size_t addMutex=2)
std::shared_ptr< This > shared_ptr
std::pair< Key, size_t > DiscreteKey
DiscreteBayesNet::shared_ptr eliminate() const
std::shared_ptr< This > shared_ptr
shared_ptr to this class
void addArea(const std::string &facultyName, const std::string &areaName)
#define tictoc_finishedIteration()
void product(const MatrixType &m)
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set samples