Commit 718af3d3 authored by Benoit Barbot's avatar Benoit Barbot
Browse files

progress bug to fix

parent 7547777a
Pipeline #1672 failed with stages
in 17 seconds
......@@ -47,16 +47,17 @@ module type WeightStructure = sig
val to_float : ?smp:float -> t -> float option
val apply_all : ?smp:float -> t -> float array -> float
val fully_apply_float : ?smp:float -> t -> var -> float -> float
val taylor_exp_s: t -> int -> t
end
type 'a transChoice = Label of 'a | Rand of float | Fixed
module type S =
sig
module P:WeightStructure
module Bt:ZoneGraphInput.BoundType
module Bt:ZoneGraphInput.BoundType
val t : P.var
val iterate_functionnal :
?update:(unit -> unit) ->
......@@ -103,10 +104,10 @@ sig
(float transChoice * ZoneGraph.l transChoice) array ->
samplers:(int -> float) * (int -> float) -> unit
end
module Make (Bt: ZoneGraphInput.BoundType) (P: WeightStructure) = struct
module P=P
module Bt=Bt
module Bt=Bt
open P
open ZoneGraph
type bt = Bt.t
......@@ -156,20 +157,20 @@ module Make (Bt: ZoneGraphInput.BoundType) (P: WeightStructure) = struct
done;
!stateweight,rgp
let find_root ?smp ?factor ?max_iter ?bound p ?diffp x guess_p =
(*let p2 = match smp with
None -> p
let find_root ?smp ?factor ?max_iter ?bound p ?diffp x guess_p =
(*let p2 = match smp with
None -> p
| Some s -> apply_const ?smp p (P.var_of_int (P.nb_var-1)) (F.of_float s) in
Format.eprintf "finding root for %a @." P.print p; *)
let pp = match diffp with
None -> diff p x
| Some pp -> pp in
let f v =
let f v =
let f0 = fully_apply_float ?smp p x v
and f1 = fully_apply_float ?smp pp x v in
and f1 = fully_apply_float ?smp pp x v in
(f0,f1) in
try newton_raphson_iterate ?factor ?max_iter ?bound f guess_p with
| Common.Not_converging (r,v) ->
| Common.Not_converging (r,v) ->
Format.eprintf "Alert Not converging %a --> %g -> %g@." P.print p r v;
r
......@@ -261,7 +262,7 @@ module Make (Bt: ZoneGraphInput.BoundType) (P: WeightStructure) = struct
List.filter (fun tr ->
let low = Bt.eval_max_bound (id,tab) tr.lower_bound
and up = Bt.eval_min_bound (id,tab) tr.upper_bound in low <= up) l
else l in
else l in
match filter with
None -> l2
| Some ff ->
......
......@@ -25,9 +25,10 @@ module type WeightStructure =
val to_float : ?smp:float -> t -> float option
val apply_all : ?smp:float -> t -> float array -> float
val fully_apply_float : ?smp:float -> t -> var -> float -> float
val taylor_exp_s: t -> int -> t
end
type 'a transChoice = Label of 'a | Rand of float | Fixed
module type S =
sig
module P:WeightStructure
......@@ -54,7 +55,7 @@ sig
val eval_poly_state_full : ?smp:float -> state -> P.t -> float
val elapse_time : state -> float -> state
val fire : state -> ('b,Bt.t) ZoneGraph.transition -> state
val sample_time : ?smp:float ->
val sample_time : ?smp:float ->
?max_iter:int ->
int ->
state -> (P.t,Bt.t) ZoneGraph.transition -> float -> float
......@@ -78,5 +79,5 @@ sig
(float transChoice * ZoneGraph.l transChoice) array ->
samplers:(int -> float) * (int -> float) -> unit
end
module Make (Bt : ZoneGraphInput.BoundType) (P : WeightStructure) : S with type P.t = P.t and type P.var=P.var and type Bt.t=Bt.t and type Bt.state=Bt.state
module Make (Bt : ZoneGraphInput.BoundType) (P : WeightStructure) : S with type P.t = P.t and type P.var=P.var and type Bt.t=Bt.t and type Bt.state=Bt.state
......@@ -67,6 +67,7 @@ module type S = sig
val of_bound : bound -> t
val map_var : t -> (var -> var) -> t
val elapse_time : t -> var -> t
val taylor_exp_s: t -> int -> t
end
let iter_fun n f x =
......@@ -370,6 +371,10 @@ module Make (F: Fl.FSIG)(K:sig val var_string:VarSet.varset end) = struct
cip := ci
done;
!ptilde
let taylor_exp_s p _ = p
end
(*
......
......@@ -62,6 +62,7 @@ module type S = sig
val of_bound : Common.bound -> t
val map_var : t -> (var -> var) -> t
val elapse_time : t -> var -> t
val taylor_exp_s: t -> int -> t
end
module Make :
......
......@@ -74,10 +74,10 @@ let _ =
| _,Some b -> b.ZoneGraph.var_string
| None,None -> assert false end) in
(* either P or exp-polynomials *)
(* If exact computation or no s parameter given s is symbolic, otherwise it is inlined during computation *)
(* If exact computation or no s parameter given s is symbolic, otherwise it is inlined during computation *)
let module Weight = (val if !frequency = None && !expected_duration = None then (module P:Semantic.WeightStructure)
else (module ExpPoly.Make(P)(struct
let smp = if P.F.is_exact then None
let smp = if P.F.is_exact then None
else !frequency
let tvar = P.var_of_int 0
let svar= P.var_of_int (P.nb_var-1)
......@@ -115,7 +115,7 @@ let _ =
(* Compute s from expected_duration *)
let smp = match !expected_duration with
None -> !frequency
| Some target ->
| Some target ->
if !verbose>0 then (
printf "Computing laplace parameters s : %g -> " target; flush stdout;
print_flush ();
......@@ -125,6 +125,18 @@ let _ =
let dw = Weight.diff w svar in
let ddw = Weight.diff dw svar in
let compv s =
if s=0.0 then
let svar = P.var_of_int (P.nb_var-1) in
let we = Weight.taylor_exp_s w (!npoly) in
(*Format.printf "vte: %a@." P.print we;*)
let de = Weight.taylor_exp_s dw (!npoly+1) in
Format.printf "vte: %a@." P.print de;
let w0 = P.apply we svar (P.const P.F.zero) in
let d0 = P.apply de svar (P.const P.F.zero) in
match P.to_float w0,P.to_float d0 with
Some v1,Some v2 -> v1,v2
| _ -> failwith "fail to evaluate"
else
match Weight.to_float ~smp:s w ,Weight.to_float ~smp:s dw, Weight.to_float ~smp:s ddw with
Some v,Some dv,Some ddv -> -. dv /. v -.target , -.ddv /. v +. dv*.dv /. (v*.v)
| _ -> failwith "fail to evaluate" in
......
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