Skip to content

Drop intrv_* tables; vignette on representing policy mechanisms - #54

Open
mmyrte wants to merge 13 commits into
developfrom
claude/confident-albattani-56osfg-scenario-levers
Open

mmyrte wants to merge 13 commits into
developfrom
claude/confident-albattani-56osfg-scenario-levers

Conversation

@mmyrte

@mmyrte mmyrte commented Sep 24, 2026

Copy link
Copy Markdown
Member

Stacked on #49, which provides the exported single-period allocators and per-run trans_pot_t that the vignette uses. Once #49 merges, retarget this PR to develop.

Removal

Nothing read intrv_meta_t or intrv_masks_t, and intervention machinery isn't meant to live in the package. This PR removes:

  • R/intrv_meta_t.R, R/intrv_masks_t.R, their tests and .Rd pages;
  • the evoland_db table bindings, the Collate entries and the NAMESPACE exports (as_intrv_*, create_intrv_meta_t).

It also rewords the remaining mentions: util_download, the create_lulc_meta_t / create_pred_meta_t docs (which said "intervention specifications"), the allocator docs, the intro vignette and the README.

Breaking: databases that already hold intrv_* tables keep them in the catalog, but the package no longer binds them.

Vignette: vignettes/policy-mechanisms.qmd

Shows how scenario-specific policy is expressed with the tables the simulation already reads. Each mechanism goes on a run of its own and is compared against a business-as-usual run. It's named after the policy represented rather than the model step, since potentials are adjusted before allocation:

Mechanism Example in the vignette Scenario-specific table
Settlement form compact development (3× mean urban patch size) alloc_params_t
Spatial steering building zones (urban potentials ×0.1 outside), nature conservation (urban/arable potentials ×0 inside) trans_pot_t, after prediction and before allocation
Exogenous change a reservoir project flooding a strip lulc_data_t, edited before committing

The vignette also explains:

  • why the potential adjustments are multiplicative: they survive the rescaling to the demanded rates, and zero is an exact exclusion;
  • that under a fixed demand they relocate change rather than add to it;
  • that the whole trans_pot_t slice must be written back;
  • the commit → upsert_new_neighbors() order.

A short note maps the terms to SSP-CH's "pre-allocation / allocation / post-allocation" interventions.

It reuses the synthetic landscape from stochastic-allocation-sensitivity.qmd (code folded) and renders with quarto render. On that render:

  • the building-zone share of new urban land rises from 0.68 to 0.88;
  • conversions inside the protected area fall from 41 to 0;
  • compact settlement gives 33 new urban patches (mean 3.3 cells) instead of 82 (mean 1.3);
  • the reservoir floods 88 cells.

Tests

tinytest::build_install_test(): all ok, 619 results.

🤖 Generated with Claude Code

https://claude.ai/code/session_019fog72qNWbuSjiGBWuP3np


Generated by Claude Code

claude and others added 9 commits September 23, 2026 13:55
trans_pot_t omitted id_run from its key columns, so upserting a run's
potentials rewrote any other run's rows for the same transition, period
and coordinate, including the parent's. Add id_run to the key, as for the
other run-partitioned tables.

That exposed a second problem in the run-lineage read expression: tables
without id_period grouped by id_run as well, so every run in the lineage
was returned instead of the nearest one holding data. Group by the
inheritance keys only, and handle tables with no inheritance key at all.

Export alloc_clumpy_one_period() with a `db` argument instead of `self`.
It returns the posterior map without committing it, so callers can edit
trans_pot_t before and the allocated map after each period.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019fog72qNWbuSjiGBWuP3np
alloc_dinamica_one_period() now mirrors alloc_clumpy_one_period(): it takes
`db`, derives the anterior map itself, reuses existing trans_pot_t (with
use_parent_trans_pot / force_predict_trans_pot) and returns the posterior
map without committing it. It works in a temporary directory by default
and removes it afterwards. alloc_dinamica() is a thin loop over it, and
its work_dir now also defaults to a temporary directory.

Both allocators share predict_trans_pot_for_alloc() for the
parent-run handling.

Move the trans_pot_t lineage test into test_db_evoland.R, reusing its open
database, and note the convention in AGENTS.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019fog72qNWbuSjiGBWuP3np
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019fog72qNWbuSjiGBWuP3np
The test derived work_dir from dirname(db$catalog). Under DuckLake the
catalog is "sqlite:/tmp/.../catalog.sqlite", so that produced a relative
"sqlite:/tmp/..." directory wherever the tests ran. work_dir now defaults
to a temporary directory, so the argument is dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019fog72qNWbuSjiGBWuP3np
Recomputing neighbour predictors after the last requested period is
wasted work when nothing is allocated onwards from it, e.g. in
single-period ensembles. update_neighbors = FALSE skips that final upsert;
intermediate periods are always updated because the next prediction
reads them. The default keeps the current behaviour.
alloc_clumpy_one_period() and alloc_dinamica_one_period() had help pages
of their own that largely repeated alloc_clumpy / alloc_dinamica. They now
sit on those pages via @describeIn, with the shared arguments documented
once. Each page opens with when to use the multi-period method (commits
each period, refreshes neighbour predictors) and when to use the
single-period function (returns the map uncommitted; the caller commits
and refreshes neighbours).

AGENTS.md: tests needing a longer series of database manipulations go in
test_integ_*.R.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019fog72qNWbuSjiGBWuP3np
… change

Keeps the update_neighbors code and parameter docs from #50 on the
restructured allocator help pages; man pages regenerated with roxygen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019fog72qNWbuSjiGBWuP3np
intrv_meta_t and intrv_masks_t were never read by anything, and
intervention machinery is not meant to live in the package. Remove them,
their tests, bindings and docs, and reword the remaining mentions.

In their place, vignettes/policy-mechanisms.qmd shows how scenario-specific
policy is expressed with the tables the simulation already reads, each on
a run of its own and compared against a business-as-usual run:
- settlement form (compact development) through alloc_params_t,
- spatial steering (building zones, nature conservation) through
  multiplicative adjustments of trans_pot_t before allocation,
- exogenous change (a reservoir project) through edits of the allocated
  map before it is committed,
using the exported single-period allocator for the per-period steps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019fog72qNWbuSjiGBWuP3np
@mmyrte
mmyrte changed the base branch from claude/confident-albattani-56osfg to develop September 24, 2026 10:37
Conflicts in the allocator docs resolved to develop's version, with this
branch's one change re-applied (no "e.g. interventions"); man pages
regenerated with roxygen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019fog72qNWbuSjiGBWuP3np
@mmyrte mmyrte mentioned this pull request Oct 6, 2026
3 tasks
Merges develop, which added the diagram and its CI check after this branch
removed the tables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019fog72qNWbuSjiGBWuP3np
@mmyrte mmyrte moved this to Backlog in evoland-plus Oct 22, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants