@@ -10,14 +10,13 @@ use nohash_hasher::IntMap;
10
10
use tracing:: info;
11
11
12
12
use crate :: simulation:: config:: { CommandLineArgs , Config , PartitionMethod , RoutingMode } ;
13
- use crate :: simulation:: id:: Id ;
14
13
use crate :: simulation:: io:: proto_events:: ProtoEventsWriter ;
15
14
use crate :: simulation:: messaging:: communication:: communicators:: {
16
15
ChannelSimCommunicator , MpiSimCommunicator , SimCommunicator ,
17
16
} ;
18
17
use crate :: simulation:: messaging:: communication:: message_broker:: NetMessageBroker ;
19
18
use crate :: simulation:: messaging:: events:: EventsPublisher ;
20
- use crate :: simulation:: network:: global_network:: { Link , Network } ;
19
+ use crate :: simulation:: network:: global_network:: Network ;
21
20
use crate :: simulation:: network:: sim_network:: SimNetworkPartition ;
22
21
use crate :: simulation:: population:: population:: Population ;
23
22
use crate :: simulation:: replanning:: replanner:: { DummyReplanner , ReRouteTripReplanner , Replanner } ;
@@ -110,13 +109,11 @@ fn execute_partition<C: SimCommunicator + 'static>(comm: C, args: &CommandLineAr
110
109
) ) ;
111
110
let mut garage = Garage :: from_file ( & PathBuf :: from ( config. proto_files ( ) . vehicles ) ) ;
112
111
113
- let population: Population = Population :: from_file (
114
- & get_numbered_output_filename (
115
- & output_path,
116
- & PathBuf :: from ( config. proto_files ( ) . population ) ,
117
- rank,
118
- ) ,
112
+ let population = Population :: from_file_filtered_part (
113
+ & PathBuf :: from ( config. proto_files ( ) . population ) ,
114
+ & network,
119
115
& mut garage,
116
+ comm. rank ( ) ,
120
117
) ;
121
118
122
119
let network_partition = SimNetworkPartition :: from_network ( & network, rank, config. simulation ( ) ) ;
@@ -183,15 +180,13 @@ fn try_join(mut handles: IntMap<u32, JoinHandle<()>>) {
183
180
184
181
pub fn partition_input ( config : & Config ) {
185
182
id:: load_from_file ( & PathBuf :: from ( config. proto_files ( ) . ids ) ) ;
186
- let net = if let PartitionMethod :: Metis ( _) = config. partitioning ( ) . method {
183
+ let _net = if let PartitionMethod :: Metis ( _) = config. partitioning ( ) . method {
187
184
info ! ( "Config param Partition method was set to metis. Loading input network, running metis conversion and then store it into output folder" ) ;
188
185
partition_network ( config)
189
186
} else {
190
187
info ! ( "Config param Partition method was set to none. Loading network from input, assuming it has partitioning information" ) ;
191
188
copy_network_into_output ( config)
192
189
} ;
193
-
194
- partition_population ( config, & net) ;
195
190
}
196
191
197
192
fn partition_network ( config : & Config ) -> Network {
@@ -217,38 +212,6 @@ fn copy_network_into_output(config: &Config) -> Network {
217
212
network
218
213
}
219
214
220
- fn partition_population ( config : & Config , network : & Network ) {
221
- info ! (
222
- "Partition population into {} parts" ,
223
- config. partitioning( ) . num_parts
224
- ) ;
225
- let pop_in_path = PathBuf :: from ( config. proto_files ( ) . population ) ;
226
- let num_parts = config. partitioning ( ) . num_parts ;
227
- let pop = Population :: from_file ( & pop_in_path, & mut Garage :: new ( ) ) ;
228
- let mut part_pops = vec ! [ ] ;
229
- for _i in 0 ..num_parts {
230
- part_pops. push ( Population :: new ( ) )
231
- }
232
-
233
- let pop_out_path =
234
- create_output_filename ( & PathBuf :: from ( config. output ( ) . output_dir ) , & pop_in_path) ;
235
-
236
- for ( id, person) in pop. persons . into_iter ( ) {
237
- let link_id: Id < Link > = Id :: get ( person. curr_act ( ) . link_id ) ;
238
- let partition = network. get_link ( & link_id) . partition ;
239
- part_pops
240
- . get_mut ( partition as usize )
241
- . unwrap ( )
242
- . persons
243
- . insert ( id, person) ;
244
- }
245
-
246
- for ( i, population) in part_pops. iter ( ) . enumerate ( ) {
247
- let part_out_path = insert_number_in_proto_filename ( & pop_out_path, i as u32 ) ;
248
- population. to_file ( & part_out_path) ;
249
- }
250
- }
251
-
252
215
pub fn get_numbered_output_filename ( output_dir : & Path , input_file : & Path , part : u32 ) -> PathBuf {
253
216
let out = create_output_filename ( output_dir, input_file) ;
254
217
insert_number_in_proto_filename ( & out, part)
0 commit comments