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(
"Pan, Yunpeng",
"Controls",
"Perception",
"Mechanics",
"Eric Johnson");
39 s.
addStudent(
"Sawhney, Rahul",
"Controls",
"AI",
"Perception",
"Henrik Christensen");
42 s.
addStudent(
"Akgun, Baris",
"Controls",
"AI",
"HRI",
"Andrea Thomaz");
45 s.
addStudent(
"Jiang, Shu",
"Controls",
"AI",
"Perception",
"Ron Arkin");
48 s.
addStudent(
"Grice, Phillip",
"Controls",
"Perception",
"HRI",
"Charlie Kemp");
51 s.
addStudent(
"Huaman, Ana",
"Controls",
"AI",
"Perception",
"Mike Stilman");
54 s.
addStudent(
"Levihn, Martin",
"AI",
"Autonomy",
"Perception",
"Mike Stilman");
57 s.
addStudent(
"Nieto, Carlos",
"AI",
"Autonomy",
"Perception",
"Henrik Christensen");
60 s.
addStudent(
"Robinette, Paul",
"Controls",
"AI",
"HRI",
"Ayanna Howard");
67 string path(
"../../../gtsam_unstable/discrete/examples/");
68 Scheduler s(nrStudents, path +
"Doodle2012.csv");
70 s.
addArea(
"Harvey Lipkin",
"Mechanics");
71 s.
addArea(
"Jun Ueda",
"Mechanics");
73 s.
addArea(
"Patricio Vela",
"Controls");
74 s.
addArea(
"Magnus Egerstedt",
"Controls");
75 s.
addArea(
"Jun Ueda",
"Controls");
76 s.
addArea(
"Panos Tsiotras",
"Controls");
77 s.
addArea(
"Fumin Zhang",
"Controls");
79 s.
addArea(
"Henrik Christensen",
"Perception");
80 s.
addArea(
"Aaron Bobick",
"Perception");
82 s.
addArea(
"Mike Stilman",
"AI");
84 s.
addArea(
"Ayanna Howard",
"AI");
85 s.
addArea(
"Charles Isbell",
"AI");
86 s.
addArea(
"Tucker Balch",
"AI");
88 s.
addArea(
"Ayanna Howard",
"Autonomy");
89 s.
addArea(
"Charlie Kemp",
"Autonomy");
90 s.
addArea(
"Tucker Balch",
"Autonomy");
91 s.
addArea(
"Ron Arkin",
"Autonomy");
93 s.
addArea(
"Andrea Thomaz",
"HRI");
94 s.
addArea(
"Karen Feigh",
"HRI");
95 s.
addArea(
"Charlie Kemp",
"HRI");
98 for (
size_t i = 0;
i < nrStudents;
i++)
118 product.
dot(
"scheduling-large",
false);
123 SETDEBUG(
"DiscreteConditional::DiscreteConditional",
true);
131 for (
size_t i=0;
i<100;
i++) {
139 if (nz >= 13 && min >=1 && max <= 4) {
140 cout <<
"======================================================\n";
160 SETDEBUG(
"DiscreteConditional::COUNT",
true);
161 SETDEBUG(
"DiscreteConditional::DiscreteConditional", debug);
165 vector<double> slotsAvailable(
largeExample(0).nrTimeSlots(), 1.0);
194 size_t bestSlot = root->solve(values);
198 values[dkey.first] = bestSlot;
199 size_t count = (*root)(
values);
202 slotsAvailable[bestSlot] = 0.0;
203 cout << boost::format(
"%s = %d (%d), count = %d") % scheduler.
studentName(NRSTUDENTS-1-
s)
204 % scheduler.
slotName(bestSlot) % bestSlot % count << endl;
212 size_t slot, vector<Scheduler>& schedulers) {
215 SETDEBUG(
"Scheduler::buildGraph",
false);
219 schedulers.push_back(scheduler);
225 vector<Scheduler> schedulers;
226 vector<DiscreteBayesNet::shared_ptr> samplers(
NRSTUDENTS);
229 vector<size_t> slots;
230 slots += 3, 20, 2, 6, 5, 11, 1, 4;
235 for (
size_t n = 0;
n < 500;
n++) {
236 vector<size_t>
stats(19, 0);
237 vector<Scheduler::sharedValues>
samples;
239 samples.push_back(samplers[i]->sample());
240 schedulers[
i].accumulateStats(samples[i], stats);
242 size_t max = *max_element(stats.begin(), stats.end());
243 size_t min = *min_element(stats.begin(), stats.end());
244 size_t nz = count_if(stats.begin(), stats.end(),
NonZero);
245 if (nz >= 15 && max <= 2) {
246 cout << boost::format(
247 "Sampled schedule %d, min = %d, nz = %d, max = %d\n") % (
n + 1) % min
250 cout << schedulers[
i].studentName(0) <<
" : " << schedulers[
i].slotName(
252 schedulers[
i].printSpecial(samples[i]);
const std::string & slotName(size_t s) const
sharedValues optimalAssignment() const
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
DiscreteBayesNet::shared_ptr createSampler(size_t i, size_t slot, vector< Scheduler > &schedulers)
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
Scheduler largeExample(size_t nrStudents=NRSTUDENTS)
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
void addStudent(Scheduler &s, size_t i)
void addArea(const std::string &facultyName, const std::string &areaName)
DecisionTreeFactor product() const
#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
void accumulateStats(sharedValues assignment, std::vector< size_t > &stats) const