@@ -5,6 +5,7 @@ import Parser.Char.Numeric
55import Parser.Stream
66
77open Cli
8+ open Lean (Json)
89
910
1011instance : ParseableType Float where
@@ -28,31 +29,27 @@ def runMarkovCmd (p : Parsed) : IO UInt32 :=
2829 let rbCount : Nat := p.flag! "rb-count" |>.as! Nat
2930 let env := makeEnvironment activeSlotCoefficient pRbHeaderArrives pEbValidates committeeSize.toFloat τ Lheader Lvote Ldiff
3031 let sn := simulate env default ε rbCount
31- let print {α : Type } [Repr α] (x : α) : IO Unit := IO.println (reprPrec x 0 ).pretty
32- IO.println ""
33- print sn
34- IO.println ""
35- print $ ebDistribution sn
36- IO.println ""
37- print $ ebEfficiency sn
38- IO.println ""
39- print $ 1 - totalProbability sn
32+ if p.hasFlag "output-file"
33+ then IO.FS.writeFile (p.flag! "output-file" |>.as! String) (Json.pretty $ ebDistributionJson sn)
34+ IO.println s! "Efficiency: { (reprPrec (ebEfficiency sn) 0 ).pretty} "
35+ IO.eprintln s! "Missing probability: { 1 - totalProbability sn} "
4036 pure 0
4137
4238def markovCmd : Cmd := `[Cli|
4339 markovCmd VIA runMarkovCmd; ["0.0.1" ]
4440 "Run a Markov simulation of Linear Leios."
4541 FLAGS:
46- "active-slot-coefficient" : Float ; "The active slot coefficient for RBs, in probability per slot."
47- "l-header" : Nat ; "L_header protocol parameter, in slots."
48- "l-vote" : Nat ; "L_vote protocol parameter, in slots."
49- "l-diff" : Nat ; "L_diff protocol parameter, in slots."
50- "committee-size" : Nat ; "Expected number of voters in the committee."
51- "quorum-fraction" : Float ; "τ protocol parameter, in %/100."
52- "p-rb-header-arrives" : Float ; "Probability that the RB header arrives before L_header."
53- "p-eb-validates" : Float ; "Probability that the EB is fully validated before 3 L_header + L_vote."
54- "tolerance" : Float ; "Discard states with less than this probability."
55- "rb-count" : Nat ; "Number of RBs to simulate."
42+ "active-slot-coefficient" : Float ; "The active slot coefficient for RBs, in probability per slot."
43+ "l-header" : Nat ; "L_header protocol parameter, in slots."
44+ "l-vote" : Nat ; "L_vote protocol parameter, in slots."
45+ "l-diff" : Nat ; "L_diff protocol parameter, in slots."
46+ "committee-size" : Nat ; "Expected number of voters in the committee."
47+ "quorum-fraction" : Float ; "τ protocol parameter, in %/100."
48+ "p-rb-header-arrives" : Float ; "Probability that the RB header arrives before L_header."
49+ "p-eb-validates" : Float ; "Probability that the EB is fully validated before 3 L_header + L_vote."
50+ "tolerance" : Float ; "Discard states with less than this probability."
51+ "rb-count" : Nat ; "Number of RBs to simulate."
52+ "output-file" : String ; "Path to the JSON output file for the EB distribution."
5653 EXTENSIONS:
5754 author "bwbush" ;
5855 defaultValues! #[
@@ -64,7 +61,7 @@ def markovCmd : Cmd := `[Cli|
6461 , ("quorum-fraction" , "0.75" )
6562 , ("p-rb-header-arrives" , "0.95" )
6663 , ("p-eb-validates" , "0.90" )
67- , ("tolerance" , "1e-9 " )
64+ , ("tolerance" , "1e-8 " )
6865 , ("rb-count" , "100" )
6966 ]
7067]
0 commit comments