feat: cleanup
This commit is contained in:
parent
e07f165494
commit
c867859cce
3 changed files with 27 additions and 18 deletions
|
|
@ -6,6 +6,7 @@ open State
|
|||
module LazySim (S : SimState) =
|
||||
struct
|
||||
|
||||
(** "Lazy" simulation of a model with an appropriate solver. *)
|
||||
let run
|
||||
(HNode model : ('p, 'a, 'b, 'y, 'yder, 'zin, 'zout) hnode)
|
||||
(DNode solver : ('y, 'yder, 'zin, 'zout) solver)
|
||||
|
|
@ -64,6 +65,8 @@ module LazySim (S : SimState) =
|
|||
S.update ms ss (S.set_idle s) in
|
||||
DNode { state; step; reset }
|
||||
|
||||
(** Run the model on the given input until the end of the input or until the
|
||||
model stops answering. *)
|
||||
let run_on model solver input use =
|
||||
let DNode sim = run model solver in
|
||||
let state = match sim.step sim.state (Some input) with
|
||||
|
|
@ -75,6 +78,8 @@ module LazySim (S : SimState) =
|
|||
| Some o -> use o; loop (DNode { s with state }) in
|
||||
loop (DNode { sim with state })
|
||||
|
||||
(** Run the model autonomously until [length], or until the model stops
|
||||
answering. *)
|
||||
let run_until model solver length =
|
||||
run_on model solver { start = 0.0; length; u = fun _ -> () }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue