1+ use std:: cmp:: Ordering ;
2+ use std:: collections:: HashMap ;
3+ use std:: io:: Cursor ;
4+
5+ use prost:: Message ;
6+
17use crate :: simulation:: config:: RoutingMode ;
28use crate :: simulation:: id_mapping:: { MatsimIdMapping , MatsimIdMappings } ;
39use crate :: simulation:: io:: matsim_id:: MatsimId ;
@@ -11,10 +17,6 @@ use crate::simulation::messaging::messages::proto::{
1117} ;
1218use crate :: simulation:: network:: node:: NodeVehicle ;
1319use crate :: simulation:: time_queue:: EndTime ;
14- use prost:: Message ;
15- use std:: cmp:: Ordering ;
16- use std:: collections:: HashMap ;
17- use std:: io:: Cursor ;
1820
1921// Include the `messages` module, which is generated from messages.proto.
2022pub mod proto {
@@ -181,6 +183,14 @@ impl Agent {
181183 }
182184 }
183185
186+ pub fn new ( id : u64 , plan : Plan ) -> Self {
187+ Agent {
188+ id,
189+ curr_plan_elem : 0 ,
190+ plan : Some ( plan) ,
191+ }
192+ }
193+
184194 pub fn id ( & self ) -> usize {
185195 self . id as usize
186196 }
@@ -368,7 +378,7 @@ impl EndTime for Agent {
368378impl Plan {
369379 pub const DEFAULT_ROUTING_MODE : & ' static str = "car" ;
370380
371- fn new ( ) -> Plan {
381+ pub fn new ( ) -> Plan {
372382 Plan {
373383 acts : Vec :: new ( ) ,
374384 legs : Vec :: new ( ) ,
@@ -492,6 +502,14 @@ impl Plan {
492502 result
493503 }
494504
505+ pub fn add_leg ( & mut self , leg : Leg ) {
506+ self . legs . push ( leg) ;
507+ }
508+
509+ pub fn add_act ( & mut self , activity : Activity ) {
510+ self . acts . push ( activity) ;
511+ }
512+
495513 fn get_plan_type ( io_plan : & IOPlan ) -> PlanType {
496514 if let IOPlanElement :: Activity ( _) = io_plan. elements . get ( 1 ) . unwrap ( ) {
497515 return PlanType :: ActivitiesOnly ;
@@ -584,6 +602,26 @@ impl Activity {
584602 }
585603 }
586604
605+ pub fn new (
606+ x : f32 ,
607+ y : f32 ,
608+ act_type : String ,
609+ link_id : u64 ,
610+ start_time : Option < u32 > ,
611+ end_time : Option < u32 > ,
612+ max_dur : Option < u32 > ,
613+ ) -> Self {
614+ Activity {
615+ x,
616+ y,
617+ act_type,
618+ link_id,
619+ start_time,
620+ end_time,
621+ max_dur,
622+ }
623+ }
624+
587625 fn cmp_end_time ( & self , now : u32 ) -> u32 {
588626 if let Some ( end_time) = self . end_time {
589627 end_time
@@ -611,6 +649,15 @@ impl Leg {
611649 }
612650 }
613651
652+ pub fn new ( route : Route , mode : & str , trav_time : Option < u32 > , dep_time : Option < u32 > ) -> Self {
653+ Self {
654+ route : Some ( route) ,
655+ mode : String :: from ( mode) ,
656+ trav_time,
657+ dep_time,
658+ }
659+ }
660+
614661 fn only_with_mode ( mode : & str ) -> Self {
615662 Self {
616663 mode : mode. to_string ( ) ,
@@ -686,6 +733,13 @@ impl NetworkRoute {
686733 vehicle_id : * veh_id as u64 ,
687734 }
688735 }
736+
737+ pub fn new ( vehicle_id : u64 , link_ids : Vec < u64 > ) -> Self {
738+ Self {
739+ vehicle_id,
740+ route : link_ids,
741+ }
742+ }
689743}
690744
691745fn parse_time_opt ( value : & Option < String > ) -> Option < u32 > {
0 commit comments