Update v1 templates for PyRel PR #730 API changes#28
Conversation
cafzal
left a comment
There was a problem hiding this comment.
looks good, thanks. we should wait to merge until the new release and update minimum version guidance
|
new release is v1.0.6 and was released today |
|
The The workflow checks out The |
|
@chriscoey I'm looking in to the credentials issue |
|
The docs preview for this pull request has been deployed to Vercel!
|
somacdivad
left a comment
There was a problem hiding this comment.
Thanks for the updates @chriscoey. I got the preview working again and everything passes there. My one concern is that the README files may need to be updated so that any code changes made here are reflected in any code shown in the READMEs.
Early feedback I got about templates indicated that people want to see some code on the website, but I'm thinking about removing raw code blocks from the READMEs because of the maintenance annoyance.
I haven't settled on a solution yet, though, so I think that for now we just need to keep the README's in sync. There's a prompt in .github/prompts that I've used in the past to easily sync READMEs with an agent.
I'll work on a solution for showing code on the website without having to keep anything in sync so future updates are easier.
Migrate all 22 prescriptive templates to the new result accessor API: - p.display_solve_info() → p.solve_info().display() - p.termination_status/p.objective_value properties → p.termination_status()/p.objective_value() Relationships - Add model.require(p.termination_status() == "OPTIMAL") engine-side ICs to 18 templates - Add structural ICs (num_variables, num_objectives) to network_flow and traveling_salesman - Add p.verify() constraint checking to shift_assignment (MiniZinc) - Replace display-only .to_df()+print with .inspect() in 7 templates - Guard loop-based scenario templates against None objective_value - Fix pre-existing NameError in grid_interconnection (build_formulation) Tested: 20/21 templates pass locally (demand_planning_temporal has pre-existing type issue). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update code snippet to match the {Type:name} syntax used in the .py file.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f4361ed to
bc76267
Compare
|
Rebased onto main (picking up PR #29's scenario restructuring), resolved conflicts in grid_interconnection, demand_planning_temporal, and sprint_scheduling. All 22 templates (21 HiGHS + 1 MiniZinc) run successfully against PyRel v1.0.6 after the rebase. |
Update code blocks and expected output in 4 template READMEs to reflect the solve_info() API migration and scenario restructuring: - grid_interconnection: scenario loop → single solve with scenario-indexed variables; all code blocks updated - demand_planning_temporal: scenario loop added for planning_end sweep; date filtering/period mapping sections updated - sprint_scheduling: capacity_multiplier scenario loop added; named constraint variables; expected output updated - shift_assignment: constraints extracted to named variables (coverage_ic, workload_ic); p.verify() documented The remaining 15 templates' READMEs don't show any code that was changed (solve_info, .inspect patterns), so no update is needed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sections 3-5 referenced `s.solve_for()`, `s.satisfy()`, `s.minimize()` but the code uses `p = Problem(...)`. Fixed to match. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- sprint_scheduling: fix scenario order (0.5, 0.75, 1.0 not reversed) - machine_maintenance: fix s. → p. in solve/verify code block - shift_assignment: fix s.solve/minimize refs in prose, add solve+verify code block, update infeasibility docs for single-solve approach - demand_planning: fix expected output format (status/cost on separate lines), add planning_end= prefix to summary - grid_interconnection: add explanatory prose to step 5 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codex found s.solve_for() and s.minimize() in sections 3-4 that were not covered by the earlier fix. All code blocks now use p. to match the actual code. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- sprint_scheduling: start_epoch was computed but unused — now used in filter so planning_start actually narrows the backlog - shift_assignment: Shift.capacity loaded from CSV but never used in any constraint — removed dead property to avoid confusion - demand_planning: add comment that SCENARIO_VALUES must be in increasing date order (data accumulates across iterations); clarify safety_stock_weeks is an extension point, not wired in Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- shift_assignment: restore Shift.capacity and add capacity_ic constraint (max workers per shift from CSV). The property was loaded since the template was created but never enforced. - demand_planning: wire safety_stock_weeks into a constraint requiring inventory >= avg_weekly_demand × safety_stock_weeks per site-SKU pair per week. Previously defined but unused. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- shifts.csv: increase capacity to 4/5/4 so all scenarios (including coverage_3) are feasible with the new capacity constraint - shift_assignment README: add capacity troubleshooting bullet - demand_planning README: add safety_stock_weeks to INFEASIBLE hint Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Capacity should actually constrain the solution: 3 on Morning/Night means the constraint binds at coverage_3 (exactly 3 assigned). 4 on Afternoon allows slight headroom. Previous 4/5/4 was too loose to demonstrate the constraint's effect. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The sprint_scheduling code and README described pre-planning_start issues as "backlog items eligible from Sprint 1" — but the start_epoch filter now excludes them. Updated both. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
All .py files use p = Problem(model, ...) but 16 READMEs still showed s.solve_for(), s.satisfy(), s.minimize(), etc. in code blocks. Renamed all to p. for consistency. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Change SCENARIO_VALUES from [0.5, 0.75, 1.0] to [0.35, 0.5, 1.0]. At 0.35x capacity the problem is INFEASIBLE (per-developer limits too tight for 139 story points), demonstrating the scenario sweep's value in finding the breaking point. The code correctly handles infeasibility: prints status, skips results, shows N/A in summary. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@somacdivad Good call on the README sync — synced all code blocks across all 21 template READMEs. What was done:
All 21 modified templates verified passing against PyRel v1 on latest. Re: your longer-term plan for showing code on the website without maintenance burden — happy to help when you have a direction. |
somacdivad
left a comment
There was a problem hiding this comment.
Thanks @chriscoey. Looks great!
Resolve conflict in network_flow.py: keep `count` import (used by model.require IC on line 70). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- production_planning: rewrite section 2 to describe Scenario-concept single-solve pattern (was incorrectly describing a loop pattern) - supplier_reliability: fix s → p variable name in README snippet - sprint_scheduling: fix scenario values 0.25 → 0.35 to match code Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
model.require()ICs for solve status validation — avoids querying data to the clientp.verify()constraint checking pattern to shift_assignment{{name:float}}→{Float:name}Property syntaxAPI migration (all 22 templates)
p.display_solve_info()p.solve_info().display()p.termination_status(property)p.termination_status()(Relationship)p.objective_value(property)p.objective_value()(Relationship){{name:float}}Property shorthand{Float:name}PyRel type syntaxPattern diversity across templates
.inspect())solve_info()(termination IC + Python-side formatted output)solve_info()+.inspect()(single solve)p.verify()(post-solve constraint checking)solve_info()in scenario loops (need Python scalars per iteration)Additional changes
Noneobjective_value on non-OPTIMAL solves.to_df()+ print replaced with.inspect()in 7 templatesTest plan
py_compile)azure-latest🤖 Generated with Claude Code