Commit 6037cafc authored by Benoit Barbot's avatar Benoit Barbot
Browse files

absolute time for cosim

parent 38f0883e
Pipeline #2245 passed with stages
in 2 minutes and 11 seconds
version=0.15.0
version=0.19.0
......@@ -72,33 +72,43 @@ struct
type out = unit
type monitor_state = {
mutable total_time : float;
mutable total_length : int;
mutable apericube : int;
}
type t =
Format.formatter
* (weight, bound) ZoneGraph.t
* style
* (int * int * float) ref
* monitor_state
* (string ->
(float Sampling.transChoice * string Sampling.transChoice) list)
let new_traj (_, _, _, mon_state, _) = mon_state := (0, 0, 0.0)
let new_traj (_, _, _, mon_state, _) =
mon_state.total_time <- 0.0;
mon_state.total_length <- 0;
mon_state.apericube <- 0
let init outfile rg ost parse_action =
let mon_state = ref (0, 0, 0.0) in
let mon_state = { total_time = 0.0; total_length = 0; apericube = 0 } in
((outfile, rg, ost, mon_state, parse_action) : t)
let end_traj (outfile, _, (ost, _), mon_state, _) store_traj =
( if store_traj then
let aper, size, duration = !mon_state in
Format.fprintf outfile "%i\t%i\t%g" aper size duration );
if store_traj then
Format.fprintf outfile "%i\t%i\t%g" mon_state.apericube
mon_state.total_length mon_state.total_time;
if ost <> Void || store_traj then fprintf outfile "@."
let end_sampling _ = ()
module StringMap = Map.Make (String)
let up_state ((outfile, rgpoly, (ost, is_interactive), _, parse_action) : t)
?smp (st : State.t) i (u1, u2) =
( match ost with
let up_state
((outfile, rgpoly, (ost, is_interactive), monitor_state, parse_action) :
t) ?smp (st : State.t) i (u1, u2) =
(match ost with
| TimewordState -> fprintf outfile "(%a)@." print_state st
| StateList -> fprintf outfile "%a@." print_state st
| StateListFull -> fprintf outfile "%a\t%i@." print_state st 1
......@@ -166,15 +176,15 @@ struct
| _ when u1 = 1.0 -> Some (snd @@ List.nth accl (n - 1))
| _ when skip > 0.0 ->
Some
( snd
(snd
@@ List.find
(fun ((x, y), _) -> x <= skip && skip < y)
accl )
accl)
| _ ->
Some
( snd
(snd
@@ List.nth accl
(min (int_of_float (u1 *. float n)) (n - 1)) ))
(min (int_of_float (u1 *. float n)) (n - 1))))
|> (fun m ->
StringMap.fold
(fun _ v acc ->
......@@ -184,10 +194,13 @@ struct
let target =
rgpoly.statelist.((List.hd tr.ZoneGraph.miniedge).target)
in
let ct = monitor_state.total_time in
fprintf f
"%s{\"label\":\"%s\",\"min_time\": %g, \"max_time\":%g, \"time\":%g, \"target\":\"%s\"}"
"%s{\"label\":\"%s\",\"min_time\": %g, \"max_time\":%g, \
\"time\":%g, \"target\":\"%s\"}"
(if i > 0 then "," else "")
tr.ZoneGraph.action low up time target.name))
tr.ZoneGraph.action (low +. ct) (up +. ct) (time +. ct)
target.name))
rgpoly.ZoneGraph.statelist.(get_loc st).ZoneGraph.transition
| Debug ->
fprintf outfile "@[<h 0>%a@. @[<v 2>@[<v 0>%a@]@]@]@."
......@@ -213,7 +226,7 @@ struct
tr.ZoneGraph.action low up W.print weight w target.name
else fprintf f "[%s]-[%g;%g]@," tr.ZoneGraph.action low up))
rgpoly.ZoneGraph.statelist.(get_loc st).ZoneGraph.transition
| Void | Word | Timestamp | Timeword | TimeAndLabels -> () );
| Void | Word | Timestamp | Timeword | TimeAndLabels -> ());
if is_interactive then
let rec aux () =
......@@ -246,9 +259,9 @@ struct
let up_trans (outfile, _, (ost, _), mon_state, _) time tr i =
let t2 = int_of_float time in
(mon_state :=
let ap, size, tt = !mon_state in
((2 * ap) + t2, size + 1, tt +. time));
mon_state.total_time <- mon_state.total_time +. time;
mon_state.total_length <- mon_state.total_length + 1;
mon_state.apericube <- (2 * mon_state.apericube) + t2;
match ost with
| Debug when Array.length tr.ZoneGraph.weight > 0 ->
let weight, cdf, _ = tr.ZoneGraph.weight.(i) in
......@@ -264,8 +277,7 @@ struct
| StateListDelay ->
fprintf outfile "\t%i@.@." (int_of_char tr.ZoneGraph.action.[0])
| TimeAndLabels ->
fprintf outfile "%f\t%i@."
((fun (_, _, a) -> a) !mon_state)
fprintf outfile "%f\t%i@." mon_state.total_time
(int_of_char tr.ZoneGraph.action.[0])
| StateList | Void | CoSim -> ()
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment