policyengine-simulation-mechanics

Cache policyengine.py simulation results and map data across entities.

31|6|Updated Oct 19, 2025
One-click install
npx skills add https://github.com/PolicyEngine/policyengine-claude --skill policyengine-simulation-mechanics
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: policyengine-simulation-mechanics
Source: https://github.com/PolicyEngine/policyengine-claude/tree/main/skills/tools-and-apis/policyengine-simulation-mechanics-skill
Command: npx skills add https://github.com/PolicyEngine/policyengine-claude --skill policyengine-simulation-mechanics

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill covers advanced simulation mechanics with policyengine.py, including caching, result access, and entity mapping.

Core Features & Use Cases

  • Simulation.ensure(): Smart caching to avoid recomputation.
  • output_dataset.data: Access and analyze simulation results across entities.
  • map_to_entity(): Convert data between person, household, and other units.

Quick Start

Create a Simulation and call ensure() to reuse cached results across reforms.

Frequently Asked Questions about policyengine-simulation-mechanics

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I avoid recomputing simulations when testing policy reforms in policyengine.py?

Use Simulation.ensure() to enable smart caching that reuses baseline results across reforms. The Skill implements in-memory LRU caching for up to 100 simulations and disk persistence via save/load, eliminating redundant computation in iterative policy analysis workflows.

How do I access and analyze simulation results across different entity levels in policyengine?

Access results via output_dataset.data to retrieve simulation outputs, then use map_to_entity() to convert data between person, household, and other entity levels. This lets you analyze outcomes at the appropriate granularity for your policy question.

When should I use caching in policyengine.py simulations?

Caching is essential for batch scenario simulation and comparative policy analysis where you reuse the same baseline across multiple reforms. It eliminates inefficient recomputation and dramatically speeds up iterative development and what-if analysis.

Can I persist simulation results to disk with policyengine.py?

Yes. Beyond in-memory LRU caching, the Skill provides disk persistence via save/load methods, letting you preserve simulation state across sessions and share cached results for reproducible policy analysis.

How do I convert simulation data between person and household levels?

The map_to_entity() function converts data between person, household, and benunit/entity levels, enabling you to aggregate or disaggregate simulation outputs to match your analytical or reporting requirements.

What's the best way to structure policyengine simulations for comparative policy analysis?

Create a baseline Simulation, call ensure() to cache it, then run reforms against that cached baseline. This workflow maximizes reuse of computation across multiple policy scenarios and minimizes redundant processing.