10 #define ADD_NO_PRUNING 15 #include <boost/assign/std/vector.hpp> 16 #include <boost/assign/std/map.hpp> 17 #include <boost/optional.hpp> 18 #include <boost/format.hpp> 24 using namespace gtsam;
30 s.
addStudent(
"Michael N",
"AI",
"Autonomy",
"Perception",
"Tucker Balch");
33 s.
addStudent(
"Tucker H",
"Controls",
"AI",
"Perception",
"Jim Rehg");
36 s.
addStudent(
"Jake H",
"Controls",
"AI",
"Perception",
"Henrik Christensen");
39 s.
addStudent(
"Tobias K",
"Controls",
"AI",
"Autonomy",
"Mike Stilman");
42 s.
addStudent(
"Shu J",
"Controls",
"AI",
"HRI",
"N/A 1");
45 s.
addStudent(
"Akansel C",
"AI",
"Autonomy",
"Mechanics",
46 "Henrik Christensen");
49 s.
addStudent(
"Tiffany C",
"Controls",
"N/A 1",
"N/A 2",
"Charlie Kemp");
60 string path(
"../../../gtsam_unstable/discrete/examples/");
63 s.
addArea(
"Harvey Lipkin",
"Mechanics");
64 s.
addArea(
"Wayne Book",
"Mechanics");
65 s.
addArea(
"Jun Ueda",
"Mechanics");
68 s.
addArea(
"Patricio Vela",
"Controls");
69 s.
addArea(
"Magnus Egerstedt",
"Controls");
70 s.
addArea(
"Jun Ueda",
"Controls");
73 s.
addArea(
"Jim Rehg",
"Perception");
74 s.
addArea(
"Irfan Essa",
"Perception");
75 s.
addArea(
"Aaron Bobick",
"Perception");
76 s.
addArea(
"Henrik Christensen",
"Perception");
78 s.
addArea(
"Mike Stilman",
"AI");
79 s.
addArea(
"Henrik Christensen",
"AI");
80 s.
addArea(
"Frank Dellaert",
"AI");
81 s.
addArea(
"Ayanna Howard",
"AI");
84 s.
addArea(
"Ayanna Howard",
"Autonomy");
86 s.
addArea(
"Charlie Kemp",
"Autonomy");
87 s.
addArea(
"Tucker Balch",
"Autonomy");
88 s.
addArea(
"Ron Arkin",
"Autonomy");
90 s.
addArea(
"Andrea Thomaz",
"HRI");
91 s.
addArea(
"Karen Feigh",
"HRI");
92 s.
addArea(
"Charlie Kemp",
"HRI");
99 for (
size_t i = 0;
i < nrStudents;
i++)
118 product.
dot(
"scheduling-large",
false);
123 SETDEBUG(
"DiscreteConditional::DiscreteConditional",
true);
138 SETDEBUG(
"DiscreteConditional::COUNT",
true);
139 SETDEBUG(
"DiscreteConditional::DiscreteConditional", debug);
143 vector<double> slotsAvailable(
largeExample(0).nrTimeSlots(), 1.0);
146 for (
size_t s = 0;
s < 7;
s++) {
169 size_t bestSlot = root->solve(values);
173 values[dkey.first] = bestSlot;
174 size_t count = (*root)(
values);
177 slotsAvailable[bestSlot] = 0.0;
178 cout << boost::format(
"%s = %d (%d), count = %d") % scheduler.
studentName(6-
s)
179 % scheduler.
slotName(bestSlot) % bestSlot % count << endl;
203 size_t slot, vector<Scheduler>& schedulers) {
206 SETDEBUG(
"Scheduler::buildGraph",
false);
210 schedulers.push_back(scheduler);
216 vector<Scheduler> schedulers;
217 vector<DiscreteBayesNet::shared_ptr> samplers(7);
220 vector<size_t> slots;
221 slots += 16, 17, 11, 2, 0, 5, 9;
222 for (
size_t i = 0;
i < 7;
i++)
226 for (
size_t n = 0;
n < 500;
n++) {
227 vector<size_t>
stats(19, 0);
228 vector<Scheduler::sharedValues>
samples;
229 for (
size_t i = 0; i < 7; i++) {
230 samples.push_back(samplers[i]->sample());
231 schedulers[
i].accumulateStats(samples[i], stats);
233 size_t max = *max_element(stats.begin(), stats.end());
234 size_t min = *min_element(stats.begin(), stats.end());
235 size_t nz = count_if(stats.begin(), stats.end(),
NonZero);
236 if (nz >= 15 && max <= 2) {
237 cout << boost::format(
238 "Sampled schedule %d, min = %d, nz = %d, max = %d\n") % (
n + 1) % min
240 for (
size_t i = 0; i < 7; i++) {
241 cout << schedulers[
i].studentName(0) <<
" : " << schedulers[
i].slotName(
243 schedulers[
i].printSpecial(samples[i]);
292 SETDEBUG(
"DiscreteConditional::DiscreteConditional", debug);
297 scheduler.
addStudent(
"Carlos N",
"Perception",
"AI",
"Autonomy",
298 "Henrik Christensen");
299 scheduler.
print(
"scheduler");
302 vector<size_t> slots;
303 slots += 16, 17, 11, 2, 0, 5, 9, 14;
304 vector<double> slotsAvailable(scheduler.
nrTimeSlots(), 1.0);
306 slotsAvailable[
s] = 0;
323 size_t bestSlot = root->solve(values);
327 values[dkey.first] = bestSlot;
328 size_t count = (*root)(
values);
329 cout << boost::format(
"%s = %d (%d), count = %d") % scheduler.
studentName(0)
330 % scheduler.
slotName(bestSlot) % bestSlot % count << endl;
333 for (
size_t n = 0;
n < 10;
n++) {
334 Scheduler::sharedValues sample0 = chordal->sample();
const std::string & slotName(size_t s) const
sharedValues optimalAssignment() const
void solveStaged(size_t addMutex=2)
DiscreteBayesNet::shared_ptr createSampler(size_t i, size_t slot, vector< Scheduler > &schedulers)
const std::string & studentName(size_t i) const
size_t nrTimeSlots() const
void addStudent(const std::string &studentName, const std::string &area1, const std::string &area2, const std::string &area3, const std::string &advisor)
const mpreal root(const mpreal &x, unsigned long int k, mp_rnd_t r=mpreal::get_default_rnd())
size_t nrStudents() const
current number of students
void printAssignment(sharedValues assignment) const
void addStudentSpecificConstraints(size_t i, boost::optional< size_t > slot=boost::none)
void addStudent(Scheduler &s, size_t i)
std::pair< Key, size_t > DiscreteKey
void dot(std::ostream &os, bool showZero=true) const
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
void buildGraph(size_t mutexBound=7)
void setSlotsAvailable(const std::vector< double > &slotsAvailable)
const DiscreteKey & studentKey(size_t i) const
std::vector< float > Values
void print(const std::string &s="Scheduler", const KeyFormatter &formatter=DefaultKeyFormatter) const override
boost::shared_ptr< Values > sharedValues
DiscreteBayesNet::shared_ptr eliminate() const
boost::shared_ptr< This > shared_ptr
Scheduler largeExample(size_t nrStudents=7)
void addArea(const std::string &facultyName, const std::string &areaName)
DecisionTreeFactor product() const
#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