Commit d12ace4b authored by Sonja Kolen's avatar Sonja Kolen

add time measurements for behavior computation

parent 64cc7901
......@@ -90,6 +90,20 @@ public:
Time_measurement* tm_init_MR; /*!< Time measurement for MR Agent init */
Time_measurement* tm_comm_partners_init; /*!< Time measurement for communication partners init*/
/* Time measurements for agent behaviors */
Time_measurement* tm_load;
Time_measurement* tm_ev;
Time_measurement* tm_pv;
Time_measurement* tm_hp;
Time_measurement* tm_chp;
Time_measurement* tm_wec;
Time_measurement* tm_bio;
Time_measurement* tm_bat;
Time_measurement* tm_comp;
Time_measurement* tm_substation;
Time_measurement* tm_slack;
Time_measurement* tm_df;
unsigned int number_of_fbs_sweeps; //!< counting the number of forward-backward sweeps
//!< in each iteration
......
......@@ -1681,7 +1681,60 @@ void Model::process_agent_messages() {
IO->log_info("####### local agents process incoming messages #######");
for(auto i : local_agents){
IO->log_info("###### for agent " + IO->id2str(i->getId()));
if(i->getId().agentType() == TYPE_LOAD_INT){
IO->start_time_measurement(IO->tm_load);
} else if (i->getId().agentType() == TYPE_PV_INT) {
IO->start_time_measurement(IO->tm_pv);
} else if (i->getId().agentType() == TYPE_EV_INT) {
IO->start_time_measurement(IO->tm_ev);
} else if (i->getId().agentType() == TYPE_HP_INT) {
IO->start_time_measurement(IO->tm_hp);
} else if (i->getId().agentType() == TYPE_CHP_INT) {
IO->start_time_measurement(IO->tm_chp);
} else if (i->getId().agentType() == TYPE_WEC_INT) {
IO->start_time_measurement(IO->tm_wec);
} else if (i->getId().agentType() == TYPE_BIOFUEL_INT) {
IO->start_time_measurement(IO->tm_bio);
} else if (i->getId().agentType() == TYPE_BATTERY_INT) {
IO->start_time_measurement(IO->tm_bat);
} else if (i->getId().agentType() == TYPE_COMPENSATOR_INT) {
IO->start_time_measurement(IO->tm_comp);
} else if (i->getId().agentType() == TYPE_TRANSFORMER_INT) {
IO->start_time_measurement(IO->tm_substation);
} else if (i->getId().agentType() == TYPE_SLACK_INT) {
IO->start_time_measurement(IO->tm_slack);
} else if (i->getId().agentType() == TYPE_DF_INT) {
IO->start_time_measurement(IO->tm_df);
}
i->process_incoming_messages();
if(i->getId().agentType() == TYPE_LOAD_INT){
IO->stop_time_measurement(IO->tm_load);
} else if (i->getId().agentType() == TYPE_PV_INT) {
IO->stop_time_measurement(IO->tm_pv);
} else if (i->getId().agentType() == TYPE_EV_INT) {
IO->stop_time_measurement(IO->tm_ev);
} else if (i->getId().agentType() == TYPE_HP_INT) {
IO->stop_time_measurement(IO->tm_hp);
} else if (i->getId().agentType() == TYPE_CHP_INT) {
IO->stop_time_measurement(IO->tm_chp);
} else if (i->getId().agentType() == TYPE_WEC_INT) {
IO->stop_time_measurement(IO->tm_wec);
} else if (i->getId().agentType() == TYPE_BIOFUEL_INT) {
IO->stop_time_measurement(IO->tm_bio);
} else if (i->getId().agentType() == TYPE_BATTERY_INT) {
IO->stop_time_measurement(IO->tm_bat);
} else if (i->getId().agentType() == TYPE_COMPENSATOR_INT) {
IO->stop_time_measurement(IO->tm_comp);
} else if (i->getId().agentType() == TYPE_TRANSFORMER_INT) {
IO->stop_time_measurement(IO->tm_substation);
} else if (i->getId().agentType() == TYPE_SLACK_INT) {
IO->stop_time_measurement(IO->tm_slack);
} else if (i->getId().agentType() == TYPE_DF_INT) {
IO->stop_time_measurement(IO->tm_df);
}
}
IO->stop_time_measurement(IO->tm_behaviors);
IO->log_info("####### calculating communication interactions finished #######");
......
......@@ -58,6 +58,20 @@ props(_props), rank(_rank), world_size(_world_size), profile_dir(_profile_dir)
tm_distribute_agents = new Time_measurement("distribute_agents",rank);
tm_init_MR = new Time_measurement("init_MR",rank);
tm_comm_partners_init = new Time_measurement("comm_partners_init",rank);
tm_load = new Time_measurement("load_behavior", rank);
tm_pv = new Time_measurement("pv_behavior", rank);
tm_ev = new Time_measurement("ev_behavior", rank);
tm_hp = new Time_measurement("hp_behavior", rank);
tm_chp = new Time_measurement("chp_behavior", rank);
tm_wec = new Time_measurement("wec_behavior", rank);
tm_bio = new Time_measurement("bio_behavior", rank);
tm_bat = new Time_measurement("battery_behavior", rank);
tm_comp = new Time_measurement("compensator_behavior", rank);
tm_substation = new Time_measurement("substation_behavior", rank);
tm_slack = new Time_measurement("slack_behavior", rank);
tm_df = new Time_measurement("df_behavior", rank);
}
/*! \brief Initialize message and result logging on rank level
......@@ -162,7 +176,19 @@ void ModelIO::init_db() {
d_props.result.dbconn->addTimeMeasurementType("calculatecomponents","Time for calculating components in us");
d_props.result.dbconn->addTimeMeasurementType("backward_sweep","Time for backward sweeping in us");
d_props.result.dbconn->addTimeMeasurementType("forward_sweep","Time for forward sweeping in us");
d_props.result.dbconn->addTimeMeasurementType("load_behavior","Time for load behavior in us");
d_props.result.dbconn->addTimeMeasurementType("pv_behavior","Time for PV behavior in us");
d_props.result.dbconn->addTimeMeasurementType("ev_behavior","Time for EV behavior in us");
d_props.result.dbconn->addTimeMeasurementType("hp_behavior","Time for HP behavior in us");
d_props.result.dbconn->addTimeMeasurementType("chp_behavior","Time for CHP behavior in us");
d_props.result.dbconn->addTimeMeasurementType("wec_behavior","Time for WEC behavior in us");
d_props.result.dbconn->addTimeMeasurementType("bio_behavior","Time for biofuel behavior in us");
d_props.result.dbconn->addTimeMeasurementType("battery_behavior","Time for battery behavior in us");
d_props.result.dbconn->addTimeMeasurementType("compensator_behavior","Time for compensator behavior in us");
d_props.result.dbconn->addTimeMeasurementType("substation_behavior","Time for substation behavior in us");
d_props.result.dbconn->addTimeMeasurementType("slack_behavior","Time for slack behavior in us");
d_props.result.dbconn->addTimeMeasurementType("df_behavior","Time for DF behavior in us");
// initialize metadata
addMetaEntry(rank, "simulationmeta", "stop.at", props->getProperty("stop.at"));
......@@ -253,6 +279,19 @@ void ModelIO::finish_time_measurements(unsigned long &stop_at){
delete tm_init_MR;
delete tm_comm_partners_init;
delete tm_load;
delete tm_pv;
delete tm_ev;
delete tm_hp;
delete tm_chp;
delete tm_wec;
delete tm_bio;
delete tm_bat;
delete tm_comp;
delete tm_substation;
delete tm_slack;
delete tm_df;
}
......@@ -293,9 +332,22 @@ void ModelIO::log_results_for_tick() {
"," + std::to_string(tm_msg_proc_external->get_duration() / 1000000.0) +
"," + std::to_string(tm_behaviors->get_duration() / 1000000.0) +
"," + std::to_string(number_of_fbs_sweeps) +
"," + std::to_string(tm_rt_tick->get_duration() / 1000000.0)
"," + std::to_string(tm_rt_tick->get_duration() / 1000000.0) +
"," + std::to_string(tm_load->get_duration() / 1000000.0) +
"," + std::to_string(tm_pv->get_duration() / 1000000.0) +
"," + std::to_string(tm_ev->get_duration() / 1000000.0) +
"," + std::to_string(tm_hp->get_duration() / 1000000.0) +
"," + std::to_string(tm_chp->get_duration() / 1000000.0) +
"," + std::to_string(tm_wec->get_duration() / 1000000.0) +
"," + std::to_string(tm_bio->get_duration() / 1000000.0) +
"," + std::to_string(tm_bat->get_duration() / 1000000.0) +
"," + std::to_string(tm_comp->get_duration() / 1000000.0) +
"," + std::to_string(tm_substation->get_duration() / 1000000.0) +
"," + std::to_string(tm_slack->get_duration() / 1000000.0) +
"," + std::to_string(tm_df->get_duration() / 1000000.0)
);
#ifdef USE_DB
if(d_props.result.db_results){
......@@ -326,6 +378,21 @@ void ModelIO::log_results_for_tick() {
tm_behaviors->get_duration(), tick);
d_props.result.dbconn->addTimeMeasurement(tm_rt_tick->get_time_measurement_type(), tm_rt_tick->getId(),
tm_rt_tick->get_duration(), tick);
// Agent behavior time measurements
d_props.result.dbconn->addTimeMeasurement(tm_load->get_time_measurement_type(), tm_load->getId(), tm_load->get_duration(), tick);
d_props.result.dbconn->addTimeMeasurement(tm_pv->get_time_measurement_type(), tm_pv->getId(), tm_pv->get_duration(), tick);
d_props.result.dbconn->addTimeMeasurement(tm_ev->get_time_measurement_type(), tm_ev->getId(), tm_ev->get_duration(), tick);
d_props.result.dbconn->addTimeMeasurement(tm_hp->get_time_measurement_type(), tm_hp->getId(), tm_hp->get_duration(), tick);
d_props.result.dbconn->addTimeMeasurement(tm_chp->get_time_measurement_type(), tm_chp->getId(), tm_chp->get_duration(), tick);
d_props.result.dbconn->addTimeMeasurement(tm_wec->get_time_measurement_type(), tm_wec->getId(), tm_wec->get_duration(), tick);
d_props.result.dbconn->addTimeMeasurement(tm_bio->get_time_measurement_type(), tm_bio->getId(), tm_bio->get_duration(), tick);
d_props.result.dbconn->addTimeMeasurement(tm_bat->get_time_measurement_type(), tm_bat->getId(), tm_bat->get_duration(), tick);
d_props.result.dbconn->addTimeMeasurement(tm_comp->get_time_measurement_type(), tm_comp->getId(), tm_comp->get_duration(), tick);
d_props.result.dbconn->addTimeMeasurement(tm_substation->get_time_measurement_type(), tm_substation->getId(), tm_substation->get_duration(), tick);
d_props.result.dbconn->addTimeMeasurement(tm_slack->get_time_measurement_type(), tm_slack->getId(), tm_slack->get_duration(), tick);
d_props.result.dbconn->addTimeMeasurement(tm_df->get_time_measurement_type(), tm_df->getId(), tm_df->get_duration(), tick);
}
catch (const DBException &ex){
std::cout << "[DBEXCEPTION ON RANK " << rank << "] Error: " << ex.what() << std::endl;
......@@ -363,11 +430,52 @@ void ModelIO::reset_time_measurements() {
tm_msg_proc_internal->reset();
tm_msg_proc_external->reset();
tm_behaviors->reset();
tm_load->reset();
tm_pv->reset();
tm_ev->reset();
tm_hp->reset();
tm_chp->reset();
tm_wec->reset();
tm_bio->reset();
tm_bat->reset();
tm_comp->reset();
tm_substation->reset();
tm_slack->reset();
tm_df->reset();
}
void ModelIO::set_result_file_header() {
result_stream << "tick,tick time [s],sync time el [s],sync time MR [s],step time [s],forward backward sweep time [s],calculate components [s],forward sweep [s],backward sweep [s],msg proc time internal [s],msg proc time external [s],behavior calculation time [s],number of FBS sweeps,real time tick time [s]" << std::endl;
result_stream <<
"tick,tick time [s]," <<
"sync time el [s],"<<
"sync time MR [s],"<<
"step time [s]," <<
"forward backward sweep time [s],"<<
"calculate components [s],"<<
"forward sweep [s],"<<
"backward sweep [s],"<<
"msg proc time internal [s],"<<
"msg proc time external [s],"<<
"behavior calculation time [s],"<<
"number of FBS sweeps,"<<
"real time tick time [s]" <<
"Load behavior [s]," <<
"PV behavior [s]," <<
"EV behavior [s]," <<
"HP behavior [s]," <<
"CHP behavior [s]," <<
"WEC behavior [s]," <<
"Biofuel behavior [s]," <<
"Battery behavior [s]," <<
"Compensator behavior [s]," <<
"Substation behavior [s]," <<
"Slack behavior [s]," <<
"DF behavior [s]" <<
std::endl;
}
/*! \brief Log one line in csv file
......
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