Cost-vs-overflow-volume plot + Eisenstadt LAI 3.9 consistency#15
Conversation
Consistency: - workflow_eisenstadt-2005.Rmd and workflow_eisenstadt-2005_neu.Rmd now unconditionally set //Massnahmenelemente/Mulde_Rigole/Parameter_Evapotranspiration/LAI_LeafAreaIndex = 3.9 (Hoernschemeyer grass value, Water 2023, 15, 2840, Tab. 6, plant type 5). Wien already sweeps LAI over c(3.9, 8.5); Bad Aussee uses the same sweep grid as Wien; Eisenstadt was the outlier still running on the base.h5 default 8.5. New feature: - plot_cost_vs_overflow_volume() -- new exported ggplot helper mirroring plot_wb_tradeoff_overflows() for cost-aware optimisation. x = cost_total (EUR), y = overflow volume in m3 (computed from sum_overflows [mm] * mulde_area [m2] / 1000), points coloured discretely by n_overflows using the same 0..x / ">x" palette and top legend. Plotly tooltip carries the cost breakdown (cost_excavation / _profiling / _filter / _storage / _total) plus the varying param_grid entries. - Each of the four case-study workflow vignettes (workflow_wien, workflow_badaussee, workflow_eisenstadt-2005, workflow_eisenstadt-2005_neu) now renders the plot as simulation_results_optimisation_<site>_cost-vs-overflow-volume.html right after the existing water-balance render, matching its PDF / saveWidget pattern exactly. - vignettes/index.Rmd gains a new "Kosten vs. Überlaufvolumen" section under "Interaktive Visualisierungen" that links to the three top-level sites (Eisenstadt 2005, Wien, Bad Aussee). https://claude.ai/code/session_014QrjF51tg7cMVmsgjmfPNG
| paths$modelname) | ||
| kwb.utils::preparePdf(pdfFile = pdff) | ||
|
|
||
| p <- kwb.raindrop::plot_cost_vs_overflow_volume( |
There was a problem hiding this comment.
Bug: plot_cost_vs_overflow_volume() will fail here because the Eisenstadt vignette never calls compute_costs().
Unlike workflow_wien.Rmd (line 404) and workflow_badaussee.Rmd (line 408), the pipeline that builds simulation_results_optimisation in this vignette (lines 298–301) does not chain %>% kwb.raindrop::compute_costs():
simulation_results_optimisation <- param_grid %>%
dplyr::left_join(simulation_results_optimisation,
by = c("scenario_name" = "s_name")) %>%
dplyr::relocate(scenario_name, .before = connected_area)plot_cost_vs_overflow_volume() requires cost_excavation, cost_profiling, cost_filter, cost_storage, cost_total (see R/plot_cost_vs_overflow_volume.R:121-139) and will stop() with "simulation_results_optimisation is missing column(s): cost_excavation, cost_profiling, cost_filter, cost_storage, cost_total" when the analyse_results chunk runs on Windows (i.e. when the vignette actually evaluates).
Add %>% kwb.raindrop::compute_costs() to the pipe on line 301, matching Wien / Bad Aussee:
| p <- kwb.raindrop::plot_cost_vs_overflow_volume( | |
| p <- kwb.raindrop::plot_cost_vs_overflow_volume( |
(Fix on the data-prep pipe at line 298–301 rather than here; the plot call itself is fine — but this line is where the failure will surface. The suggestion block is a no-op placeholder so this comment doesn't overwrite code.)
Builds on the cost-vs-overflow-volume plot (PR #15) with a new cost-by-overflow-count boxplot (three best-selection variants), richer tooltips and i18n parameter labels, and fixes the Eisenstadt cost pipeline the PR review flagged. Bug fix (PR #15 review blocker): - vignettes/workflow_eisenstadt-2005.Rmd now pipes the joined optimisation results through kwb.raindrop::compute_costs(), like the Wien and Bad Aussee workflows already did. Without it the vignette's plot_cost_vs_overflow_volume() call aborted with "missing column(s): cost_excavation, ..." on Windows, so the cost PDF/HTML was never produced and the exported CSV lacked the cost columns. New plot -- plot_cost_overflow_boxplot() (exported): - Boxplot of total construction cost (EUR, y) per number of overflow events (x). Counts 0..x each get their own box (x = max_n_overflows, as in the sibling plots); higher counts collapse into a single ">x" catch-all box (furthest right, red), keeping the axis readable for the long-tailed 15-year runs (Wien / Bad Aussee reach several hundred overflow events). The ">x" box highlights the scenario with the fewest overflow events above x (closest to valid), best_by breaking ties. - Individual scenarios are overlaid as jittered points whose size scales with a chosen variable (size_by): the overflow volume (m3, default) or the element evapotranspiration share (%). The size scale is calibrated to the valid region (0..x) and capped, with a minimum size, so the many-overflow outliers of the ">x" box do not shrink the valid-region points to invisible dots. - One best scenario per box is highlighted with a black-outlined diamond in that box's group colour (so its tooltip inherits the group colour) and the best of all boxes are joined by a frontier line (mark_best / connect_best). best_by picks the objective, cost as tie-breaker -- "min_cost" (cheapest), "min_overflow" (smallest overflow volume) or "max_evapotranspiration" (highest evapotranspiration) -- so the three variants trace three different frontier lines; label_best annotates the marker ("NN m3 / NN %" or "NN %"). - Each case-study vignette loops the three variants into *_cost-by-overflows-boxplot-{cheapest,min-overflow,max-evap}.html, all linked from vignettes/index.Rmd, which now groups the cost plots under one "Kosten" heading with sub-points (toc_depth 4). Tooltip enrichment (shared helpers in R/cost_tooltip.R): - The plotly tooltip of plot_cost_vs_overflow_volume() now carries the element water balance (evapotranspiration / infiltration / overflow, all in %) in addition to the cost breakdown, and names the chosen storage type on its own bold line, bilingually ("Sickerbox / Infiltration box" or "Schotterrigol / Gravel trench"). - The "varying parameters" block is translated via the new exported default_param_labels() helper -- a hovered point shows e.g. "Muldenflaeche [m2]=125" (de) / "Swale area [m2]=125" (en) instead of the raw "mulde_area=125"; override with param_labels =. - cost_tooltip_labels() / cost_tooltip_text() / build_varying_param_html() are shared so both cost plots emit byte-identical tooltips. Code hygiene: - All non-ASCII characters in R code (string literals in the plot functions and in the vignette code chunks) are unicode-escaped (\uXXXX); the few non-ASCII code comments were rewritten in plain ASCII ("Hoernschemeyer", "2xN"). Markdown prose keeps UTF-8. New exports: plot_cost_overflow_boxplot(), default_param_labels().
Both plot_cost_vs_overflow_volume() and plot_cost_overflow_boxplot() now append the share of scenarios meeting the validity criterion (n_overflows <= x) to the plot title, e.g. "Kosten vs. Ueberlaufvolumen (39 % mit <= 5 Ueberlaeufen)" / "Cost vs. overflow volume (39 % with <= 5 overflows)". It goes in the title, not a ggplot subtitle: ggplotly drops subtitles, so the share would be lost in the interactive HTML the vignettes export. The scatter title drops its old "(Anzahl Ueberlaeufe <= x)" parenthetical, which the share now supersedes. vignettes/index.Rmd now spells out the per-site validity threshold that drives this share: Eisenstadt <= 1 (1-year simulation), Wien / Bad Aussee <= 5 (15-year rain/ET series).
Summary
Two changes, both consumer-driven follow-ups to Daniel's earlier XLSX review:
Consistency — Eisenstadt 2005 LAI = 3.9
Both
workflow_eisenstadt-2005.Rmdandworkflow_eisenstadt-2005_neu.Rmdnow unconditionally set//Massnahmenelemente/Mulde_Rigole/Parameter_Evapotranspiration/LAI_LeafAreaIndex = 3.9(Hörnschemeyer grass value, Water 2023, 15, 2840, Tab. 6, plant type 5). Wien already sweeps LAI over
c(3.9, 8.5), Bad Aussee uses the same grid — Eisenstadt was the only case study still running on thebase.h5default8.5. Michael's May 2026 LAI sweep showed the modelled ET share barely moves between the two values, so this is a hygiene alignment rather than a physics change.New export —
plot_cost_vs_overflow_volume()Companion to
plot_wb_tradeoff_overflows()for cost-aware optimisation:cost_total[€]sum_overflows[mm] ×mulde_area[m²] / 1000)n_overflowsdiscretely bucketed (0,1, …,x,">x") with the samedarkgreen → yellowgreen → orange → redpalette and top legend asplot_wb_tradeoff_overflowsparam_gridentries, so a mouseover on any point reads out both hydraulic performance and construction cost detaillang = c("de", "en")(German default), overrideable title / axis / legendEach of the four case-study vignettes now renders the plot as
simulation_results_optimisation_<site>_cost-vs-overflow-volume.htmlright after the existing water-balance render, andvignettes/index.Rmdgains a "Kosten vs. Überlaufvolumen" section under the interactive-visualisation block.Test plan
R CMD checkonwindows-latestis greenworkflow_wien.Rmdproducessimulation_results_optimisation_Wien_cost-vs-overflow-volume.htmlwith (a) points coloured byn_overflows(top legend,0..x / ">x") and (b) a tooltip showing the full cost breakdown plus varying parametersindex.Rmdlinks all three sites under the new sectionhttps://claude.ai/code/session_014QrjF51tg7cMVmsgjmfPNG
Generated by Claude Code