Skip to content

Commit 0bff843

Browse files
author
janekdererste
committed
Load network from input folder if network is pre-partitioned.
Before we would copy the network into the output folder. This caused problems when the input folder is loaded onto computing nodes before executing the actual program.
1 parent ca73970 commit 0bff843

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

src/simulation/config.rs

-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ pub enum RoutingMode {
241241
AdHoc,
242242
UsePlans,
243243
}
244-
245244
#[derive(PartialEq, Debug, Clone, Serialize, Deserialize)]
246245
pub enum PartitionMethod {
247246
Metis(MetisOptions),

src/simulation/controller.rs

+18-21
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,18 @@ fn execute_partition<C: SimCommunicator + 'static>(comm: C, args: &CommandLineAr
103103
comm.barrier();
104104

105105
id::load_from_file(&io::resolve_path(config_path, &config.proto_files().ids));
106-
let network = Network::from_file_as_is(&get_numbered_output_filename(
107-
&output_path,
108-
&io::resolve_path(config_path, &config.proto_files().network),
109-
config.partitioning().num_parts,
110-
));
106+
// if we partition the network is copied to the output folder.
107+
// otherwise nothing is done and we can load the network from the input folder directly.
108+
let network_path = if let PartitionMethod::Metis(_) = config.partitioning().method {
109+
get_numbered_output_filename(
110+
&output_path,
111+
&io::resolve_path(config_path, &config.proto_files().network),
112+
config.partitioning().num_parts,
113+
)
114+
} else {
115+
io::resolve_path(config_path, &config.proto_files().network)
116+
};
117+
let network = Network::from_file_as_is(&network_path);
111118
let mut garage = Garage::from_file(&io::resolve_path(
112119
config_path,
113120
&config.proto_files().vehicles,
@@ -189,13 +196,16 @@ fn try_join(mut handles: IntMap<u32, JoinHandle<()>>) {
189196

190197
pub fn partition_input(config: &Config, config_path: &String) {
191198
id::load_from_file(&io::resolve_path(config_path, &config.proto_files().ids));
192-
let _net = if let PartitionMethod::Metis(_) = config.partitioning().method {
199+
if let PartitionMethod::Metis(_) = config.partitioning().method {
193200
info!("Config param Partition method was set to metis. Loading input network, running metis conversion and then store it into output folder");
194-
partition_network(config, config_path)
195-
} else {
201+
partition_network(config, config_path);
202+
}
203+
// don't do anything. If the network is already partitioned, we'll load it from the input folder.
204+
/*else {
196205
info!("Config param Partition method was set to none. Loading network from input, assuming it has partitioning information");
197206
copy_network_into_output(config, config_path)
198207
};
208+
*/
199209
}
200210

201211
fn partition_network(config: &Config, config_path: &String) -> Network {
@@ -212,19 +222,6 @@ fn partition_network(config: &Config, config_path: &String) -> Network {
212222
network
213223
}
214224

215-
fn copy_network_into_output(config: &Config, config_path: &String) -> Network {
216-
let net_in_path = io::resolve_path(config_path, &config.proto_files().network);
217-
let num_parts = config.partitioning().num_parts;
218-
let network = Network::from_file_as_is(&net_in_path);
219-
let mut net_out_path = create_output_filename(
220-
&io::resolve_path(config_path, &config.output().output_dir),
221-
&net_in_path,
222-
);
223-
net_out_path = insert_number_in_proto_filename(&net_out_path, num_parts);
224-
network.to_file(&net_out_path);
225-
network
226-
}
227-
228225
pub fn get_numbered_output_filename(output_dir: &Path, input_file: &Path, part: u32) -> PathBuf {
229226
let out = create_output_filename(output_dir, input_file);
230227
insert_number_in_proto_filename(&out, part)

0 commit comments

Comments
 (0)