@@ -153,77 +153,72 @@ def run(self, simulation: "Simulation") -> "Simulation":
153153 )
154154 modifier (microsim )
155155
156- # Allow custom variable selection, or use defaults
157- if simulation .variables is not None :
158- entity_variables = simulation .variables
159- else :
160- # Default comprehensive variable set
161- entity_variables = {
162- "person" : [
163- # IDs and weights
164- "person_id" ,
165- "benunit_id" ,
166- "household_id" ,
167- "person_weight" ,
168- # Demographics
169- "age" ,
170- "gender" ,
171- "is_adult" ,
172- "is_SP_age" ,
173- "is_child" ,
174- # Income
175- "employment_income" ,
176- "self_employment_income" ,
177- "pension_income" ,
178- "private_pension_income" ,
179- "savings_interest_income" ,
180- "dividend_income" ,
181- "property_income" ,
182- "total_income" ,
183- "earned_income" ,
184- # Benefits
185- "universal_credit" ,
186- "child_benefit" ,
187- "pension_credit" ,
188- "income_support" ,
189- "working_tax_credit" ,
190- "child_tax_credit" ,
191- # Tax
192- "income_tax" ,
193- "national_insurance" ,
194- ],
195- "benunit" : [
196- # IDs and weights
197- "benunit_id" ,
198- "benunit_weight" ,
199- # Structure
200- "family_type" ,
201- # Income and benefits
202- "universal_credit" ,
203- "child_benefit" ,
204- "working_tax_credit" ,
205- "child_tax_credit" ,
206- ],
207- "household" : [
208- # IDs and weights
209- "household_id" ,
210- "household_weight" ,
211- # Income measures
212- "household_net_income" ,
213- "hbai_household_net_income" ,
214- "equiv_hbai_household_net_income" ,
215- "household_market_income" ,
216- "household_gross_income" ,
217- # Benefits and tax
218- "household_benefits" ,
219- "household_tax" ,
220- "vat" ,
221- # Housing
222- "rent" ,
223- "council_tax" ,
224- "tenure_type" ,
225- ],
226- }
156+ entity_variables = {
157+ "person" : [
158+ # IDs and weights
159+ "person_id" ,
160+ "benunit_id" ,
161+ "household_id" ,
162+ "person_weight" ,
163+ # Demographics
164+ "age" ,
165+ "gender" ,
166+ "is_adult" ,
167+ "is_SP_age" ,
168+ "is_child" ,
169+ # Income
170+ "employment_income" ,
171+ "self_employment_income" ,
172+ "pension_income" ,
173+ "private_pension_income" ,
174+ "savings_interest_income" ,
175+ "dividend_income" ,
176+ "property_income" ,
177+ "total_income" ,
178+ "earned_income" ,
179+ # Benefits
180+ "universal_credit" ,
181+ "child_benefit" ,
182+ "pension_credit" ,
183+ "income_support" ,
184+ "working_tax_credit" ,
185+ "child_tax_credit" ,
186+ # Tax
187+ "income_tax" ,
188+ "national_insurance" ,
189+ ],
190+ "benunit" : [
191+ # IDs and weights
192+ "benunit_id" ,
193+ "benunit_weight" ,
194+ # Structure
195+ "family_type" ,
196+ # Income and benefits
197+ "universal_credit" ,
198+ "child_benefit" ,
199+ "working_tax_credit" ,
200+ "child_tax_credit" ,
201+ ],
202+ "household" : [
203+ # IDs and weights
204+ "household_id" ,
205+ "household_weight" ,
206+ # Income measures
207+ "household_net_income" ,
208+ "hbai_household_net_income" ,
209+ "equiv_hbai_household_net_income" ,
210+ "household_market_income" ,
211+ "household_gross_income" ,
212+ # Benefits and tax
213+ "household_benefits" ,
214+ "household_tax" ,
215+ "vat" ,
216+ # Housing
217+ "rent" ,
218+ "council_tax" ,
219+ "tenure_type" ,
220+ ],
221+ }
227222
228223 data = {
229224 "person" : pd .DataFrame (),
@@ -248,6 +243,7 @@ def run(self, simulation: "Simulation") -> "Simulation":
248243 )
249244
250245 simulation .output_dataset = PolicyEngineUKDataset (
246+ id = simulation .id ,
251247 name = dataset .name ,
252248 description = dataset .description ,
253249 filepath = str (
@@ -263,7 +259,23 @@ def run(self, simulation: "Simulation") -> "Simulation":
263259 ),
264260 )
265261
262+ def save (self , simulation : "Simulation" ):
263+ """Save the simulation's output dataset."""
266264 simulation .output_dataset .save ()
267265
266+ def load (self , simulation : "Simulation" ):
267+ """Load the simulation's output dataset."""
268+ simulation .output_dataset = PolicyEngineUKDataset (
269+ id = simulation .id ,
270+ name = simulation .dataset .name ,
271+ description = simulation .dataset .description ,
272+ filepath = str (
273+ Path (simulation .dataset .filepath ).parent
274+ / (simulation .id + ".h5" )
275+ ),
276+ year = simulation .dataset .year ,
277+ is_output_dataset = True ,
278+ )
279+
268280
269281uk_latest = PolicyEngineUKLatest ()
0 commit comments