Skip to content

Test SimPathsBuild workflow#445

Closed
Mariia-Var wants to merge 3 commits intoMV-test-workflowfrom
MV-develop
Closed

Test SimPathsBuild workflow#445
Mariia-Var wants to merge 3 commits intoMV-test-workflowfrom
MV-develop

Conversation

@Mariia-Var
Copy link
Copy Markdown
Collaborator

No description provided.

  Persistence.createEntityManagerFactory(...) was called on every invocation of all three methods. Building a factory is expensive — it validates the schema and sets up a connection pool. Two static fields replace this:
  - emfStartingPopulationPersist — shared by getProcessed() and persistProcessed() (both use getPersistDatabasePath())
  - emfStartingPopulationRun — used by loadStartingPopulation() (uses RunDatabasePath)
  2. loadStartingPopulation() — bug fix for LazyInitializationException
  With @onetomany collections already marked FetchType.LAZY, returning detached Household objects after em.close() without having initialised benefitUnits or members would throw LazyInitializationException the moment the caller iterated them. The force-initialisation loop triggers the SUBSELECT batch
loads
   within the open session before closing it.

  3. getProcessed() — dead variable removed
  processed_return was assigned the JOIN FETCH result but the method returned processed (the same L1-cached object). The two are identical references, so processed_return.resetDependents() and processed.resetDependents() were equivalent. The dead variable is removed and the call is chained directly. No
  behaviour change.
  -DonorTaxImputation used Math.random() to decide whether a benefit unit receives Universal Credit based on the weighted mean UC receipt across donor candidates. Math.random() draws from Java's global, unseeded Random instance, producing different results on every JVM run regardless of the model's random seed setting.

  -Replaced with SimulationEngine.getRnd().nextDouble(), which draws from the model's seeded Random instance — the same one used throughout the rest of the model. With a fixed seed, UC/Legacy benefit assignment is now deterministic across runs.
  AlignmentAdjustmentFactors fields (30 total):
  - Partnership: adj factor, sim share, target share (same computation)
  - Fertility: adj factor, sim rate, target rate (same computation)
  - In-school: adj factor, sim share, target share — new
  - Utility adj factors × 7 (same computation)
  - Employment shares: 7 × simulated + 7 × target — new
@Mariia-Var Mariia-Var closed this Mar 27, 2026
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.

1 participant