File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,15 @@ def ebDistribution : Probabilities → HashMap Nat Probability :=
8282def ebDistributionJson : Probabilities → Json :=
8383 Json.mkObj ∘ List.map (fun ⟨k, v⟩ => ⟨toString k, toJson v⟩) ∘ HashMap.toList ∘ ebDistribution
8484
85+ def rbEfficiency (states : Probabilities) : Float :=
86+ let clock := states.keys.head!.clock
87+ let rbCount :=
88+ HashMap.fold
89+ (fun acc state p =>acc + state.rbCount.toFloat * p)
90+ 0
91+ states
92+ rbCount / clock.toFloat
93+
8594def ebEfficiency (states : Probabilities) : Float :=
8695 let clock := states.keys.head!.clock
8796 let ebCount :=
@@ -90,3 +99,9 @@ def ebEfficiency (states : Probabilities) : Float :=
9099 0
91100 states
92101 ebCount / (clock.toFloat - 1 )
102+
103+ def efficiency (states : Probabilities) : Float :=
104+ let rb := rbEfficiency states
105+ let eb := ebEfficiency states
106+ let ρ := 12 .5 / 0 .9
107+ (rb + ρ * eb) / (1 + ρ)
Original file line number Diff line number Diff line change @@ -32,7 +32,9 @@ def runMarkovCmd (p : Parsed) : IO UInt32 :=
3232 let sn := simulate env default ε rbCount
3333 if p.hasFlag "output-file"
3434 then IO.FS.writeFile (p.flag! "output-file" |>.as! String) (Json.pretty $ ebDistributionJson sn)
35- IO.println s! "Efficiency: { (reprPrec (ebEfficiency sn) 0 ).pretty} "
35+ IO.println s! "RB efficiency: { (reprPrec (rbEfficiency sn) 0 ).pretty} "
36+ IO.println s! "EB efficiency: { (reprPrec (ebEfficiency sn) 0 ).pretty} "
37+ IO.println s! "Overall efficiency: { (reprPrec (efficiency sn) 0 ).pretty} "
3638 IO.eprintln s! "Missing probability: { 1 - totalProbability sn} "
3739 pure 0
3840
You can’t perform that action at this time.
0 commit comments