Skip to content

Commit

Permalink
Add an all-pairs OD pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Feb 22, 2024
1 parent 2a924d7 commit 410fd23
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions od2net/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ pub enum ODPattern {
},
/// Just read GeoJSON LineStrings from this path
LineStrings(String),
/// One trip from every intersection to every other intersection. This is likely a very
/// unrealistic pattern.
AllPairsIntersections,
}

#[derive(Clone, PartialEq, Serialize, Deserialize)]
Expand Down
1 change: 1 addition & 0 deletions od2net/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ fn main() -> Result<()> {
let requests = od2net::od::generate_requests(
&config.requests,
format!("{directory}/input"),
&network,
args.rng_seed,
&mut timer,
)?;
Expand Down
11 changes: 11 additions & 0 deletions od2net/src/od.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ use rstar::{RTree, AABB};
use serde::Deserialize;

use super::config::{ODPattern, Requests};
use super::network::Network;
use super::requests::Request;
use super::timer::Timer;

pub fn generate_requests(
config: &Requests,
input_directory: String,
network: &Network,
rng_seed: u64,
timer: &mut Timer,
) -> Result<Vec<Request>> {
Expand Down Expand Up @@ -177,6 +179,15 @@ pub fn generate_requests(
requests = Request::load_from_geojson(format!("{input_directory}/{path}"))?;
timer.stop();
}
ODPattern::AllPairsIntersections => {
for from in network.intersections.values() {
let (x1, y1) = from.to_degrees();
for to in network.intersections.values() {
let (x2, y2) = to.to_degrees();
requests.push(Request { x1, y1, x2, y2 });
}
}
}
}

Ok(requests)
Expand Down

0 comments on commit 410fd23

Please sign in to comment.