Commit 6c2b8b87 authored by Sonja Happ's avatar Sonja Happ

fix indents and remove some log output

parent c55b7d45
......@@ -1579,25 +1579,25 @@ void Model::do_backward_sweep() {
std::vector<bool> state(agents_scheduling.size(), false);
while(!backward_sweep_finished) {
if(have_backward_sweeped < agents_scheduling.size()){
//perform backward sweep for all node agents if not all node agents have finished backward sweeping
int index = 0;
for(auto i : agents_scheduling){ // iterate forward
if(state[index] == false){
state[index] = i->do_backward_sweep(agent_network_elec);
if(state[index]){
have_backward_sweeped++;
}
IO->log_info("Backward sweep for AgentID " + std::to_string(i->getId().id()) + " state=" + std::to_string(state[index]));
} else {
IO->log_info("Skipping AgentID " + std::to_string(i->getId().id()));
}
index++;
}
} else {
IO->log_info("Skipping ...");
}
if(have_backward_sweeped < agents_scheduling.size()){
//perform backward sweep for all node agents if not all node agents have finished backward sweeping
int index = 0;
for(auto i : agents_scheduling){ // iterate forward
if(state[index] == false){
state[index] = i->do_backward_sweep(agent_network_elec);
if(state[index]){
have_backward_sweeped++;
}
IO->log_info("Backward sweep for AgentID " + std::to_string(i->getId().id()) + " state=" + std::to_string(state[index]));
} /*else {
IO->log_info("Skipping AgentID " + std::to_string(i->getId().id()));
} */
index++;
}
} /*else {
IO->log_info("Skipping ...");
}*/
counter++;
......@@ -1641,63 +1641,59 @@ void Model::do_forward_sweep() {
uint checked_convergence = 0;
std::vector<uint> state(agents_scheduling.size(), DONE_NOTHING);
while(!forward_sweep_finished){
if(checked_convergence < agents_scheduling.size()){
if(checked_convergence < agents_scheduling.size()){
if(!started_convergence_check) {
//perform forward sweep for all node agents
for (unsigned long i = agents_scheduling.size(); i > 0; i--) { // iterate backwards...
if(state[i-1] == DONE_NOTHING){
if(state[i-1] == DONE_NOTHING){
state[i-1] = agents_scheduling[i-1]->do_forward_sweep(agent_network_elec);
IO->log_info("Forward sweep for AgentID " + std::to_string(agents_scheduling[i-1]->getId().id()) + " state=" + std::to_string(state[i-1]));
if (state[i-1] == DONE_CONVERGENCE_CHECK){
started_convergence_check = true;
checked_convergence++;
} else{
started_convergence_check = false;
}
} else {
IO->log_info("Skipping AgentID " + std::to_string(agents_scheduling[i-1]->getId().id()));
}
IO->log_info("Forward sweep for AgentID " + std::to_string(agents_scheduling[i-1]->getId().id()) + " state=" + std::to_string(state[i-1]));
if (state[i-1] == DONE_CONVERGENCE_CHECK){
started_convergence_check = true;
checked_convergence++;
} else{
started_convergence_check = false;
}
} /* else {
IO->log_info("Skipping AgentID " + std::to_string(agents_scheduling[i-1]->getId().id()));
}*/
}
}
else{
} else{
//perform convergence check for all node agents
int index = 0;
int index = 0;
for (auto i : agents_scheduling) { // iterate forward...
if(state[index] == DONE_FORWARD_SWEEP){
state[index] = i->do_forward_sweep(agent_network_elec);
IO->log_info("Convergence check for Agent ID " + std::to_string(i->getId().id()) + " state="+ std::to_string(state[index]));
if(state[index] == DONE_CONVERGENCE_CHECK){
checked_convergence++;
if(state[index] == DONE_FORWARD_SWEEP){
state[index] = i->do_forward_sweep(agent_network_elec);
IO->log_info("Convergence check for Agent ID " + std::to_string(i->getId().id()) + " state="+ std::to_string(state[index]));
if(state[index] == DONE_CONVERGENCE_CHECK){
checked_convergence++;
}
} /* else {
IO->log_info("Skipping AgentID " + std::to_string(i->getId().id()));
}*/
index++;
}
} else {
IO->log_info("Skipping AgentID " + std::to_string(i->getId().id()));
}
index++;
}
}
} else {
} /* else {
IO->log_info("Skipping ...");
}
}*/
counter++;
//check if finished
//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));
if((slack->get_next_action_expected() == BACKWARD_SWEEP)){
forward_sweep_finished = true;
}
}
//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);
// 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
synchronize_el_connections();
IO->start_time_measurement(IO->tm_forward_sweep);
......
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