use rust_decimal::Decimal;
pub trait SimModelTrait<const LEN_Y: usize, const LEN_P: usize, const LEN_B: usize> {
fn new() -> Self;
fn init(&self) -> (f64, [f64; LEN_Y]);
fn ode(&self, t: &f64, y: &[f64; LEN_Y], deriv_y: &mut [f64; LEN_Y]);
fn rec(&self, t: &f64, y: &[f64; LEN_Y], delta_y: &mut [f64; LEN_Y], act: &[bool; LEN_B]);
fn cond(
&self,
dec_t: &Decimal,
act: &mut [bool; LEN_B],
next_t: &[Decimal; LEN_B],
y: &[f64; LEN_Y],
);
fn beat(&self, t: &f64, y: &[f64; LEN_Y]) -> [[Decimal; 3]; LEN_B];
fn cre(&self, t: &f64, y: &mut [f64; LEN_Y]);
}
pub trait OptModelTrait<
const LEN_Y: usize,
const LEN_P: usize,
const LEN_B: usize,
const LEN_X: usize,
>: SimModelTrait<LEN_Y, LEN_P, LEN_B> + Clone + Send + 'static
{
fn getp(&self) -> &[f64; LEN_P] {
unimplemented!(
"\nplease implement setp function in OptModelTrait:\n
fn setp(&mut self, index: usize, value: f64) {{
self.p[index] = value;
}}\n
"
);
}
fn getx(&self) -> (Vec<usize>, Option<Vec<(f64, f64)>>);
fn setp(&mut self, _index: usize, _value: f64) {
unimplemented!(
"\nplease implement setp function in OptModelTrait:\n
fn setp(&mut self, index: usize, value: f64) {{
self.p[index] = value;
}}\n
"
);
}
}