feat: final commit
This commit is contained in:
parent
416d97c513
commit
e9bb791be1
3 changed files with 58 additions and 33 deletions
|
|
@ -1,19 +1,20 @@
|
|||
[@@@warning "-27-50-69"]
|
||||
let todo = assert false
|
||||
|
||||
|
||||
|
||||
(* Little OCaml reminder: *)
|
||||
type _s = A | B of int | C of float * string (* sum types *)
|
||||
type _t = { a : int; b : int; } (* product types *)
|
||||
type _t = { a : int; b : int; }
|
||||
|
||||
let _f () =
|
||||
let x = { a = 0; b = 1 } in
|
||||
let y = { x with a = 2 } in (* same as "x", except field "a" *)
|
||||
assert (y = { a = 2; b = 1 })
|
||||
|
||||
(* Everything is immutable, except explicitly declared record fields! *)
|
||||
type _q = { c : int (* immutable *); mutable d : int; }
|
||||
(* Everything is immutable (at least in this presentation)! *)
|
||||
|
||||
|
||||
|
||||
(* Types can be parameterized by other types: *)
|
||||
type 'a _llist = Nil | Cons of { v : 'a; mutable next : 'a _llist }
|
||||
|
||||
|
||||
|
||||
|
|
@ -29,7 +30,7 @@ type ('i, 'o, 'r) dnode =
|
|||
|
||||
(** Run a discrete node on a list of inputs *)
|
||||
let drun (DNode n : ('i, 'o, 'r) dnode) (i : 'i list) : 'o list =
|
||||
snd (List.fold_left_map n.step n.state i)
|
||||
todo
|
||||
|
||||
|
||||
|
||||
|
|
@ -153,7 +154,7 @@ let compose_solvers : ('y, 'yder) csolver ->
|
|||
let step (cstate, zstate) h =
|
||||
let cstate, y = csolver.step cstate h in
|
||||
let zstate, (h, z) = zsolver.step zstate y in
|
||||
(cstate, zstate), ({ y with h }, z) in
|
||||
(cstate, zstate), (todo (*?*), z) in
|
||||
let reset (cstate, zstate) (ivp, zcp) =
|
||||
(csolver.reset cstate ivp, zsolver.reset zstate zcp) in
|
||||
DNode { state; step; reset }
|
||||
|
|
@ -206,12 +207,12 @@ let dstep (State ({ model = HNode m; solver = DNode s; _ } as state)) =
|
|||
else if state.time >= i.h then
|
||||
State { state with input = None; model; time = 0. }
|
||||
else
|
||||
let y0 = m.cget ms and h = i.h -. state.time and ofs = (+.) state.time in
|
||||
let y0 = todo (*?*) and h = i.h -. state.time and ofs = (+.) state.time in
|
||||
let ivp = { h; y0; fder = fun t y -> m.fder ms (ofs t) (i.f (ofs t)) y } in
|
||||
let zcp = { h; y0; fzer = fun t y -> m.fzer ms (ofs t) (i.f (ofs t)) y } in
|
||||
let solver = DNode { s with state = s.reset s.state (ivp, zcp) } in
|
||||
let input = Some { h; f = fun t -> i.f (ofs t) } in
|
||||
State { model; solver; mode = C; time = 0.; input } in
|
||||
State { model; solver; mode = todo (*?*); time = 0.; input } in
|
||||
state, Some { h = 0.; f = fun _ -> o }
|
||||
|
||||
|
||||
|
|
@ -264,3 +265,6 @@ let hrun (model : ('i, 'o, 'r, 'y, 'yder, 'zin, 'zout) hnode)
|
|||
if o = None then (sim, List.rev_map Option.get os)
|
||||
else step (o :: os) sim None in
|
||||
List.fold_left_map (step []) sim i |> snd |> List.flatten
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue