// ---------------------------------------------------------------------- void SimulationTaskLocalizationEvaluation::Results:: collect_information( SimulationController& sc, const SimulationTaskLocalizationEvaluation& stle ) throw() { LocalizationObserver observer; if ( sc.world().communication_model().exists_communication_upper_bound() ) comm_range = sc.world().communication_model().communication_upper_bound(); set_seed( sc, stle ); for( World::node_iterator it = sc.world_w().begin_nodes_w(); it != sc.world_w().end_nodes_w(); ++it ) { Node& v = *it; LocalizationProcessor* lp = v.get_processor_of_type_w<LocalizationProcessor>(); if ( lp == NULL || lp->is_anchor() ) continue; observer.set_owner( *lp ); if ( v.has_est_position() ) { ++has_pos_cnt; double distance = euclidean_distance( v.real_position(), v.est_position() ); stat_abs_position += distance; } else { ++no_pos_cnt; } stat_known_anchors += observer.anchor_cnt(); stat_valid_known_anchors += observer.valid_anchor_cnt(); observer.fill_stat_rel_anchor_distance( stat_real_err_anchor_dist, stat_comm_err_anchor_dist ); observer.fill_stat_rel_neighbor_distance( stat_real_neighbor_dist, stat_comm_neighbor_dist ); stat_neighbor_cnt += (double)observer.neighbor_cnt(); }// for all nodes }
// ---------------------------------------------------------------------- DIPostscriptWriter:: DIPostscriptWriter(std::ostream& psfile, SimulationController& sc) : psfile_(psfile), pageNo_(1), eps_(false) { // eps ? eps_header() : ps_header(); ps_header(); calcOffset(sc.world()); //newpage(); setlinewidth2(0.1); }
// ---------------------------------------------------------------------- // ---------------------------------------------------------------------- void WisemlWriterTask::run(SimulationController &sc) throw() { std::string filename = sc.environment().optional_string_param("filename", "simulation.wiseml"); std::ofstream file; file.open(filename.c_str()); std::string wml; WisemlDataKeeper *keeper = sc.keeper_by_name_w<WisemlDataKeeper>("wiseml_data_keeper"); WisemlSetupCollector &setup = keeper->setup(); setup.set_timeinfo_duration(sc.world().current_time()); wml = keeper->generate_xml(); file << wml; file.close(); }
// ---------------------------------------------------------------------- void SimulationTaskLocalizationEvaluation:: print_ps( const SimulationController& sc, const HeaderInfo& header ) const throw() { std::string fname = sc.environment().optional_string_param( "loc_ps_out", "" ); if ( fname == "" ) return; std::ofstream psout( fname.c_str() ); LocalizationPsWriter psw( psout, false ); std::string info = "Dist: " + header.dist_algo + "; Pos: " + header.pos_algo + "; Ref: " + header.ref_algo; psw.paint_color( sc.world(), info, true ); }
// ---------------------------------------------------------------------- void SimulationTaskLocalizationEvaluation::HeaderInfo:: collect_information( SimulationController& sc, const SimulationTaskLocalizationEvaluation& stle ) throw() { LocalizationObserver observer; if ( sc.world().communication_model().exists_communication_upper_bound() ) comm_range = sc.world().communication_model().communication_upper_bound(); world_width = sc.world().upper_right().x() - sc.world().lower_left().x(); world_height = sc.world().upper_right().y() - sc.world().lower_left().y(); set_placement( sc, stle ); for( World::node_iterator it = sc.world_w().begin_nodes_w(); it != sc.world_w().end_nodes_w(); ++it ) { Node& v = *it; LocalizationProcessor* lp = v.get_processor_of_type_w<LocalizationProcessor>(); if ( lp == NULL ) continue; if ( lp->is_anchor() ) ++anchor_cnt; else ++unknown_cnt; observer.set_owner( *lp ); startup_anchor_frac = observer.startup_anchor_frac(); dist_algo = observer.distance_algorithm(); pos_algo = observer.position_algorithm(); ref_algo = observer.refinement_algorithm(); floodlimit = observer.floodlimit(); idle_time = observer.idle_time(); } }