cargo fmt, mostly just to trigger [rebuild]

This commit is contained in:
Dustin Carlino 2020-04-05 18:20:19 -07:00
parent ec29ade70e
commit 3e462cda90
4 changed files with 29 additions and 18 deletions

View File

@ -20,6 +20,7 @@ pub use self::make::{
pub(crate) use self::mechanics::{
DrivingSimState, IntersectionSimState, ParkingSimState, WalkingSimState,
};
pub(crate) use self::pandemic::PandemicModel;
pub(crate) use self::router::{ActionAtEnd, Router};
pub(crate) use self::scheduler::{Command, Scheduler};
pub use self::sim::{AgentProperties, Sim, SimOptions};
@ -37,7 +38,6 @@ use map_model::{
BuildingID, BusStopID, DirectedRoadID, IntersectionID, LaneID, Map, Path, PathConstraints,
PathRequest, Position,
};
pub(crate) use self::pandemic::PandemicModel;
use serde_derive::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::fmt;

View File

@ -1,9 +1,9 @@
mod prob;
mod pandemic;
mod prob;
pub use prob::{proba_decaying_sigmoid, erf_distrib_bounded};
pub use pandemic::{PandemicModel, Cmd};
use geom::{Duration};
use geom::Duration;
pub use pandemic::{Cmd, PandemicModel};
pub use prob::{erf_distrib_bounded, proba_decaying_sigmoid};
pub enum SEIR {
Sane,
@ -38,9 +38,7 @@ impl SEIR {
SEIR::Sane => Duration::seconds(SEIR::T_INF / SEIR::R_0 / 2.0),
SEIR::Exposed => Duration::seconds(SEIR::T_INC / 2.0),
SEIR::Infectious => Duration::seconds(SEIR::T_INF / 2.0),
SEIR::Recovered => {
panic!("Impossible to transition from Recovered state")
}
SEIR::Recovered => panic!("Impossible to transition from Recovered state"),
}
}

View File

@ -1,6 +1,6 @@
use crate::{CarID, Command, Event, Person, PersonID, Scheduler, TripPhaseType};
use crate::pandemic::SEIR;
use crate::pandemic::{proba_decaying_sigmoid, erf_distrib_bounded};
use crate::pandemic::{erf_distrib_bounded, proba_decaying_sigmoid};
use crate::{CarID, Event, Person, PersonID, Scheduler, TripPhaseType};
use geom::{Duration, Time};
use map_model::{BuildingID, BusStopID};
use rand::Rng;
@ -162,7 +162,8 @@ impl PandemicModel {
assert!(self.initialized);
// TODO Here we might enforce policies. Like severe -> become hospitalized
// Symptomatic -> stay quaratined, and/or track contacts to quarantine them too (or test them)
// Symptomatic -> stay quaratined, and/or track contacts to quarantine them too (or test
// them)
match cmd {
Cmd::BecomeHospitalized(person) => {
self.hospitalized.insert(person);

View File

@ -22,7 +22,10 @@ pub fn erf_distrib(t: f64, mu: f64, sigma: f64) -> f64 {
// t1 >= t0
pub fn erf_distrib_bounded(t0: f64, t1: f64, mu: f64, sigma: f64) -> f64 {
if t1 < t0 {
panic!("Error t0 = {} < and t1 = {}. t1 must be larger than t0.", t0, t1);
panic!(
"Error t0 = {} < and t1 = {}. t1 must be larger than t0.",
t0, t1
);
}
if sigma < 0.0 {
panic!("Error sigma must be always be positive but was {}", sigma);
@ -32,7 +35,6 @@ pub fn erf_distrib_bounded(t0: f64, t1: f64, mu: f64, sigma: f64) -> f64 {
- 0.5 * libm::erf((-t1 + mu) / (f64::sqrt(2.0) * sigma))
}
#[cfg(test)]
mod tests {
use super::*;
@ -54,7 +56,10 @@ mod tests {
let max = 100;
let mut rng = rand::thread_rng();
for _ in 0..max {
prob_range(proba_decaying_sigmoid(rng.gen::<f64>() * range, rng.gen::<f64>() * range));
prob_range(proba_decaying_sigmoid(
rng.gen::<f64>() * range,
rng.gen::<f64>() * range,
));
}
}
@ -64,11 +69,14 @@ mod tests {
let max = 100;
let mut rng = rand::thread_rng();
for _ in 0..max {
prob_range(erf_distrib(rng.gen::<f64>() * range, rng.gen::<f64>() * range, rng.gen::<f64>() * range));
prob_range(erf_distrib(
rng.gen::<f64>() * range,
rng.gen::<f64>() * range,
rng.gen::<f64>() * range,
));
}
}
#[test]
fn test_range_erf_distrib_bounded() {
let range = 1000.0;
@ -77,7 +85,12 @@ mod tests {
for _ in 0..max {
let t0 = rng.gen::<f64>() * range;
let t1 = t0 + 1.0;
prob_range(erf_distrib_bounded(t0, t1, rng.gen::<f64>() * range, rng.gen::<f64>() * range));
prob_range(erf_distrib_bounded(
t0,
t1,
rng.gen::<f64>() * range,
rng.gen::<f64>() * range,
));
}
}
@ -98,5 +111,4 @@ mod tests {
fn test_sigma_erf_distrib_bounded() {
erf_distrib_bounded(1.0, 2.0, 1.0, -1.0);
}
}