main()
{
CNSGA2* nsga2a = new CNSGA2(true); // true or false are only for different constructors
CNSGA2* nsga2b = new CNSGA2(false);
if (myRank == 0) // scope1
{
initialize the objects of nsga2a or nsga2b;
}
broadcast some parameters, which are got from scope1.
According to the parameters, define a datatype (myData) so that all workers use that to do recv and send.
if (myRank == 0) // scope2
{
send out myData to workers by the datatype defined above;
}
if (myRank != 0)
{
newCNSGA2 myNsga2;
recv data from master and work on the recved data;
myNsga2.evaluate(recv data);
send back results;
}
}