Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 2024.08.19
_src_path: gh:scientific-python/cookie
backend: hatch
email: alujan@jhu.edu
full_name: Alan Lujan
license: MIT
org: alanlujan91
project_name: SequentialEGM
project_short_description: A great package.
url: https://github.com/alanlujan91/SequentialEGM
vcs: true
3 changes: 3 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git_archival.txt export-subst
14 changes: 1 addition & 13 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ py -m venv .venv
py -m install -v -e .[dev]
```

# Post setup
# Pre-commit

You should prepare pre-commit, which will help you by checking that commits pass
required checks:
Expand Down Expand Up @@ -87,15 +87,3 @@ You can see a preview with:
```bash
nox -s docs -- --serve
```

# Pre-commit

This project uses pre-commit for all style checking. While you can run it with
nox, this is such an important tool that it deserves to be installed on its own.
Install pre-commit and run:

```bash
pre-commit run -a
```

to check all files.
5 changes: 5 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
changelog:
exclude:
authors:
- dependabot
- pre-commit-ci
10 changes: 9 additions & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ concurrency:
cancel-in-progress: true

env:
# Many color libraries just need this to be set to any value, but at least
# one distinguishes color depth, where "3" -> "256-bit color".
FORCE_COLOR: 3

jobs:
Expand All @@ -35,6 +37,8 @@ jobs:
environment: pypi
permissions:
id-token: write
attestations: write
contents: read
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'

Expand All @@ -44,8 +48,12 @@ jobs:
name: Packages
path: dist

- name: Generate artifact attestation for sdist and wheel
uses: actions/attest-build-provenance@v1.4.1
with:
subject-path: "dist/*"

- uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'release' && github.event.action == 'published'
with:
# Remember to tell (test-)pypi about this repo before publishing
# Remove this line to publish to PyPI
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ concurrency:
cancel-in-progress: true

env:
# Many color libraries just need this to be set to any value, but at least
# one distinguishes color depth, where "3" -> "256-bit color".
FORCE_COLOR: 3

jobs:
Expand All @@ -29,9 +31,7 @@ jobs:
with:
extra_args: --hook-stage manual --all-files
- name: Run PyLint
run: |
echo "::add-matcher::$GITHUB_WORKSPACE/.github/matchers/pylint.json"
pipx run nox -s pylint
run: pipx run nox -s pylint -- --output-format=github

checks:
name: Check Python ${{ matrix.python-version }} on ${{ matrix.runs-on }}
Expand All @@ -40,11 +40,11 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.12"]
runs-on: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.13"]
runs-on: [ubuntu-latest, windows-latest, macos-14]

include:
- python-version: pypy-3.10
- python-version: "pypy-3.10"
runs-on: ubuntu-latest

steps:
Expand All @@ -66,4 +66,6 @@ jobs:
--durations=20

- name: Upload coverage report
uses: codecov/codecov-action@v4.0.2
uses: codecov/codecov-action@v4.5.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
46 changes: 46 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This file was created automatically with `myst init --gh-pages` 🪄 💚

name: MyST GitHub Pages Deploy
on:
push:
# Runs on pushes targeting the default branch
branches: [main]
env:
# `BASE_URL` determines the website is served from, including CSS & JS assets
# You may need to change this to `BASE_URL: ''`
BASE_URL: /${{ github.event.repository.name }}

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v3
- uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Install MyST Markdown
run: npm install -g mystmd
- name: Build HTML Assets
run: myst build --html
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: "./_build/html"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ dmypy.json
cython_debug/

# setuptools_scm
code/*/_version.py
src/*/_version.py


# ruff
Expand All @@ -157,6 +157,5 @@ Thumbs.db
*~
*.swp

*_build
*_pdf_logs
*_pdf_tex
# MyST build outputs
_build
48 changes: 25 additions & 23 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ ci:
autoupdate_commit_msg: "chore: update pre-commit hooks"
autofix_commit_msg: "style: pre-commit fixes"

exclude: ^.cruft.json|.copier-answers.yml$

repos:
- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0"
rev: "1.18.0"
hooks:
- id: blacken-docs
additional_dependencies: [black==23.*]
additional_dependencies: [black==24.*]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.6.0"
Expand All @@ -32,38 +34,38 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v4.0.0-alpha.8"
- repo: https://github.com/rbubley/mirrors-prettier
rev: "v3.3.3"
hooks:
- id: prettier
types_or: [yaml, html, css, scss, javascript, json]
args: [--prose-wrap=always]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.10"
rev: "v0.6.1"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format

# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: "v1.8.0"
# hooks:
# - id: mypy
# files: code|tests
# args: []
# additional_dependencies:
# - pytest
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.11.1"
hooks:
- id: mypy
files: src|tests
args: []
additional_dependencies:
- pytest

# - repo: https://github.com/codespell-project/codespell
# rev: "v2.2.6"
# hooks:
# - id: codespell
- repo: https://github.com/codespell-project/codespell
rev: "v2.3.0"
hooks:
- id: codespell

# - repo: https://github.com/shellcheck-py/shellcheck-py
# rev: "v0.9.0.6"
# hooks:
# - id: shellcheck
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: "v0.10.0.1"
hooks:
- id: shellcheck

- repo: local
hooks:
Expand All @@ -74,13 +76,13 @@ repos:
exclude: .pre-commit-config.yaml

- repo: https://github.com/abravalheri/validate-pyproject
rev: "v0.18"
rev: "v0.19"
hooks:
- id: validate-pyproject
additional_dependencies: ["validate-pyproject-schema-store[all]"]

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: "0.28.5"
rev: "0.29.1"
hooks:
- id: check-dependabot
- id: check-github-workflows
Expand Down
17 changes: 17 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

version: 2

build:
os: ubuntu-22.04
tools:
python: "3.12"
commands:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
- uv venv
- uv pip install .[docs]
- .venv/bin/python -m sphinx -T -b html -d docs/_build/doctrees -D
language=en docs $READTHEDOCS_OUTPUT/html
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
---
title: "EGMⁿ: The Sequential Endogenous Grid Method"
author: "Alan Lujan"
date: 2023/02/15
---

# EGMⁿ: The Sequential Endogenous Grid Method

## Abstract

Heterogeneous agent models with multiple decisions are often solved using inefficient grid search methods that require a large number of points and are time intensive. This paper provides a novel method for solving such models using an extension of the endogenous grid method (EGM) that uses Gaussian Process Regression (GPR) to interpolate functions on unstructured grids. First, separating models into smaller, sequential problems allows the problems to be more tractable and easily analyzed. Second, using an exogenous grid of post-decision states and solving for an endogenous grid of pre-decision states that obey a first order condition greatly speeds up the solution process. Third, since the resulting endogenous grid can often be curvilinear at best and unstructured at worst, GPR provides an efficient and accurate method for interpolating the value, marginal value, and policy functions. Applied sequentially to each decision within the overarching problem, the method is able to solve heterogeneous agent models with multiple decisions in a fraction of the time and with less computational resources than are required by standard grid search methods currently used. This paper also illustrates how this method can be applied to a number of increasingly complex models. Software is provided in the form of a Python module under the `HARK` package.
# SequentialEGM

[![Actions Status][actions-badge]][actions-link]
[![Documentation Status][rtd-badge]][rtd-link]
Expand Down
38 changes: 0 additions & 38 deletions _toc.yml

This file was deleted.

2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Run reproduce_paper.py and check if it was successful
if python3 code/reproduce_paper.py; then
if python3 src/reproduce_paper.py; then
echo "reproduce_paper.py ran successfully. Now running myst build..."

# Run myst build command and check if it was successful
Expand Down
Loading