Skip to content

Commit

Permalink
Merge pull request #53 from NREL/feature/speed-set-stuff
Browse files Browse the repository at this point in the history
improved speed_set and speed_sets validation
  • Loading branch information
calbaker authored Apr 12, 2024
2 parents 87ac72c + 669a0a7 commit 4a2e6b0
Show file tree
Hide file tree
Showing 9 changed files with 239 additions and 49 deletions.
1 change: 1 addition & 0 deletions python/altrios/altrios_pyo3.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,7 @@ class Network(SerdeAPI):
def __getitem__(self, index) -> Any: ...
def __len__(self) -> Any: ...
def __setitem__(self, index, object) -> Any: ...
def set_speed_set_for_train_type(self, train_type: TrainType): ...


@dataclass
Expand Down
3 changes: 2 additions & 1 deletion python/altrios/demos/set_speed_train_sim_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
cars_empty=50,
cars_loaded=50,
rail_vehicle_type="Manifest",
train_type=alt.TrainType.Freight,
train_type=None,
train_length_meters=None,
train_mass_kilograms=None,
)
Expand Down Expand Up @@ -66,6 +66,7 @@

network = alt.Network.from_file(
alt.resources_root() / "networks/Taconite.yaml")
network.set_speed_set_for_train_type(alt.TrainType.Freight)
link_path = alt.LinkPath.from_csv_file(
alt.resources_root() / "demo_data/link_points_idx.csv"
)
Expand Down
157 changes: 139 additions & 18 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rust/altrios-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ serde-this-or-that = "0.4.2"
project-root = "0.2.2"
eng_fmt = { workspace = true }
directories = "5.0.1"
tempfile = "3.10.1"

[features]
pyo3 = ["dep:pyo3"]
8 changes: 4 additions & 4 deletions rust/altrios-core/src/meet_pass/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,10 @@ mod test_dispatch {

#[test]
fn test_simple_dispatch() {
let mut network_file_path = project_root::get_project_root().unwrap();
network_file_path.push("../python/altrios/resources/networks/Taconite.yaml");
let network = Network::from_file(network_file_path.as_os_str().to_str().unwrap()).unwrap();
network.validate().unwrap();
let network_file_path = project_root::get_project_root()
.unwrap()
.join("../python/altrios/resources/networks/Taconite.yaml");
let network = Network::from_file(network_file_path).unwrap();

let train_sims = vec![
crate::train::speed_limit_train_sim_fwd(),
Expand Down
16 changes: 8 additions & 8 deletions rust/altrios-core/src/meet_pass/train_disp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ mod test_train_disp {

#[test]
fn test_make_train_fwd() {
let mut network_file_path = project_root::get_project_root().unwrap();
network_file_path.push("../python/altrios/resources/networks/Taconite.yaml");
let network = Network::from_file(network_file_path.as_os_str().to_str().unwrap()).unwrap();
network.validate().unwrap();
let network_file_path = project_root::get_project_root()
.unwrap()
.join("../python/altrios/resources/networks/Taconite.yaml");
let network = Network::from_file(network_file_path).unwrap();

let speed_limit_train_sim = crate::train::speed_limit_train_sim_fwd();
let est_times = make_est_times(&speed_limit_train_sim, &network).unwrap().0;
Expand All @@ -243,11 +243,11 @@ mod test_train_disp {
#[test]
fn test_make_train_rev() {
// TODO: Make this test depend on a better file
let mut network_file_path = project_root::get_project_root().unwrap();
network_file_path.push("../python/altrios/resources/networks/Taconite.yaml");
let network = Network::from_file(network_file_path.as_os_str().to_str().unwrap()).unwrap();
let network_file_path = project_root::get_project_root()
.unwrap()
.join("../python/altrios/resources/networks/Taconite.yaml");
let network = Network::from_file(network_file_path).unwrap();

network.validate().unwrap();
let speed_limit_train_sim = crate::train::speed_limit_train_sim_rev();
let est_times = make_est_times(&speed_limit_train_sim, &network).unwrap().0;
TrainDisp::new(
Expand Down
Loading

0 comments on commit 4a2e6b0

Please sign in to comment.