2 #include <samchon/example/interaction/Master.hpp> 4 #include <samchon/example/interaction/ChiefDriver.hpp> 5 #include <samchon/example/interaction/SlaveDriver.hpp> 6 #include <samchon/protocol/Invoke.hpp> 8 #include <samchon/example/packer/Packer.hpp> 9 #include <samchon/library/CombinedPermutationGenerator.hpp> 19 using namespace library;
20 using namespace protocol;
53 packer = make_shared<packer::Packer>();
61 virtual void optimize(shared_ptr<XML> xml)
override 63 super::optimize(
nullptr);
65 packer->construct(xml);
81 unique_lock<mutex> uk(mtx);
83 shared_ptr<packer::Packer> packer(
new packer::Packer());
84 packer->construct(xml);
86 cout <<
"An optimization process from a slave system has completed" << endl;
87 cout <<
"\tOrdinary minimum price: " << this->packer->calcPrice()
88 <<
", New Price from the slave: " << packer->calcPrice() << endl;
90 if (this->packer->calcPrice() == 0 || packer->calcPrice() < this->packer->calcPrice())
91 this->packer = packer;
93 if (++optimized < this->size())
96 cout <<
"Parallel optimization has completed." << endl;
97 cout << packer->toString() << endl << endl;
99 chiefDriver->sendData( make_shared<Invoke>(
"replyOptimization", packer->toXML()) );
111 cout <<
"----------------------------------------------------------------------------" << endl;
112 cout <<
" PACKER MASTER" << endl;
113 cout <<
"----------------------------------------------------------------------------" << endl;
virtual void replyOptimization(shared_ptr< XML > xml) override
Handle (replied) optimized value from a slave system.
A combined-permutation case generator.
A master of parallel system solving something.
shared_ptr< packer::Packer > packer
A packer solver.
static void main()
Main functino.
virtual void optimize(shared_ptr< XML > xml) override
Optimize something.
A master of parallel system solving packaging problem.
PackerMaster()
Default Constructor.