Commit f09ded30 authored by Sonja Happ's avatar Sonja Happ

sync one SET of agents for el connections instead of two

parent 66a7665b
......@@ -135,8 +135,7 @@
#define EPSILON 0.000001
/*definition of agent set names*/
#define SET_FORWARD_SWEEP "SET_forward_sweep"
#define SET_BACKWARD_SWEEP "SET_backward_sweep"
#define SET_EL_CONNECTIONS "SET_el_connections"
#define SET_MESSAGE_ROUTERS "SET_message_routers"
/* defines for control behavior */
......
......@@ -602,9 +602,7 @@ void Model::init_elec_network() {
//save all connections to be made to non-local agents
std::vector<std::pair<repast::AgentId, repast::AgentId>> connections_missing;
//repast::AgentRequest node_req(rank);
repast::AgentRequest node_req_forward(rank);
repast::AgentRequest node_req_backward(rank);
repast::AgentRequest req_el_connections(rank);
if(rank == 0) {
std::cout << "---> creating electrical connections of local agents" << std::endl;
......@@ -757,18 +755,10 @@ void Model::init_elec_network() {
repast::AgentId agent2(id2, agent2_rank, type2);
if(id1 < id2){
if (!node_req_backward.contains(agent2)) {
node_req_backward.addRequest(agent2);
}
}
else{
if (!node_req_forward.contains(agent2)) {
node_req_forward.addRequest(agent2);
}
if (!req_el_connections.contains(agent2)) {
req_el_connections.addRequest(agent2);
}
std::pair<repast::AgentId, repast::AgentId> connection;
connection.first = agent1_id;
connection.second = agent2;
......@@ -784,16 +774,8 @@ void Model::init_elec_network() {
repast::AgentId agent1(id1, agent1_rank, type1);
if(id1 < id2){
if (!node_req_forward.contains(agent1)) {
node_req_forward.addRequest(agent1);
}
}
else{
if (!node_req_backward.contains(agent1)) {
node_req_backward.addRequest(agent1);
}
if (!req_el_connections.contains(agent1)) {
req_el_connections.addRequest(agent1);
}
std::pair<repast::AgentId, repast::AgentId> connection;
......@@ -808,12 +790,9 @@ void Model::init_elec_network() {
std::cout << "---> requesting non local agents" << std::endl;
}
// request all missing non-local agents (call this function only once for all agents that need to be requested)
IO->log_info("agent forward sweep request for nodes: " + IO->req2str(node_req_forward));
repast::RepastProcess::instance()->requestAgents<Agent, AgentPackage, AgentPackageProvider, AgentPackageReceiver>(
context, node_req_forward, *provider, *receiver, *receiver, SET_FORWARD_SWEEP);
IO->log_info("agent backward sweep request for nodes: " + IO->req2str(node_req_backward));
IO->log_info("agent el connections request for nodes: " + IO->req2str(req_el_connections));
repast::RepastProcess::instance()->requestAgents<Agent, AgentPackage, AgentPackageProvider, AgentPackageReceiver>(
context, node_req_backward, *provider, *receiver, *receiver, SET_BACKWARD_SWEEP);
context, req_el_connections, *provider, *receiver, *receiver, SET_EL_CONNECTIONS);
if(rank == 0) {
std::cout << "---> creating electrical connections to non-local agents" << std::endl;
......@@ -1390,7 +1369,7 @@ void Model::initSchedule(repast::ScheduleRunner& runner){
* */
void Model::synchronize(const std::string agent_set) {
if (agent_set == SET_FORWARD_SWEEP || agent_set == SET_BACKWARD_SWEEP){
if (agent_set == SET_EL_CONNECTIONS){
IO->start_time_measurement(IO->tm_sync_el);
} else {
IO->start_time_measurement(IO->tm_sync_mr);
......@@ -1411,7 +1390,7 @@ void Model::synchronize(const std::string agent_set) {
MPI_Abort(MPI_COMM_WORLD, -1);
}
if (agent_set == SET_FORWARD_SWEEP || agent_set == SET_BACKWARD_SWEEP){
if (agent_set == SET_EL_CONNECTIONS){
IO->stop_time_measurement(IO->tm_sync_el);
} else {
IO->stop_time_measurement(IO->tm_sync_mr);
......@@ -1421,8 +1400,7 @@ void Model::synchronize(const std::string agent_set) {
}
void Model::synchronize_el_connections(){
this->synchronize(SET_FORWARD_SWEEP);
this->synchronize(SET_BACKWARD_SWEEP);
this->synchronize(SET_EL_CONNECTIONS);
}
/*! \brief Advances a simulation step for every local agent and cable
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment