Skip to content

Feature: CLUMPY style allocation#30

Open
Copilot wants to merge 15 commits into
mainfrom
copilot/discuss-transition-probability-estimation
Open

Feature: CLUMPY style allocation#30
Copilot wants to merge 15 commits into
mainfrom
copilot/discuss-transition-probability-estimation

Conversation

Copilot AI commented May 12, 2026

Copy link
Copy Markdown
Contributor

R CMD check (light) failed during package load because evoland_db_views.R attempted to add public methods that are now already declared in evoland_db.R. The failure was caused by duplicate R6 method registration at load time.

  • R6 method override compatibility

    • Updated evoland_db$set(...) calls in R/evoland_db_views.R to explicitly allow replacing predeclared methods:
      • trans_rates_dinamica_v
      • adjusted_trans_pot_v
      • alloc_params_clumpy_v
    • This keeps evoland_db.R as the canonical method declaration surface while preserving view-backed implementations in evoland_db_views.R.
  • Behavioral impact

    • No API shape changes.
    • Resolves class initialization/load error by making view implementations intentional overrides instead of duplicate adds.
evoland_db$set(
  "public",
  "trans_rates_dinamica_v",
  overwrite = TRUE,
  function(id_period) { ... }
)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

air

[air] reported by reviewdog 🐶

params[c("mean_patch_size", "patch_size_variance", "patch_isometry",
"frac_expander", "frac_patcher")],


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

id_coord = 1L,
value = 0.3


[air] reported by reviewdog 🐶

id_trans = c(1L, 2L, 1L, 2L, 1L, 2L),
id_coord = c(1L, 1L, 2L, 2L, 3L, 3L),


[air] reported by reviewdog 🐶

value = c(0.6, 0.2, 0.1, 0.5, 0.3, 0.4)


[air] reported by reviewdog 🐶

id_trans = c(1L, 2L),
rate = c(0.2, 0.1)


[air] reported by reviewdog 🐶

mean_t1 <- mean(raw_vals$value[raw_vals$id_trans == 1L]) # (0.6+0.1+0.3)/3
mean_t2 <- mean(raw_vals$value[raw_vals$id_trans == 2L]) # (0.2+0.5+0.4)/3


[air] reported by reviewdog 🐶

expect_true(abs(col_mean_t1_scaled - rates$rate[1L]) <=
abs(mean_t1 - rates$rate[1L]) + 1e-9)

Copilot AI changed the title feat: CLUMPY allocation backend + raw/adjusted transition potential architecture Fix R CMD check lazy-load failure from duplicate R6 method registration Jun 16, 2026
@mmyrte mmyrte marked this pull request as ready for review June 16, 2026 13:54
@mmyrte mmyrte changed the title Fix R CMD check lazy-load failure from duplicate R6 method registration Feature: CLUMPY style allocation Jun 25, 2026
@mmyrte mmyrte force-pushed the copilot/discuss-transition-probability-estimation branch from 6a135de to a672f32 Compare June 26, 2026 08:59
…esis

Adds dev/pivot-mechanism-verification.md documenting:
- GART/MuST pivot test is a faithful inverse-CDF translation
- the allocator implements the simplified single-pass strategy, not the
  bias-free uPAM (no per-patch P(v|u) update, no merge rollback)
- the 1/E(sigma) pivot rarefaction (thesis Fig. 3.2) is missing
- determinism behaviour under 0/1 transition potentials

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0189ymK6BeCwBC8iZ45CGuVb
claude and others added 7 commits June 26, 2026 12:30
…hape metric

Move the whole CLUMPY pivot-selection + patch-growth routine into C++
(allocate_clumpy_cpp) so the hot loop no longer crosses into R per patch.

- Add selectable allocation methods:
  * uSAM (single GART pass, quantity of change in expectation)
  * uPAM (iterative GART with a per-transition pixel quota and sampling
    without replacement; batch_size dials speed vs fidelity, 1 = strict
    one-pivot-per-draw). Affordable here because evoland's fixed-model
    potentials are pool-independent, so rho(z|u) is never re-estimated.
- Apply the 1/E(sigma) pivot rarefaction before GART (thesis Fig. 3.2) so the
  allocated quantity of change matches the target rate; rate confirmed to be a
  quantity-of-change rate via get_obs_trans_rates.
- Clamp negative/NaN potentials inside GART (matches reference clumpy).
- Move gart/sample_lognorm_area/raster_neighbors from R into C++
  (gart_cpp, sample_lognorm_area_cpp, raster_neighbors_cpp).
- Unify the duplicate patch-shape metric (patch_eccentricity vs
  calculate_elongation) into clumpy::elongation_from_raw_moments
  (src/clumpy_geometry.h), shared by the grower and calculate_class_stats_cpp.
- Patch grower uses incremental moments (O(1) per candidate) and the shared
  metric; thread method/batch_size through alloc_clumpy() and the evoland_db
  binding; update unit tests to the C++ entry points.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0189ymK6BeCwBC8iZ45CGuVb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants