fomtools 0.0.4__tar.gz → 0.0.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fomtools-0.0.4 → fomtools-0.0.6}/AGENTS.md +4 -3
- {fomtools-0.0.4/fomtools.egg-info → fomtools-0.0.6}/PKG-INFO +1 -3
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/get_started.md +1 -1
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/cvxpygen.md +3 -3
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/user_guide/codegen.md +65 -15
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/canonicalizers/obbt_handler.py +38 -7
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/agent/__init__.py +17 -35
- fomtools-0.0.6/fomtools/codegen/agent/agents.yaml +98 -0
- fomtools-0.0.6/fomtools/codegen/agent/budget.py +47 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/agent/cli_driver.py +170 -110
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/agent/cli_specs.py +48 -60
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/agent/driver.py +15 -24
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/agent/prompts.py +34 -2
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/agent/stub.py +2 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/cli.py +7 -7
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/config.py +32 -20
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/generate.py +209 -9
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/postprocess.py +43 -20
- fomtools-0.0.6/fomtools/codegen/progress.py +194 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/targets/embedded_c.py +13 -9
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/cvxpygen/api.py +1 -1
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/solvers/gurobi.py +29 -1
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/solvers/highs.py +47 -4
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/solvers/solver.py +9 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/verifier.py +4 -0
- {fomtools-0.0.4 → fomtools-0.0.6/fomtools.egg-info}/PKG-INFO +1 -3
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools.egg-info/SOURCES.txt +3 -4
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools.egg-info/requires.txt +0 -2
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools.egg-info/scm_file_list.json +3 -4
- fomtools-0.0.6/fomtools.egg-info/scm_version.json +8 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/pyproject.toml +4 -5
- {fomtools-0.0.4 → fomtools-0.0.6}/skills/fomtools/references/codegen.md +11 -1
- fomtools-0.0.6/tests/codegen/test_agent_budget.py +344 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_agent_integration.py +5 -5
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_agent_notes.py +10 -18
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_cli.py +22 -7
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_optimization_rounds.py +8 -1
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_profiling.py +40 -0
- fomtools-0.0.6/tests/codegen/test_progress.py +233 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_obbt_handler.py +127 -6
- fomtools-0.0.6/tests/test_solver_update_bounds.py +187 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/uv.lock +4 -425
- fomtools-0.0.4/fomtools/codegen/agent/agents.yaml +0 -33
- fomtools-0.0.4/fomtools/codegen/agent/budget.py +0 -132
- fomtools-0.0.4/fomtools/codegen/agent/claude_sdk.py +0 -221
- fomtools-0.0.4/fomtools/codegen/agent/codex_sdk.py +0 -151
- fomtools-0.0.4/fomtools/codegen/agent/pidev_sdk.py +0 -131
- fomtools-0.0.4/fomtools/codegen/agent/sdk_base.py +0 -384
- fomtools-0.0.4/fomtools.egg-info/scm_version.json +0 -8
- fomtools-0.0.4/tests/codegen/test_agent_budget.py +0 -147
- {fomtools-0.0.4 → fomtools-0.0.6}/.github/workflows/ci.yml +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/.github/workflows/claude-code-review.yml +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/.github/workflows/claude.yml +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/.github/workflows/docs.yml +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/.github/workflows/release.yml +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/.github/workflows/update-skill.yml +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/.gitignore +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/.pre-commit-config.yaml +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/CLAUDE.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/CONTRIBUTING.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/LICENSE +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/Makefile +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/README.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/api/canonicalizer.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/api/codegen.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/api/constraint.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/api/index.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/api/linearexpression.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/api/proxablefunctions.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/api/solvers.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/api/steps.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/api/verifier.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/assets/logo/favicon-16.png +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/assets/logo/favicon-32.png +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/assets/logo/favicon-48.png +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/assets/logo/favicon.svg +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/assets/logo/icon-512.png +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/assets/logo/icon-dark.svg +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/assets/logo/icon-mono.svg +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/assets/logo/icon-small.svg +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/assets/logo/icon.svg +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/assets/logo/logo-dark.svg +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/assets/logo/logo-mono.svg +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/assets/logo/logo.svg +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/index.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/javascripts/mathjax.js +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/quick_start.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/stylesheets/extra.css +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/codegen/_recorded_timings.json +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/codegen/control.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/codegen/control.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/codegen/lasso.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/codegen/lasso.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/codegen/network.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/codegen/network.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/codegen/nnls.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/codegen/nnls.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/codegen/portfolio.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/codegen/portfolio.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/codegen/speedup_results.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/codegen.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/cvxpygen_mpc.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/helper_functions/codegen_benchmarks.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/helper_functions/control.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/helper_functions/lasso.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/helper_functions/network.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/helper_functions/nnls.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/helper_functions/pepit_runner.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/helper_functions/portfolio.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/index.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/verification/control.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/verification/lasso.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/verification/network.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/verification/nnls.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/verification/portfolio.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/tutorials/verification.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/user_guide/index.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/docs/user_guide/sdp.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/__init__.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/canonicalizers/__init__.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/canonicalizers/canonicalizer.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/canonicalizers/mip.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/canonicalizers/sdp.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/canonicalizers/simulator.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/__init__.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/dedup.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/emit.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/examples.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/extract.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/extract_scheduled.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/extract_unrolled.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/factorize.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/harness.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/ir.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/kernel_rules.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/objective.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/oracle.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/schedule.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/spec.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/targets/__init__.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/targets/base.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/targets/large_scale_cuda.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/targets/large_scale_openmp.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/codegen/wrapper.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/constraint.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/cvxpygen/__init__.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/cvxpygen/builders.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/cvxpygen/glue.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/cvxpygen/interface.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/cvxpygen/qpdata.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/cvxpygen/scaling.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/iteratetrajectory.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/linearexpression.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/nn/__init__.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/nn/layers.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/__init__.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/elastic_net.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/hinge_loss.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/huber_loss.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/ind_affine.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/ind_ball_l1.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/ind_ball_linf.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/ind_box.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/ind_half_space.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/ind_nonnegative.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/ind_nonpositive.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/ind_point.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/ind_polyhedral.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/ind_simplex.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/labeled_hinge_loss.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/least_squares.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/linear.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/norm_inf.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/norm_l1.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/proximal_operator.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/quadratic.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/soft_nonnegative.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/sq_l2_norm.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/sum_negative.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/sum_positive.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/proxable_functions/total_variation_1d.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/sets/__init__.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/sets/affine_subspace.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/sets/ball.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/sets/box.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/sets/polyhedron.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/sets/set.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/solvers/__init__.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/solvers/clarabel.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/solvers/cuclarabel.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/solvers/factory.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/solvers/mip_solver.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/solvers/sdp_solver.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/stepdecomposers/__init__.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/stepdecomposers/mip_step_decomposer.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/stepdecomposers/sdp_step_decomposer.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/stepdecomposers/simulator_step_decomposer.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/stepdecomposers/step_decomposer.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/steps/__init__.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/steps/affine.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/steps/lin_prog.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/steps/quad_prog.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/steps/relu.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/steps/saturated_linear.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/steps/soft_threshold.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/steps/step.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/utils/__init__.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/utils/convex_hull_cuts.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/utils/dict_utils.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/utils/envelopes.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/utils/math_utils.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/utils/matrix_utils.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/utils/range_utils.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools/utils/sparse_utils.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools.egg-info/dependency_links.txt +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools.egg-info/entry_points.txt +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/fomtools.egg-info/top_level.txt +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/mkdocs.yml +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/overrides/main.html +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/overrides/partials/logo.html +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/scripts/export_marimo.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/setup.cfg +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/skills/README.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/skills/fomtools/SKILL.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/skills/fomtools/references/api.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/skills/fomtools/references/cvxpygen.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/skills/update-prompt.md +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/__init__.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/__init__.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/conftest.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/boxqp/embedded_c/fom_solver.c +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/cgqp/large_scale_cuda/fom_solver.cu +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/cgqp/large_scale_openmp/fom_solver.c +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/cvxpygen_qp/embedded_c/fom_solver.c +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/cvxpygen_qp_objective/embedded_c/fom_solver.c +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/dr/embedded_c/fom_solver.c +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/fista/embedded_c/fom_solver.c +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/fista_objective/embedded_c/fom_solver.c +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/halpern/embedded_c/fom_solver.c +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/indef_kkt/embedded_c/fom_solver.c +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/ista/embedded_c/fom_solver.c +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/ista/large_scale_cuda/fom_solver.cu +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/ista/large_scale_openmp/fom_solver.c +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/ista_objective/embedded_c/fom_solver.c +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/ista_objective/large_scale_cuda/fom_solver.cu +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/mpc/embedded_c/fom_solver.c +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/pdhg_lp/embedded_c/fom_solver.c +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/pdhg_lp/large_scale_cuda/fom_solver.cu +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/scheduled/embedded_c/fom_solver.c +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/scheduled_objective/embedded_c/fom_solver.c +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/golden/scheduled_objective/large_scale_cuda/fom_solver.cu +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_codegen_dispatch.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_cvxpygen_bounds.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_cvxpygen_builders.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_cvxpygen_dispatch.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_cvxpygen_e2e.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_cvxpygen_glue.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_cvxpygen_objective.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_cvxpygen_preflight.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_cvxpygen_qpdata.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_cvxpygen_register.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_cvxpygen_scaling.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_cvxpygen_scheduled.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_dedup.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_dr_pipeline.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_editable_linsolve.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_editable_ops.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_emit_scaffold.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_examples_scale.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_factorize.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_fista_pipeline.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_float32.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_fused_ops.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_indefinite_kkt.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_ir_extraction.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_large_scale.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_objective_termination.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_oracle.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_pdhg_pipeline.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_postprocess.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_satlin_mpc.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_scheduled_ir.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_scheduled_pipeline.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_spec_roundtrip.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_static_constraints.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_stationarity_gate.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_step_iterate.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_stub_pipeline.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_termination_interval.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_unrolled_emission.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_unrolled_ir.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/codegen/test_wrapper_roundtrip.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/conftest.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/cvxpy.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/examples/comparison_lasso.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/examples/cut_experiment.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_LP_pdhg.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_add_constraint.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_affine_simulator.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_api.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_audit_regressions.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_boxpgd_sdp_mip.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_complementarity.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_convex_hull_cuts.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_copy_isolation.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_docs_examples.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_douglas_rachford.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_export_marimo.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_fixed_point_ista.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_fixed_point_nnls.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_ind_ball_l1.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_ind_polyhedral.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_ind_simplex.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_inf_norm_sdp.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_infinite_bounds.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_ista.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_ista_sdp_mip.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_iterate_trajectory.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_l1_obj_norm.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_linear_program.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_linearexpression.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_linsolve_simulator.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_mincost_flow.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_mip_solution_consistency.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_nn_verify_jax.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_nn_verify_torch.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_nnls_sdp_mip.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_norm_inf.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_objective_bounds.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_partial_relu.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_partial_relu_sdp_sim.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_placeholder.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_portfolio.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_prox_decomposer.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_quadratic_program.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_range_functions.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_relu_simulator.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_satlin.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_satlin_simulator.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_sdp_canonicalizer.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_sdp_cuts.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_sdp_hull.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_sdp_inequality.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_sdp_nnls.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_sdp_selector.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_sets.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_simulator.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_soft_threshold_simulator.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_solve_kwargs.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_solver_boundary.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_sparse_utils.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_stack.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_subproblem_simulator.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_sum_squares.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_tighten_residuals.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_total_variation_1d.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_two_norm_mip.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_vec_LUhat.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_verifier.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_verifier_ista.py +0 -0
- {fomtools-0.0.4 → fomtools-0.0.6}/tests/test_warm_start.py +0 -0
|
@@ -67,12 +67,13 @@ These invariants are checked by tests; keep them when editing `fomtools/codegen/
|
|
|
67
67
|
- Every generated solver must pass the numerical acceptance check against the
|
|
68
68
|
NumPy oracle (`oracle.py`); the agent may only edit the files a target marks
|
|
69
69
|
editable, and the package restores the rest before each check.
|
|
70
|
-
- Agent backends are pluggable:
|
|
71
|
-
|
|
70
|
+
- Agent backends are pluggable: every agent is a headless CLI described in
|
|
71
|
+
`agent/agents.yaml` (`claude`, `codex`, `pi`, `cursor`) and run by
|
|
72
|
+
`agent/cli_driver.py`; no vendor SDKs. `fomtools/codegen/agent/stub.py` lets the
|
|
72
73
|
pipeline and tests run without a model.
|
|
73
74
|
|
|
74
75
|
Useful environment variables: `FOMTOOLS_CUDA_RUN=1|0` forces or disables GPU
|
|
75
|
-
execution of the CUDA checks; `FOMTOOLS_CODEGEN_BACKEND` selects the agent.
|
|
76
|
+
execution of the CUDA checks; `FOMTOOLS_CODEGEN_BACKEND` selects the agent and `FOMTOOLS_CODEGEN_MODEL` its model.
|
|
76
77
|
|
|
77
78
|
## Conventions
|
|
78
79
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fomtools
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.6
|
|
4
4
|
Summary: FOMTools: A Python Toolbox for Analysis of First-Order Methods
|
|
5
5
|
Author-email: Vinit Ranjan <vranjan1@mit.edu>, Daniel Deza <dd7022@princeton.edu>, Anushka Acharya <aa9078@princeton.edu>, Jisun Park <jisunpark@princeton.edu>, Bartolomeo Stellato <bstellato@princeton.edu>
|
|
6
6
|
License: Apache 2.0
|
|
@@ -20,8 +20,6 @@ Requires-Dist: cupy-cuda12x; extra == "gpu"
|
|
|
20
20
|
Provides-Extra: cuda
|
|
21
21
|
Requires-Dist: nvidia-cudss-cu13; sys_platform == "linux" and extra == "cuda"
|
|
22
22
|
Provides-Extra: codegen
|
|
23
|
-
Requires-Dist: claude-agent-sdk; extra == "codegen"
|
|
24
|
-
Requires-Dist: openai-codex; extra == "codegen"
|
|
25
23
|
Provides-Extra: cvxpygen
|
|
26
24
|
Requires-Dist: cvxpygen<2,>=1.0; extra == "cvxpygen"
|
|
27
25
|
Requires-Dist: osqp; extra == "cvxpygen"
|
|
@@ -76,7 +76,7 @@ Quote extras so shells such as zsh do not interpret the brackets. From PyPI use
|
|
|
76
76
|
| Extra | Installation | Purpose |
|
|
77
77
|
|---|---|---|
|
|
78
78
|
| Gurobi | `uv pip install -e ".[gurobi]"` | Optional MIP/MIQP/MIQCP backend; a suitable Gurobi license is required |
|
|
79
|
-
| Code generation | `uv pip install -e ".[codegen]"` |
|
|
79
|
+
| Code generation | `uv pip install -e ".[codegen]"` | Nothing extra (kept for compatibility); code generation needs an installed, logged-in agent CLI such as Claude Code or Codex |
|
|
80
80
|
| CVXPYgen | `uv pip install -e ".[cvxpygen]"` | High-level problem-modeling integration |
|
|
81
81
|
| CUDA code generation | `uv pip install -e ".[cuda]"` | cuDSS for direct linear solves in the generated CUDA solver (Linux) |
|
|
82
82
|
| GPU | `uv pip install -e ".[gpu]"` | CuPy for CUDA simulation; GPU SDP additionally requires Julia, Clarabel.jl with CUDA, and juliacall |
|
|
@@ -120,9 +120,9 @@ application allows.
|
|
|
120
120
|
solver, its linear solves and its matrix-vector products for speed, and the
|
|
121
121
|
rewrite is kept only if it passes verification again (including the direct
|
|
122
122
|
checks of each solve and product) and is benchmarked faster. Its budget comes from `config`
|
|
123
|
-
(`agent_optimize_timeout_s`, two hours per round by default,
|
|
124
|
-
|
|
125
|
-
[time
|
|
123
|
+
(`agent_optimize_timeout_s`, two hours per round by default, and up to
|
|
124
|
+
`agent_optimize_rounds` rounds; see
|
|
125
|
+
[time budgets](../user_guide/codegen.md#time-budgets)).
|
|
126
126
|
|
|
127
127
|
## The three generation paths
|
|
128
128
|
|
|
@@ -18,9 +18,9 @@ examples, and [the API page](../api/codegen.md) documents each symbol.
|
|
|
18
18
|
## Defining the FOM
|
|
19
19
|
|
|
20
20
|
The Python snippets below reuse the imports and problem data in the first block.
|
|
21
|
-
Calls to `codegen`, `codegen_rolled`, and `generate_code`
|
|
22
|
-
|
|
23
|
-
or an explicit `driver=`. Recording the method requires no coding agent.
|
|
21
|
+
Calls to `codegen`, `codegen_rolled`, and `generate_code` need a coding-agent CLI
|
|
22
|
+
that is installed and already logged in (`claude` by default), enabled with
|
|
23
|
+
`FOMTOOLS_CODEGEN_AGENT=1`, or an explicit `driver=`. Recording the method requires no coding agent.
|
|
24
24
|
|
|
25
25
|
Write the algorithm as a loop, exactly as you would to verify it, and keep the
|
|
26
26
|
iterate sequence. An
|
|
@@ -228,11 +228,24 @@ settings and at other runtime `check_termination` and `max_iter`. An unrolled ru
|
|
|
228
228
|
(one that does not roll back up) evaluates the objective once, after its single
|
|
229
229
|
pass.
|
|
230
230
|
|
|
231
|
-
This requires a coding agent
|
|
232
|
-
`
|
|
233
|
-
|
|
231
|
+
This requires a coding agent: an installed, logged-in agent CLI. Claude Code
|
|
232
|
+
(`claude`, the default), Codex (`codex`), Pi (`pi`), and Cursor (`cursor-agent`)
|
|
233
|
+
are bundled in `fomtools/codegen/agent/agents.yaml`, and any other headless agent
|
|
234
|
+
can be added there or in `~/.config/fomtools/agents.yaml`. No Python packages are
|
|
235
|
+
needed for it. Enable it with `FOMTOOLS_CODEGEN_AGENT=1`, or pass an explicit
|
|
236
|
+
driver (for example a `StubAgentDriver` wrapping a known-good source) for fully
|
|
234
237
|
deterministic, offline runs.
|
|
235
238
|
|
|
239
|
+
Select the agent with `FOMTOOLS_CODEGEN_BACKEND` (or `--agent` on the command
|
|
240
|
+
line). Each agent uses its CLI's own default model and configuration, so it
|
|
241
|
+
follows the CLI's updates. To pick a model, set `CodegenConfig(agent_model=...)`
|
|
242
|
+
(`--model` on the command line), which takes precedence over
|
|
243
|
+
`FOMTOOLS_CODEGEN_MODEL`:
|
|
244
|
+
|
|
245
|
+
```python
|
|
246
|
+
config = CodegenConfig(agent_model="claude-opus-5-5")
|
|
247
|
+
```
|
|
248
|
+
|
|
236
249
|
The emitted directory (`out/ista`) contains:
|
|
237
250
|
|
|
238
251
|
```
|
|
@@ -318,12 +331,46 @@ Profiling breakdown (hottest first):
|
|
|
318
331
|
```
|
|
319
332
|
|
|
320
333
|
The generated directory also exposes `make bench` and `make profile` directly.
|
|
334
|
+
|
|
335
|
+
### Watching the run
|
|
336
|
+
|
|
337
|
+
Pass `verbose=True` to follow the run as it happens: one line per phase, one per
|
|
338
|
+
optimization round with a bar that shrinks with the solve time, and a final summary
|
|
339
|
+
with the optimizations the agent kept. On a terminal a spinner shows the elapsed
|
|
340
|
+
time. Output of a real run on the Lasso example (ISTA, 200 iterations, embedded C):
|
|
341
|
+
|
|
342
|
+
```
|
|
343
|
+
✓ extract + scaffold data, factorizations, matvecs 0 s
|
|
344
|
+
✓ translate → C (agent) VERIFY OK max err 0e+00 1.95 µs 95 s
|
|
345
|
+
✓ optimize · round 1 (agent) 1.43 µs → 1.29 µs ███████████░ 1.10x VERIFY ✓ 1814 s
|
|
346
|
+
✗ optimize · round 2 (agent) 1.18 µs vs 1.01 µs best, not faster, reverted 1584 s
|
|
347
|
+
|
|
348
|
+
lasso
|
|
349
|
+
translated C 1.43 µs ██████████████████████████████
|
|
350
|
+
optimized C 1.29 µs ███████████████████████████ 1.10x faster
|
|
351
|
+
NumPy 1,503 µs
|
|
352
|
+
VERIFY OK worst error 4.4e-16 over 8 samples
|
|
353
|
+
what the agent found:
|
|
354
|
+
• Ping-pong state/new_state buffers, drop per-iter copy
|
|
355
|
+
• Hoist bias_t0 computation outside the iteration loop
|
|
356
|
+
• Inline t0_state matrix coefficients, unroll 4x4 product
|
|
357
|
+
• Fuse fom_iterate into single inlined matvec+soft+add
|
|
358
|
+
• Rewrite soft-threshold as v - clamp(v,-l,l) via fmin/fmax
|
|
359
|
+
• ...
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Each round is timed head to head against the best solver so far: both are built
|
|
363
|
+
once, then run five times each in alternating order, and the medians are compared.
|
|
364
|
+
One `make bench` warms up for 20 ms and then times full solves for 100 ms, so even
|
|
365
|
+
a microsecond solve is timed over many thousands of runs. The times printed for a
|
|
366
|
+
round can still differ from earlier lines by a few percent. A rewrite that is not
|
|
367
|
+
faster, or fails verification, is reverted.
|
|
321
368
|
The portable region profiler (`include/fom_profile.h`) is compiled in only for
|
|
322
369
|
`make profile` (`-DFOM_PROFILE`); its `FOM_PROF_BEGIN/END` macros are no-ops in
|
|
323
370
|
the shipped `make verify` / `make lib` builds, so profiling never affects the
|
|
324
371
|
production solver.
|
|
325
372
|
|
|
326
|
-
### Time
|
|
373
|
+
### Time budgets
|
|
327
374
|
|
|
328
375
|
Each agent phase runs under a budget, set per run on `CodegenConfig`:
|
|
329
376
|
|
|
@@ -331,7 +378,6 @@ Each agent phase runs under a budget, set per run on `CodegenConfig`:
|
|
|
331
378
|
|---|---|---|
|
|
332
379
|
| `agent_timeout_s` | 600 s (10 min) | wall-clock time of the translation phase |
|
|
333
380
|
| `agent_optimize_timeout_s` | 7200 s (2 h) | wall-clock time of one code optimization round |
|
|
334
|
-
| `agent_optimize_max_turns` | 200 | agent turns of one code optimization round |
|
|
335
381
|
| `agent_optimize_rounds` | 5 | maximum number of code optimization rounds |
|
|
336
382
|
| `agent_optimize_min_gain` | 0.02 | a round gaining less than this (relative) ends the phase |
|
|
337
383
|
|
|
@@ -354,18 +400,21 @@ keep the translated solver too.
|
|
|
354
400
|
|
|
355
401
|
Translation is a bounded task and rarely needs more than a few minutes. The code
|
|
356
402
|
optimization phase is open-ended, and on a GPU every round (an `nvcc` build,
|
|
357
|
-
`make verify`, `make bench`) is slow, so it gets two hours
|
|
358
|
-
|
|
403
|
+
`make verify`, `make bench`) is slow, so it gets two hours. Raise the budgets for
|
|
404
|
+
larger problems:
|
|
359
405
|
|
|
360
406
|
```python
|
|
361
|
-
config = CodegenConfig(agent_optimize_timeout_s=4 * 3600
|
|
407
|
+
config = CodegenConfig(agent_optimize_timeout_s=4 * 3600)
|
|
362
408
|
result = generate_code(..., config=config, code_optimization=True)
|
|
363
409
|
```
|
|
364
410
|
|
|
365
411
|
or, on the command line, `--translate-timeout`, `--optimize-timeout` (seconds),
|
|
366
|
-
`--optimize-
|
|
412
|
+
`--optimize-rounds` and `--optimize-min-gain`. The
|
|
367
413
|
budgets apply to whichever agent driver runs, a driver you build yourself included: one built without a config takes the run's.
|
|
368
|
-
|
|
414
|
+
A minute before a budget runs out, the agent is told to stop through the
|
|
415
|
+
`FOMTOOLS_DEADLINE` environment variable (Unix time). The bundled Claude Code spec
|
|
416
|
+
reads it in a hook that then refuses further tool calls and asks for the summary;
|
|
417
|
+
an agent you add can do the same. When the budget runs out the agent is stopped, whatever it wrote is re-verified and
|
|
369
418
|
benchmarked as usual, and the report says so (in that case the agent may not have
|
|
370
419
|
written its own summary). For reference, a CUDA CG solve stopped at 30 minutes
|
|
371
420
|
had already gone from 2.05 s to 0.114 s per solve and was still improving.
|
|
@@ -754,8 +803,9 @@ both side by side is the quickest way to see what declaring a coefficient buys.
|
|
|
754
803
|
`--scaffold-only` emits everything except the solver body (useful to inspect the
|
|
755
804
|
spec and data before invoking the agent). `--no-roll` keeps a recorded run
|
|
756
805
|
unrolled even when it could be rolled back up. `--translate-timeout`,
|
|
757
|
-
`--optimize-timeout` (seconds), `--optimize-
|
|
758
|
-
`--optimize-min-gain` set the agent's budgets for this run ([above](#time-
|
|
806
|
+
`--optimize-timeout` (seconds), `--optimize-rounds` and
|
|
807
|
+
`--optimize-min-gain` set the agent's budgets for this run ([above](#time-budgets)),
|
|
808
|
+
and `--agent` and `--model` select the agent and its model. `--tol` alone stops on the
|
|
759
809
|
infinity-norm change; with `--objective` it stops on the verification objective
|
|
760
810
|
the module set on its recording, and `--check-termination N` sets the interval.
|
|
761
811
|
|
|
@@ -34,6 +34,12 @@ class OBBTHandler(Canonicalizer):
|
|
|
34
34
|
tolerances.
|
|
35
35
|
crossing_repairs : int
|
|
36
36
|
Number of bound entries repaired this way so far.
|
|
37
|
+
lp_retries : int
|
|
38
|
+
Number of OBBT LPs not solved to optimality warm-started but solved
|
|
39
|
+
from scratch (``Solver.optimize_from_scratch``) so far.
|
|
40
|
+
lp_failures : int
|
|
41
|
+
Number of OBBT LPs not solved to optimality even from scratch so far;
|
|
42
|
+
each keeps the input bound of its entry and sense.
|
|
37
43
|
"""
|
|
38
44
|
|
|
39
45
|
def __init__(self, solver: str, solver_params: dict = None, crossing_tol: float = 1e-6):
|
|
@@ -56,6 +62,8 @@ class OBBTHandler(Canonicalizer):
|
|
|
56
62
|
super().__init__(solver_params=solver_params, solver=solver)
|
|
57
63
|
self.crossing_tol = crossing_tol
|
|
58
64
|
self.crossing_repairs = 0
|
|
65
|
+
self.lp_retries = 0
|
|
66
|
+
self.lp_failures = 0
|
|
59
67
|
|
|
60
68
|
def add_var(self, var: LinearExpression) -> None:
|
|
61
69
|
"""
|
|
@@ -161,11 +169,14 @@ class OBBTHandler(Canonicalizer):
|
|
|
161
169
|
-------
|
|
162
170
|
tuple[np.ndarray, np.ndarray] | None
|
|
163
171
|
A tuple ``(new_lb, new_ub)`` containing the tightened lower
|
|
164
|
-
and upper bounds.
|
|
165
|
-
|
|
172
|
+
and upper bounds. An LP not solved to optimality is solved once
|
|
173
|
+
more from scratch; if that fails too, its entry keeps the input
|
|
174
|
+
bound for that sense, and the other entries are still tightened.
|
|
175
|
+
Returns ``None`` if a bound stays nonfinite.
|
|
166
176
|
"""
|
|
167
|
-
|
|
168
|
-
|
|
177
|
+
# An LP that is not solved to optimality leaves the input bound in place.
|
|
178
|
+
lb_out = np.array(lb, dtype=float, copy=True)
|
|
179
|
+
ub_out = np.array(ub, dtype=float, copy=True)
|
|
169
180
|
|
|
170
181
|
for sense in ["minimize", "maximize"]:
|
|
171
182
|
for i, expr in enumerate(linexpr):
|
|
@@ -173,9 +184,29 @@ class OBBTHandler(Canonicalizer):
|
|
|
173
184
|
self.solver.optimize()
|
|
174
185
|
|
|
175
186
|
if not self.solver.is_optimal():
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
187
|
+
# A warm-started solve can end with a wrong status (on della, a
|
|
188
|
+
# feasible LP came back INFEASIBLE); retry once from scratch.
|
|
189
|
+
status = self.solver["status"]
|
|
190
|
+
self.solver.optimize_from_scratch()
|
|
191
|
+
if self.solver.is_optimal():
|
|
192
|
+
self.lp_retries += 1
|
|
193
|
+
log.info(
|
|
194
|
+
"OBBT: LP for entry %d (%s) ended with status %s; solved from scratch",
|
|
195
|
+
i,
|
|
196
|
+
sense,
|
|
197
|
+
status,
|
|
198
|
+
)
|
|
199
|
+
else:
|
|
200
|
+
self.lp_failures += 1
|
|
201
|
+
log.info(
|
|
202
|
+
"OBBT: LP for entry %d (%s) not solved to optimality (status %s, "
|
|
203
|
+
"%s from scratch); keeping its input bound",
|
|
204
|
+
i,
|
|
205
|
+
sense,
|
|
206
|
+
status,
|
|
207
|
+
self.solver["status"],
|
|
208
|
+
)
|
|
209
|
+
continue
|
|
179
210
|
|
|
180
211
|
if sense == "maximize":
|
|
181
212
|
ub_out[i] = self.solver["objVal"]
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"""Coding-agent drivers for code generation.
|
|
2
2
|
|
|
3
|
-
Code generation is **agent-agnostic**:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
(`ClaudeAgentDriver`,
|
|
12
|
-
`CodexAgentDriver`,
|
|
13
|
-
`PiDevAgentDriver`) that prefer an
|
|
14
|
-
in-process SDK (Pi via its JSON-RPC subprocess) with a CLI fallback. Anything
|
|
15
|
-
that is not a CLI can implement the
|
|
3
|
+
Code generation is **agent-agnostic**: every agent is a headless CLI described by
|
|
4
|
+
a declarative `CliAgentSpec` and driven by the generic `CliAgentDriver`. Specs
|
|
5
|
+
for ``claude`` (the default), ``codex``, ``pi`` (https://pi.dev), and ``cursor``
|
|
6
|
+
ship in ``agents.yaml``; users add their own agents with no code changes, at
|
|
7
|
+
runtime via `register_agent` or in a YAML config (see `load_user_specs`). Each
|
|
8
|
+
agent runs through its own installed CLI, so it uses the user's login, config,
|
|
9
|
+
and default model; set ``CodegenConfig.agent_model`` or ``FOMTOOLS_CODEGEN_MODEL``
|
|
10
|
+
to pick another model. Anything that is not a CLI can implement the
|
|
16
11
|
`AgentDriver` ABC directly.
|
|
17
12
|
"""
|
|
18
13
|
|
|
@@ -32,17 +27,15 @@ from fomtools.codegen.agent.cli_specs import (
|
|
|
32
27
|
register_agent,
|
|
33
28
|
)
|
|
34
29
|
from fomtools.codegen.agent.stub import StubAgentDriver
|
|
35
|
-
from fomtools.codegen.agent.claude_sdk import ClaudeAgentDriver
|
|
36
30
|
from fomtools.codegen.agent.cli_driver import CliAgentDriver
|
|
37
31
|
from fomtools.codegen.agent.cli_specs import get_spec
|
|
38
|
-
from fomtools.codegen.agent.codex_sdk import CodexAgentDriver
|
|
39
|
-
from fomtools.codegen.agent.pidev_sdk import PiDevAgentDriver
|
|
40
32
|
|
|
41
33
|
__all__ = [
|
|
42
34
|
"AgentBackendError",
|
|
43
35
|
"AgentDriver",
|
|
44
36
|
"AgentResult",
|
|
45
37
|
"AgentTask",
|
|
38
|
+
"CliAgentDriver",
|
|
46
39
|
"CliAgentSpec",
|
|
47
40
|
"StubAgentDriver",
|
|
48
41
|
"available_backends",
|
|
@@ -51,36 +44,25 @@ __all__ = [
|
|
|
51
44
|
"register_agent",
|
|
52
45
|
]
|
|
53
46
|
|
|
54
|
-
|
|
55
|
-
# its JSON-RPC subprocess), as opposed to declarative CLI specs in the registry.
|
|
56
|
-
# The first is the default backend.
|
|
57
|
-
_SDK_BACKENDS = ("claude", "codex", "pi")
|
|
58
|
-
_DEFAULT_BACKEND = _SDK_BACKENDS[0]
|
|
47
|
+
_DEFAULT_BACKEND = "claude"
|
|
59
48
|
|
|
60
49
|
|
|
61
50
|
def available_backends() -> list[str]:
|
|
62
|
-
"""All selectable backends:
|
|
63
|
-
return
|
|
51
|
+
"""All selectable backends: every registered CLI spec (bundled and user)."""
|
|
52
|
+
return available_specs()
|
|
64
53
|
|
|
65
54
|
|
|
66
55
|
def make_agent_driver(backend: str | None = None, config=None) -> AgentDriver:
|
|
67
56
|
"""Construct a real coding-agent driver for the selected backend.
|
|
68
57
|
|
|
69
|
-
``backend`` is any name from `available_backends` (
|
|
70
|
-
``
|
|
58
|
+
``backend`` is any name from `available_backends` (bundled ``claude`` /
|
|
59
|
+
``codex`` / ``pi`` / ``cursor``, or a user-registered CLI agent). When
|
|
71
60
|
``None`` it is read from ``FOMTOOLS_CODEGEN_BACKEND`` and otherwise defaults
|
|
72
|
-
to ``"claude"``.
|
|
73
|
-
|
|
61
|
+
to ``"claude"``. The model is ``config.agent_model``, else
|
|
62
|
+
``FOMTOOLS_CODEGEN_MODEL``, else the CLI's own default. These backends are
|
|
63
|
+
nondeterministic and need auth, so they never run in CI.
|
|
74
64
|
"""
|
|
75
65
|
backend = backend or os.environ.get("FOMTOOLS_CODEGEN_BACKEND") or _DEFAULT_BACKEND
|
|
76
|
-
match backend:
|
|
77
|
-
case "claude":
|
|
78
|
-
return ClaudeAgentDriver(config=config)
|
|
79
|
-
case "codex":
|
|
80
|
-
return CodexAgentDriver(config=config)
|
|
81
|
-
case "pi":
|
|
82
|
-
return PiDevAgentDriver(config=config)
|
|
83
|
-
|
|
84
66
|
try:
|
|
85
67
|
spec = get_spec(backend)
|
|
86
68
|
except KeyError:
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Agent config for fomtools codegen.
|
|
2
|
+
#
|
|
3
|
+
# This file is loaded automatically: just edit it in place to add or tweak an
|
|
4
|
+
# agent and it is immediately available — no copying or env vars required.
|
|
5
|
+
# Each entry under `agents:` registers a headless coding-agent CLI as a backend
|
|
6
|
+
# you can select with `--agent <name>` or FOMTOOLS_CODEGEN_BACKEND=<name>.
|
|
7
|
+
#
|
|
8
|
+
# To override these per-user, or keep config outside the package, you can also
|
|
9
|
+
# use (later wins on a name clash):
|
|
10
|
+
# ~/.config/fomtools/agents.yaml # per-user config
|
|
11
|
+
# $FOMTOOLS_CODEGEN_AGENTS # explicit path (takes precedence)
|
|
12
|
+
#
|
|
13
|
+
# Valid keys map 1:1 onto fomtools.codegen.agent.cli_specs.CliAgentSpec; an unknown
|
|
14
|
+
# key raises so typos surface loudly. `bin` is the only required key.
|
|
15
|
+
|
|
16
|
+
agents:
|
|
17
|
+
# Claude Code (https://claude.com/claude-code), the default backend. Runs
|
|
18
|
+
# `claude -p` headless in the output dir with the file and shell tools. The
|
|
19
|
+
# PreToolUse hook enforces the phase's time budget: once FOMTOOLS_DEADLINE
|
|
20
|
+
# (Unix time, set by fomtools) has passed, every tool call is refused with an
|
|
21
|
+
# instruction to stop and summarize, a minute before the process is ended.
|
|
22
|
+
# CLAUDE_CODE_DISABLE_BACKGROUND_TASKS keeps every Bash command in the
|
|
23
|
+
# foreground: a background task (asked for, or a command that outlived the
|
|
24
|
+
# Bash timeout) keeps `claude -p` waiting after its reply, until the phase
|
|
25
|
+
# timeout ends it (#166).
|
|
26
|
+
claude:
|
|
27
|
+
bin: claude
|
|
28
|
+
flags:
|
|
29
|
+
- "-p"
|
|
30
|
+
# Isolated from the user's own settings, CLAUDE.md, hooks, plugins, and MCP
|
|
31
|
+
# servers, so results do not depend on whose machine runs them. The login
|
|
32
|
+
# is kept; the deadline hook below comes in through --settings.
|
|
33
|
+
- "--setting-sources"
|
|
34
|
+
- ""
|
|
35
|
+
- "--strict-mcp-config"
|
|
36
|
+
# The event stream, reduced to the agent's text by fomtools, so a round
|
|
37
|
+
# ended at its timeout keeps the notes written so far.
|
|
38
|
+
- "--output-format"
|
|
39
|
+
- "stream-json"
|
|
40
|
+
- "--verbose"
|
|
41
|
+
- "--permission-mode"
|
|
42
|
+
- "bypassPermissions"
|
|
43
|
+
- "--allowedTools"
|
|
44
|
+
- "Read,Write,Edit,Bash,Glob,Grep"
|
|
45
|
+
- "--settings"
|
|
46
|
+
- '{"env":{"CLAUDE_CODE_DISABLE_BACKGROUND_TASKS":"1"},"hooks":{"PreToolUse":[{"matcher":"*","hooks":[{"type":"command","command":"[ -z \"$FOMTOOLS_DEADLINE\" ] || [ \"$(date +%s)\" -lt \"$FOMTOOLS_DEADLINE\" ] || { echo \"fomtools: the time budget is spent. Stop editing and print your summary now.\" >&2; exit 2; }"}]}]}}'
|
|
47
|
+
cwd_flag: --add-dir
|
|
48
|
+
sysprompt_flag: --append-system-prompt
|
|
49
|
+
output_format: stream-json
|
|
50
|
+
auth_markers: ["authentication_error", "invalid x-api-key", "please run /login", "claude login"]
|
|
51
|
+
display_name: Claude Code
|
|
52
|
+
auth_hint: Run `claude` once and log in.
|
|
53
|
+
install_hint: Install Claude Code (https://claude.com/claude-code) and ensure `claude` is on PATH.
|
|
54
|
+
|
|
55
|
+
# OpenAI Codex CLI (https://github.com/openai/codex): `codex exec` in the
|
|
56
|
+
# output dir (not a git repo), with approvals and the sandbox bypassed since
|
|
57
|
+
# the dir is isolated. The time budget is the process timeout.
|
|
58
|
+
codex:
|
|
59
|
+
bin: codex
|
|
60
|
+
base_args: ["exec"]
|
|
61
|
+
# Isolated from the user's ~/.codex/config.toml (hooks, MCP servers, profiles,
|
|
62
|
+
# a pinned model) and execpolicy rules; no session files. The login is kept.
|
|
63
|
+
# Codex still reads ~/.codex/AGENTS.md; no flag turns that off.
|
|
64
|
+
flags:
|
|
65
|
+
- "--skip-git-repo-check"
|
|
66
|
+
- "--dangerously-bypass-approvals-and-sandbox"
|
|
67
|
+
- "--ignore-user-config"
|
|
68
|
+
- "--ignore-rules"
|
|
69
|
+
- "--ephemeral"
|
|
70
|
+
cwd_flag: --cd
|
|
71
|
+
display_name: Codex
|
|
72
|
+
auth_hint: Run `codex login`.
|
|
73
|
+
install_hint: Install the Codex CLI (https://github.com/openai/codex) and ensure `codex` is on PATH.
|
|
74
|
+
|
|
75
|
+
# Pi (https://pi.dev): one-shot print mode, trusting the files in the output
|
|
76
|
+
# dir. Pi is multi-provider and uses its own login or provider keys. The time
|
|
77
|
+
# budget is the process timeout.
|
|
78
|
+
pi:
|
|
79
|
+
bin: pi
|
|
80
|
+
flags: ["--print", "--approve"]
|
|
81
|
+
display_name: Pi
|
|
82
|
+
auth_hint: Run `pi` and use /login.
|
|
83
|
+
install_hint: Install Pi (https://pi.dev) and ensure `pi` is on PATH.
|
|
84
|
+
|
|
85
|
+
# Cursor CLI agent (https://cursor.com/docs/cli). Drives `cursor-agent` in
|
|
86
|
+
# non-interactive mode, looping internally on the workspace until it stops.
|
|
87
|
+
cursor:
|
|
88
|
+
bin: cursor-agent
|
|
89
|
+
# --print: non-interactive (print to stdout instead of launching the TUI).
|
|
90
|
+
# --force: auto-approve file edits / shell commands (alias: --yolo).
|
|
91
|
+
flags: ["--print", "--force"]
|
|
92
|
+
# The prompt is passed POSITIONALLY (`cursor-agent ... "<prompt>"`), so do
|
|
93
|
+
# not set `prompt_arg`. cursor-agent has no system-prompt flag, so the shared
|
|
94
|
+
# SYSTEM_PROMPT is automatically prepended to the task prompt.
|
|
95
|
+
model_flag: --model # e.g. --agent cursor with model "sonnet-4.5"
|
|
96
|
+
display_name: Cursor
|
|
97
|
+
auth_hint: Run `cursor-agent login`.
|
|
98
|
+
install_hint: Install the Cursor CLI (https://cursor.com/docs/cli) and ensure `cursor-agent` is on PATH.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""Wall-clock budget for one agent phase.
|
|
2
|
+
|
|
3
|
+
`run_verify_loop` starts a `TimeBudget` for each phase and publishes it to the
|
|
4
|
+
driver as ``task.extra["budget"]``. `CliAgentDriver` gives every attempt what is
|
|
5
|
+
left of it as a hard process timeout, and tells the agent the deadline through
|
|
6
|
+
the ``FOMTOOLS_DEADLINE`` environment variable (Unix time), a grace period
|
|
7
|
+
(``GRACE_S``, or a fifth of a shorter budget) before that timeout. An agent CLI with tool hooks can then stop and write its
|
|
8
|
+
summary in time; the bundled ``claude`` spec does this with a ``PreToolUse``
|
|
9
|
+
hook.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import time
|
|
15
|
+
from collections.abc import Callable
|
|
16
|
+
from dataclasses import dataclass
|
|
17
|
+
|
|
18
|
+
#: Time the agent gets after ``FOMTOOLS_DEADLINE`` to write its summary before the
|
|
19
|
+
#: process is ended (at most a fifth of the budget).
|
|
20
|
+
GRACE_S = 60.0
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@dataclass
|
|
24
|
+
class TimeBudget:
|
|
25
|
+
"""A wall-clock budget of ``total_s`` seconds ending at ``deadline`` (``clock`` time)."""
|
|
26
|
+
|
|
27
|
+
deadline: float
|
|
28
|
+
total_s: float
|
|
29
|
+
clock: Callable[[], float] = time.monotonic
|
|
30
|
+
|
|
31
|
+
@classmethod
|
|
32
|
+
def starting_now(
|
|
33
|
+
cls, total_s: float, clock: Callable[[], float] = time.monotonic
|
|
34
|
+
) -> TimeBudget:
|
|
35
|
+
return cls(deadline=clock() + total_s, total_s=total_s, clock=clock)
|
|
36
|
+
|
|
37
|
+
def remaining(self) -> float:
|
|
38
|
+
return self.deadline - self.clock()
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def grace_s(self) -> float:
|
|
42
|
+
"""The summary-writing time at the end: ``GRACE_S``, or a fifth of a short budget."""
|
|
43
|
+
return min(GRACE_S, 0.2 * self.total_s)
|
|
44
|
+
|
|
45
|
+
def agent_deadline(self) -> int:
|
|
46
|
+
"""The Unix time at which the agent should stop: ``grace_s`` before the end."""
|
|
47
|
+
return int(time.time() + max(0.0, self.remaining() - self.grace_s))
|