2 #include <samchon/protocol/ExternalServerArray.hpp> 3 #include <samchon/example/interaction/MasterDriver.hpp> 5 #include <samchon/protocol/Invoke.hpp> 7 #include <samchon/example/packer/Packer.hpp> 8 #include <samchon/example/tsp/Scheduler.hpp> 20 using namespace library;
21 using namespace protocol;
47 :
public ExternalServerArray
50 typedef ExternalServerArray super;
63 emplace_back(
new MasterDriver(
this,
"TSP",
"127.0.0.1", 37110));
64 emplace_back(
new MasterDriver(
this,
"Reporter", ip, 37200));
65 emplace_back(
new MasterDriver(
this,
"Packer", ip, 37310));
67 virtual ~
Chief() =
default;
80 cout <<
"1. TSP Solver, 2. Packer: ";
93 virtual auto createChild(shared_ptr<XML>) -> ExternalSystem*
102 virtual void replyData(shared_ptr<Invoke> invoke)
104 get(
"Reporter")->sendData(invoke);
119 shared_ptr<packer::ProductArray> productArray(
new packer::ProductArray());
121 productArray->emplace_back(
new packer::Product(
"Eraser", 500, 10, 70) );
122 productArray->emplace_back(
new packer::Product(
"Pencil", 400, 30, 35) );
123 productArray->emplace_back(
new packer::Product(
"Pencil", 400, 30, 35) );
124 productArray->emplace_back(
new packer::Product(
"Pencil", 400, 30, 35) );
125 productArray->emplace_back(
new packer::Product(
"Book", 8000, 150, 300) );
126 productArray->emplace_back(
new packer::Product(
"Book", 8000, 150, 300) );
127 productArray->emplace_back(
new packer::Product(
"Drink", 1000, 75, 250) );
128 productArray->emplace_back(
new packer::Product(
"Umbrella", 4000, 200, 1000) );
129 productArray->emplace_back(
new packer::Product(
"Notebook-PC", 800000, 150, 850) );
130 productArray->emplace_back(
new packer::Product(
"Tablet-PC", 600000, 120, 450) );
133 packer::Packer packer(productArray);
135 packer.emplace_back(
new packer::WrapperArray(
"Large", 100, 200, 1000) );
136 packer.emplace_back(
new packer::WrapperArray(
"Medium", 70, 150, 500) );
137 packer.emplace_back(
new packer::WrapperArray(
"Small", 50, 100, 250) );
140 get(
"Packer")->sendData
160 shared_ptr<tsp::Travel> travel = make_shared<tsp::Travel>();
161 for(
int i = 0; i < 20; i++)
162 travel->emplace_back(
new tsp::GeometryPoint(i + 1));
165 struct tsp::GAParameters gaParameters = {.03, 30, 400, 400};
168 tsp::Scheduler scheduler(travel, gaParameters);
169 get(
"TSP")->sendData(make_shared<Invoke>(
"optimize", scheduler.toXML()));
183 cout <<
"----------------------------------------------------------------------------" << endl;
184 cout <<
" CHIEF" << endl;
185 cout <<
"----------------------------------------------------------------------------" << endl;
186 cout <<
" ip: "; cin >> ip;
void callTSP()
Call tsp master system.
A driver for each system, master.
A chief system managing master systems.
void callPacker()
Call packer master system.
static void main()
Main function.
Chief(const string &ip)
Construct from ip address.