10 #define ADD_NO_PRUNING 18 using namespace gtsam;
30 s.
addStudent(
"Pan, Yunpeng",
"Controls",
"Perception",
"Mechanics",
"Eric Johnson");
33 s.
addStudent(
"Sawhney, Rahul",
"Controls",
"AI",
"Perception",
"Henrik Christensen");
36 s.
addStudent(
"Akgun, Baris",
"Controls",
"AI",
"HRI",
"Andrea Thomaz");
39 s.
addStudent(
"Jiang, Shu",
"Controls",
"AI",
"Perception",
"Ron Arkin");
42 s.
addStudent(
"Grice, Phillip",
"Controls",
"Perception",
"HRI",
"Charlie Kemp");
45 s.
addStudent(
"Huaman, Ana",
"Controls",
"AI",
"Perception",
"Mike Stilman");
48 s.
addStudent(
"Levihn, Martin",
"AI",
"Autonomy",
"Perception",
"Mike Stilman");
51 s.
addStudent(
"Nieto, Carlos",
"AI",
"Autonomy",
"Perception",
"Henrik Christensen");
54 s.
addStudent(
"Robinette, Paul",
"Controls",
"AI",
"HRI",
"Ayanna Howard");
61 string path(
"../../../gtsam_unstable/discrete/examples/");
62 Scheduler s(nrStudents, path +
"Doodle2012.csv");
64 s.
addArea(
"Harvey Lipkin",
"Mechanics");
65 s.
addArea(
"Jun Ueda",
"Mechanics");
67 s.
addArea(
"Patricio Vela",
"Controls");
68 s.
addArea(
"Magnus Egerstedt",
"Controls");
69 s.
addArea(
"Jun Ueda",
"Controls");
70 s.
addArea(
"Panos Tsiotras",
"Controls");
71 s.
addArea(
"Fumin Zhang",
"Controls");
73 s.
addArea(
"Henrik Christensen",
"Perception");
74 s.
addArea(
"Aaron Bobick",
"Perception");
76 s.
addArea(
"Mike Stilman",
"AI");
78 s.
addArea(
"Ayanna Howard",
"AI");
79 s.
addArea(
"Charles Isbell",
"AI");
80 s.
addArea(
"Tucker Balch",
"AI");
82 s.
addArea(
"Ayanna Howard",
"Autonomy");
83 s.
addArea(
"Charlie Kemp",
"Autonomy");
84 s.
addArea(
"Tucker Balch",
"Autonomy");
85 s.
addArea(
"Ron Arkin",
"Autonomy");
87 s.
addArea(
"Andrea Thomaz",
"HRI");
88 s.
addArea(
"Karen Feigh",
"HRI");
89 s.
addArea(
"Charlie Kemp",
"HRI");
92 for (
size_t i = 0;
i < nrStudents;
i++)
117 SETDEBUG(
"DiscreteConditional::DiscreteConditional",
true);
125 for (
size_t i=0;
i<100;
i++) {
126 auto assignment = chordal->sample();
133 if (nz >= 13 && min >=1 && max <= 4) {
134 cout <<
"======================================================\n";
154 SETDEBUG(
"DiscreteConditional::COUNT",
true);
155 SETDEBUG(
"DiscreteConditional::DiscreteConditional", debug);
159 vector<double> slotsAvailable(
largeExample(0).nrTimeSlots(), 1.0);
184 size_t bestSlot = root->argmax();
189 values[dkey.first] = bestSlot;
190 size_t count = (*root)(
values);
193 slotsAvailable[bestSlot] = 0.0;
194 cout << scheduler.
studentName(NRSTUDENTS - 1 -
s) <<
" = " <<
195 scheduler.
slotName(bestSlot) <<
" (" << bestSlot
196 <<
"), count = " << count << endl;
204 size_t slot, vector<Scheduler>& schedulers) {
207 SETDEBUG(
"Scheduler::buildGraph",
false);
210 schedulers.push_back(scheduler);
216 vector<Scheduler> schedulers;
217 vector<DiscreteBayesNet::shared_ptr> samplers(
NRSTUDENTS);
220 vector<size_t> slots{3, 20, 2, 6, 5, 11, 1, 4};
225 for (
size_t n = 0;
n < 500;
n++) {
226 vector<size_t>
stats(19, 0);
227 vector<DiscreteValues>
samples;
229 samples.push_back(samplers[i]->sample());
230 schedulers[
i].accumulateStats(samples[i], stats);
232 size_t max = *max_element(stats.begin(), stats.end());
233 size_t min = *min_element(stats.begin(), stats.end());
234 size_t nz = count_if(stats.begin(), stats.end(),
NonZero);
235 if (nz >= 15 && max <= 2) {
236 cout <<
"Sampled schedule " << (
n + 1) <<
", min = " << min
237 <<
", nz = " << nz <<
", max = " << max << endl;
239 cout << schedulers[
i].studentName(0) <<
" : " << schedulers[
i].slotName(
241 schedulers[
i].printSpecial(samples[i]);
void printAssignment(const DiscreteValues &assignment) const
DecisionTreeFactor product() const
const std::string & studentName(size_t i) const
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
DiscreteBayesNet::shared_ptr createSampler(size_t i, size_t slot, vector< Scheduler > &schedulers)
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)
Scheduler largeExample(size_t nrStudents=NRSTUDENTS)
size_t nrStudents() const
current number of students
void print(const std::string &s="Scheduler", const KeyFormatter &formatter=DefaultKeyFormatter) const override
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 addStudent(Scheduler &s, size_t i)
void addArea(const std::string &facultyName, const std::string &areaName)
#define tictoc_finishedIteration()
void solveStaged(size_t addMutex=2)
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