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;
36 s.
addStudent(
"Young, Carol",
"Controls",
"Autonomy",
"Mechanics",
"Fumin Zhang");
39 s.
addStudent(
"Erdogan, Can",
"Controls",
"AI",
"Perception",
"Mike Stilman");
42 s.
addStudent(
"Arslan, Oktay",
"Controls",
"AI",
"Mechanics",
"Panos Tsiotras");
45 s.
addStudent(
"Bhattacharjee, Tapomayukh",
"Controls",
"AI",
"Mechanics",
"Charlie Kemp");
48 s.
addStudent(
"Grey, Michael",
"Controls",
"AI",
"Mechanics",
"Wayne Book");
51 s.
addStudent(
"O'Flaherty, Rowland",
"Controls",
"AI",
"Mechanics",
"Magnus Egerstedt");
54 s.
addStudent(
"Pickem, Daniel",
"Controls",
"AI",
"Mechanics",
"Jeff Shamma");
57 s.
addStudent(
"Lee, Kimoon",
"Controls",
"Autonomy",
"Mechanics",
"Henrik Christensen");
60 s.
addStudent(
"Melim, Andrew Lyon",
"Controls",
"AI",
"Perception",
"Frank Dellaert");
63 s.
addStudent(
"Jensen, David",
"Controls",
"Autonomy",
"HRI",
"Andrea Thomaz");
66 s.
addStudent(
"Nisbett, Jared",
"Controls",
"Perception",
"Mechanics",
"Magnus Egerstedt");
69 s.
addStudent(
"Pan, Yunpeng",
"Controls",
"Perception",
"Mechanics",
"Wayne Book");
85 string path(
"../../../gtsam_unstable/discrete/examples/");
86 Scheduler s(nrStudents, path +
"Doodle2013.csv");
88 s.
addArea(
"Harvey Lipkin",
"Mechanics");
89 s.
addArea(
"Jun Ueda",
"Mechanics");
90 s.
addArea(
"Mike Stilman",
"Mechanics");
92 s.
addArea(
"Wayne Book",
"Mechanics");
95 s.
addArea(
"Patricio Vela",
"Controls");
96 s.
addArea(
"Magnus Egerstedt",
"Controls");
97 s.
addArea(
"Jun Ueda",
"Controls");
98 s.
addArea(
"Panos Tsiotras",
"Controls");
99 s.
addArea(
"Fumin Zhang",
"Controls");
100 s.
addArea(
"Ayanna Howard",
"Controls");
101 s.
addArea(
"Jeff Shamma",
"Controls");
103 s.
addArea(
"Frank Dellaert",
"Perception");
104 s.
addArea(
"Henrik Christensen",
"Perception");
106 s.
addArea(
"Mike Stilman",
"AI");
109 s.
addArea(
"Charles Isbell",
"AI");
111 s.
addArea(
"Andrea Thomaz",
"AI");
113 s.
addArea(
"Ayanna Howard",
"Autonomy");
114 s.
addArea(
"Charlie Kemp",
"Autonomy");
117 s.
addArea(
"Karen Feigh",
"HRI");
122 for (
size_t i = 0;
i < nrStudents;
i++)
136 SETDEBUG(
"Scheduler::buildGraph",
true);
142 product.
dot(
"scheduling-large",
false);
147 SETDEBUG(
"DiscreteConditional::DiscreteConditional",
true);
155 for (
size_t i=0;
i<100;
i++) {
163 if (nz >= 13 && min >=1 && max <= 4) {
164 cout <<
"======================================================\n";
185 SETDEBUG(
"DiscreteConditional::COUNT",
true);
186 SETDEBUG(
"DiscreteConditional::DiscreteConditional", debug);
190 vector<double> slotsAvailable(
largeExample(0).nrTimeSlots(), 1.0);
216 size_t bestSlot = root->solve(values);
220 values[dkey.first] = bestSlot;
221 double count = (*root)(
values);
224 slotsAvailable[bestSlot] = 0.0;
225 cout << boost::format(
"%s = %d (%d), count = %d") % scheduler.
studentName(NRSTUDENTS-1-
s)
226 % scheduler.
slotName(bestSlot) % bestSlot % count << endl;
234 size_t slot, vector<Scheduler>& schedulers) {
237 cout <<
" creating sampler for " << scheduler.
studentName(0) << endl;
238 SETDEBUG(
"Scheduler::buildGraph",
false);
242 schedulers.push_back(scheduler);
248 size_t nrFaculty = 17;
250 vector<Scheduler> schedulers;
251 vector<DiscreteBayesNet::shared_ptr> samplers(
NRSTUDENTS);
254 vector<size_t> slots;
255 slots += 12,11,13, 21,16,1, 3,2,6, 7,22,4;
260 for (
size_t n = 0;
n < 10000;
n++) {
261 vector<size_t>
stats(nrFaculty, 0);
262 vector<Scheduler::sharedValues>
samples;
264 samples.push_back(samplers[i]->sample());
265 schedulers[
i].accumulateStats(samples[i], stats);
267 size_t max = *max_element(stats.begin(), stats.end());
268 size_t min = *min_element(stats.begin(), stats.end());
269 size_t nz = count_if(stats.begin(), stats.end(),
NonZero);
270 if (nz >= 16 && max <= 3) {
271 cout << boost::format(
272 "Sampled schedule %d, min = %d, nz = %d, max = %d\n") % (
n + 1) % min
275 cout << schedulers[
i].studentName(0) <<
" : " << schedulers[
i].slotName(
277 schedulers[
i].printSpecial(samples[i]);
const std::string & slotName(size_t s) const
sharedValues optimalAssignment() const
DiscreteBayesNet::shared_ptr createSampler(size_t i, size_t slot, vector< Scheduler > &schedulers)
Scheduler largeExample(size_t nrStudents=NRSTUDENTS, bool addStudents=true)
const std::string & studentName(size_t i) 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)
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
void addStudent(Scheduler &s, size_t i)
std::vector< float > Values
void print(const std::string &s="Scheduler", const KeyFormatter &formatter=DefaultKeyFormatter) const override
void solveStaged(size_t addMutex=2)
boost::shared_ptr< Values > sharedValues
DiscreteBayesNet::shared_ptr eliminate() const
boost::shared_ptr< This > shared_ptr
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
void accumulateStats(sharedValues assignment, std::vector< size_t > &stats) const