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/tsp/Scheduler.hpp> 18 using namespace library;
19 using namespace protocol;
37 shared_ptr<tsp::Scheduler> scheduler;
49 scheduler = make_shared<tsp::Scheduler>();
57 virtual void optimize(shared_ptr<XML> xml)
override 59 super::optimize(
nullptr);
61 scheduler->construct(xml);
76 unique_lock<mutex> uk(mtx);
78 shared_ptr<tsp::Scheduler> scheduler(
new tsp::Scheduler());
79 scheduler->construct(xml);
81 cout <<
"An optimization process from a slave system has completed" << endl;
82 cout <<
"\tOrdinary minimum distance: " << this->scheduler->calcDistance()
83 <<
", New Price from the slave: " << scheduler->calcDistance() << endl;
85 if (scheduler->calcDistance() < this->scheduler->calcDistance())
86 this->scheduler = scheduler;
88 if (++optimized < this->size())
92 cout <<
"Parallel optimization has completed." << endl;
93 cout << scheduler->toString() << endl << endl;
114 cout <<
"----------------------------------------------------------------------------" << endl;
115 cout <<
" TSP SOLVER MASTER" << endl;
116 cout <<
"----------------------------------------------------------------------------" << endl;
static void main()
Main function.
A master of parallel system solving something.
A master for parallel system solving TSP problem.
TSPMaster()
Default Constructor.
virtual void replyOptimization(shared_ptr< XML > xml) override
Handle (replied) optimized value from a slave system.
virtual void optimize(shared_ptr< XML > xml) override
Optimize something.