diff --git a/Logbook.md b/Logbook.md index 7a0eeaa..4327a3f 100644 --- a/Logbook.md +++ b/Logbook.md @@ -1,5 +1,40 @@ # Leios logbook +## 2024-10-01 + +Report on ΔQ work in Rust so far (Roland): + +- implemented MVP in the sense of being able to create ΔQ expressions as per the “Mind your outcomes” paper and evaluate them +- added a recursion operator that is purely syntactical: recursive unfolding of a named expression with a given depth limit +- project uses yew/trunk to render the HTML/CSS frontend, which uses WASM (tools were chosen for convenience, not minimalism) +- ΔQ evaluation currently done in server process, but could also be moved into the web part (should use web worker to stay responsive) + +Implementation notes: + +- CDF is represented as a list of f32 tuples, with a size limit of 1000 (tunable) after which the step function will be simplified (i.e. approximated) +- this simplification can be done in over- or under-approximation mode; running both and showing the difference will illustrate the error range +- tuples are pruned in increasing order of their distance to the right neighbour, with two complications: + 1. distances are binned to some precision to avoid dominating the selection by floating-point precision limits + 2. the algorithm pulls pruning candidates from a heap but skips every second one of the same distance; this yields more even pruning along the x axis +- the EvaluationContext holds all named expressions and allows resolving names, but also tracks the current recursion allowance for each name + (recursion with allowance isn’t allowed while already recursing on that name; allowing this results in infinite loop) + +Comments raised while presenting this to the team today: + +- syntax should stay closer to the original paper (I deviated in order to allow normal people to type in expressions with their keyboard) + - this could be done by having aliases and supporting the entry of special glyphs with a palette on the web page +- showing recursion as exponentiation is surprising, Andre expected exponentiation to be just some form of repeated multiplication (but unclear which operation that would be) +- recursion as template unfolding was understood as some fix point representation by Duncan, but currently that is not how it is implemented +- treating the propagation of messages across a network graph isn’t faithfully modelled, but it could be if recursion was actually some kind of fix point operation + - it would be great to have an operator that expresses “only broadcast the first copy of the message I receive”, which would allow pruning the infinite evaluation tree + - this is unclear to me because ΔQ speaks in CDFs which aren’t concrete in this way, so pruning wouldn’t apply to CDFs but to some execution of the modelled process +- Pi asked how this work relates to the Rust-based network graph simulator, which has at least two answers: + - compute CDFs that are used by the simulator using ΔQ + - use simulation results (CDFs) as inputs for further ΔQ modelling, e.g. on a higher level +- on the website we’ll need something that can quickly answer high-level questions, running a simulation would probably not be feasible but ΔQ should be +- it occurred to me that if we can get a load profile from a ΔQ model, we can then use queueing theory to compute the effect on latencies to get a better approximation of overall system behaviour + - these two steps can be run alternatingly to see if there is a fix point for the result — and if the computation diverges, that tells us that the network graph would die from overload + ## 2024-09-30 Catching-up on Leios ΔQ work: diff --git a/delta_q/models.txt b/delta_q/models.txt new file mode 100644 index 0000000..9481ba3 --- /dev/null +++ b/delta_q/models.txt @@ -0,0 +1,11 @@ +This file contains several formulas that may or may not model some systems described in some papers. + +1 -- TR1 wrong Cardano model + +hop := CDF[(0.012, 0.333), (0.069, 0.666), (0.268, 1)] ->- CDF[(0.024, 0.333), (0.143, 0.666), (0.531, 1)] +prop := hop 1<>99 hop ->- hop 5<>94 hop ->- hop ->- hop 34<>60 hop ->- hop ->- hop ->- hop 59<>1 hop ->- hop ->- hop ->- hop ->- hop + +2 -- TR1 used Cardano model + +hop := CDF[(0.012, 0.333), (0.069, 0.666), (0.268, 1)] ->- CDF[(0.012, 0.333), (0.069, 0.666), (0.268, 1)] ->- CDF[(0.012, 0.333), (0.069, 0.666), (0.268, 1)] ->- CDF[(0.024, 0.333), (0.143, 0.666), (0.531, 1)] +prop := hop 0.6<>99.4 hop ->- hop 8.58<>90.82 hop ->- hop ->- hop 65.86<>24.96 hop ->- hop ->- hop ->- hop diff --git a/delta_q/src/cdf.rs b/delta_q/src/cdf.rs index 8b7555f..5fab9ca 100644 --- a/delta_q/src/cdf.rs +++ b/delta_q/src/cdf.rs @@ -185,7 +185,7 @@ impl<'a> Iterator for CDFIterator<'a> { } else if self.last { self.last = false; let (x, y) = self.prev; - Some((x * 1.2, y)) + Some(((x * 1.2).max(0.1), y)) } else { None } diff --git a/delta_q/src/parser.rs b/delta_q/src/parser.rs index 64709ca..57f38a9 100644 --- a/delta_q/src/parser.rs +++ b/delta_q/src/parser.rs @@ -89,13 +89,11 @@ fn cdf(input: &mut &str) -> PResult { cut_err( separated::<_, _, (), _, _, _, _>( 0.., - cut_err( - (ws, '(', ws, num, ws, ',', ws, num, ws, ')') - .context(StrContext::Label("CDF literal")) - .context(StrContext::Expected(StrContextValue::Description( - "CDF[(, ), ...]", - ))), - ), + (ws, '(', ws, num, ws, ',', ws, num, ws, ')') + .context(StrContext::Label("CDF literal")) + .context(StrContext::Expected(StrContextValue::Description( + "CDF[(, ), ...]", + ))), (ws, ','), ) .take() @@ -165,8 +163,8 @@ enum Op { impl Op { fn bp(&self) -> (u8, u8) { match self { - Op::Seq => (1, 2), - Op::Choice { .. } => (3, 4), + Op::Choice { .. } => (2, 1), + Op::Seq => (3, 4), } } } diff --git a/delta_q/src/render.rs b/delta_q/src/render.rs index f3e1cb8..dd603dc 100644 --- a/delta_q/src/render.rs +++ b/delta_q/src/render.rs @@ -401,7 +401,8 @@ fn branch(props: &BranchProps) -> Html { pub fn cdf_to_svg(cdf: &CDF) -> Html { let mut canvas = Canvas::new(310.0, 110.0); - let x_scale = 300.0 / cdf.width(); + let width = cdf.width(); + let x_scale = 300.0 / (width * 1.2).max(1.1); canvas.polyline(Polyline { color: Some(Color::black()), stroke_width: 1.0, @@ -415,7 +416,11 @@ pub fn cdf_to_svg(cdf: &CDF) -> Html { y: (1.0 - y) * 100.0 + 1.0, }, Point { - x: x2 * x_scale + 10.0, + x: if x2 > width { + 310.0 + } else { + x2 * x_scale + 10.0 + }, y: (1.0 - y) * 100.0 + 1.0, }, ]