Skip to content

Commit

Permalink
Lag re-implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Siel committed Nov 23, 2023
1 parent b873ec9 commit db56cb2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions examples/bimodal_ke/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,17 @@ struct Ode {}
impl<'a> Predict<'a> for Ode {
type Model = Model;
type State = State;
fn initial_system(&self, params: &Vec<f64>, scenario: Scenario) -> Self::Model {
fn initial_system(&self, params: &Vec<f64>, scenario: Scenario) -> (Self::Model, Scenario) {
let params = HashMap::from([("ke".to_string(), params[0]), ("v".to_string(), params[1])]);
Model {
(Model {
params,
_scenario: scenario,
_scenario: scenario.clone(),//TODO remove
infusions: vec![],
cov: None,
}
},
scenario.reorder_with_lag(vec![(0.0, 1)])
)

}
fn get_output(&self, x: &Self::State, system: &Self::Model, outeq: usize) -> f64 {
let v = system.get_param("v");
Expand Down
4 changes: 2 additions & 2 deletions src/routines/simulation/predict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl Model {
pub trait Predict<'a> {
type Model: 'a + Clone;
type State;
fn initial_system(&self, params: &Vec<f64>, scenario: Scenario) -> Self::Model;
fn initial_system(&self, params: &Vec<f64>, scenario: Scenario) -> (Self::Model, Scenario);
fn initial_state(&self) -> Self::State;
fn add_covs(&self, system: Self::Model, cov: Option<HashMap<String, CovLine>>) -> Self::Model;
fn add_infusion(&self, system: Self::Model, infusion: Infusion) -> Self::Model;
Expand Down Expand Up @@ -65,7 +65,7 @@ where
Self { ode }
}
pub fn pred(&self, scenario: Scenario, params: Vec<f64>) -> Vec<f64> {
let system = self.ode.initial_system(&params, scenario.clone());
let (system, scenario) = self.ode.initial_system(&params, scenario.clone());
let mut yout = vec![];
let mut x = self.ode.initial_state();
let mut index: usize = 0;
Expand Down

0 comments on commit db56cb2

Please sign in to comment.