Skip to content

Commit

Permalink
Merge pull request #194 from NREL/ndr/small-fixes
Browse files Browse the repository at this point in the history
Add distance to state model in SpeedTraversalModel and other small fixes
  • Loading branch information
nreinicke authored Apr 30, 2024
2 parents 157dacc + 740683f commit 0a07182
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ impl TraversalModel for SpeedTraversalModel {
&estimated_time,
&self.engine.time_unit,
)?;
state_model.add_distance(
state,
&Self::DISTANCE.into(),
&distance,
&self.engine.distance_unit,
)?;

Ok(())
}
Expand Down
34 changes: 34 additions & 0 deletions rust/routee-compass-core/src/util/priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,37 @@ impl<I: Hash + Eq, P: Ord> Default for InternalPriorityQueue<I, P, RandomState>
InternalPriorityQueue(PriorityQueue::new())
}
}

mod tests {
use crate::{
model::{
road_network::vertex_id::VertexId,
unit::{cost::ReverseCost, Cost},
},
util::priority_queue::InternalPriorityQueue,
};

#[test]
fn test_priority_queue() {
let mut costs: InternalPriorityQueue<VertexId, ReverseCost> =
InternalPriorityQueue::default();

costs.push(VertexId(0), Cost::from(0.0003).into());
costs.push(VertexId(1), Cost::from(0.0001).into());
costs.push(VertexId(2), Cost::from(0.0002).into());

let (vertex_id, _cost) = costs.pop().unwrap();

assert_eq!(vertex_id, VertexId(1));

costs.push_increase(VertexId(0), Cost::from(0.00001).into());

let (vertex_id, _cost) = costs.pop().unwrap();

assert_eq!(vertex_id, VertexId(0));

let (vertex_id, _cost) = costs.pop().unwrap();

assert_eq!(vertex_id, VertexId(2));
}
}
2 changes: 1 addition & 1 deletion rust/routee-compass/src/app/cli/cli_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct CliArgs {
pub query_file: String,

/// Size of batches to load into memory at a time
#[arg(short, long)]
#[arg(long)]
pub chunksize: Option<i64>,

/// Format of JSON queries file, if regular JSON or newline-delimited JSON
Expand Down

0 comments on commit 0a07182

Please sign in to comment.