diff --git a/src/model/model.cpp b/src/model/model.cpp index 77e3933d91e6b12bab877083cea59f2627471406..3d0d21362184055ac2840949b816987b2ab40805 100644 --- a/src/model/model.cpp +++ b/src/model/model.cpp @@ -1599,7 +1599,11 @@ void Model::do_backward_sweep() { IO->log_info("Skipping ..."); } + counter++; + //check if finished + IO->stop_time_measurement(IO->tm_backward_sweep); + IO->start_time_measurement(IO->tm_bcast_backward_sweep); if (context.contains(repast::AgentId(SLACK_ID, rank, TYPE_SLACK_INT, rank))) { Agent *slack = context.getAgent(repast::AgentId(SLACK_ID, rank, TYPE_SLACK_INT, rank)); @@ -1609,17 +1613,11 @@ void Model::do_backward_sweep() { } } if(world_size > 1){ - IO->stop_time_measurement(IO->tm_backward_sweep); - IO->start_time_measurement(IO->tm_bcast_backward_sweep); //TODO use MPI_Ibcast instead MPI_Bcast(&backward_sweep_finished, 1, MPI_C_BOOL, agent_rank_relation[SLACK_ID-1], MPI_COMM_WORLD); - IO->stop_time_measurement(IO->tm_bcast_backward_sweep); - IO->start_time_measurement(IO->tm_backward_sweep); } IO->log_info("Backward sweep finished: " + std::to_string(backward_sweep_finished)); - - counter++; - IO->stop_time_measurement(IO->tm_backward_sweep); + IO->stop_time_measurement(IO->tm_bcast_backward_sweep); //synchronize changes synchronize_el_connections(); @@ -1656,10 +1654,6 @@ void Model::do_forward_sweep() { } else{ started_convergence_check = false; } - - if (state[i-1] == DONE_NOTHING){ - break; // stop iteration if one agent could not complete forward sweep because previous agents have not completed yet - } } else { IO->log_info("Skipping AgentID " + std::to_string(agents_scheduling[i-1]->getId().id())); } @@ -1675,9 +1669,6 @@ void Model::do_forward_sweep() { if(state[index] == DONE_CONVERGENCE_CHECK){ checked_convergence++; } - if (state[index] == DONE_NOTHING){ - break; // stop iteration if one agent could to nothing because it is likely that the following agents cannot to anything either - } } else { IO->log_info("Skipping AgentID " + std::to_string(i->getId().id())); } @@ -1688,7 +1679,11 @@ void Model::do_forward_sweep() { IO->log_info("Skipping ..."); } - //check if finished + counter++; + + //check if finished + IO->stop_time_measurement(IO->tm_forward_sweep); + IO->start_time_measurement(IO->tm_bcast_forward_sweep); if(context.contains(repast::AgentId(SLACK_ID,rank,TYPE_SLACK_INT, rank))){ Agent * slack = context.getAgent(repast::AgentId(SLACK_ID,rank,TYPE_SLACK_INT, rank)); @@ -1698,16 +1693,12 @@ void Model::do_forward_sweep() { } } - IO->stop_time_measurement(IO->tm_forward_sweep); - IO->start_time_measurement(IO->tm_bcast_forward_sweep); //TODO use MPI_Ibcast instead MPI_Bcast(&forward_sweep_finished, 1, MPI_C_BOOL, agent_rank_relation[SLACK_ID-1], MPI_COMM_WORLD); // root was 0 IO->stop_time_measurement(IO->tm_bcast_forward_sweep); - IO->start_time_measurement(IO->tm_forward_sweep); - counter++; - // in forward sweep info about next and previous electrical nodes are required + + // in forward sweep info about next and previous electrical nodes are required // that is why both sets need to be updated here - IO->stop_time_measurement(IO->tm_forward_sweep); synchronize_el_connections(); IO->start_time_measurement(IO->tm_forward_sweep);