Skip to content

AB-programs do file take2#451

Open
ANBurdett wants to merge 9 commits intomainfrom
AB-programs_do_file_take2
Open

AB-programs do file take2#451
ANBurdett wants to merge 9 commits intomainfrom
AB-programs_do_file_take2

Conversation

@ANBurdett
Copy link
Copy Markdown
Contributor

Apologies for the confusion last time; it seems I'm still not as fluent with GitHub as I would like to be. Hopefully the new files are now in this branch...

I've copied the text from the previous branch below for reference:

In this branch, I have included the draft programs do files, in which all of the Excel files containing the process estimates (except wages) are produced using the programs file.

A few things worth noting:

The Excel file name is now dynamic and fed into the relevant program.
There are a few different possible processing programs. The one to use depends on the type of model you are running.
Probit and logit models are processed in the same way, even if the probit option is always used.
Review Request:
@andrewbaxter439 - It would be great if you could take a look at the files for the well-being, mental health and financial distress to see if they are working as expected.
Please let me know if you spot any bugs or have any issues.

The one obvious thing that is outstanding to me is that some of the labels are incorrect. Specifically, it is easier to create dummy variables from categorical variables with the name that will be picked up by SimPaths. Lags are dealt with in the code, but category names are not. I think the best place for these variables to be created is in the variable_update do-file. @dariaple is currently updating this file (along with the full set of estimation do files) with the new variable names, so perhaps this is best added after she has completed that work. However, this shouldn't impact the programs themselves it just alters what is fed into them.

ANBurdett and others added 9 commits March 24, 2026 23:41
Deleted old validation plot files and uploaded new validation do files.
  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
Optimized database hadling and replaced Statistics3 with AlignmentAdjustmentFactors
Remove all the code/references to IT
@ANBurdett ANBurdett self-assigned this Apr 1, 2026
@ANBurdett ANBurdett changed the title Ab programs do file take2 AB-programs do file take2 Apr 1, 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.

4 participants