Repository navigation
Conversation
The capacity constraint bound the upgrade and approval variables in its where clause, outside its sums over the substation's upgrades and requests. For each substation and investment level it therefore compared the sum of the upgrade variables times the sum of the upgrade capacities with the sum of the approval variables times the sum of the requested MW. Each upgrade's capacity and each request's MW is now weighted by its own variable. Listing InvestmentLevel in the objective's sum makes it say what the solver already computes, one term per request and level. The optimum moves from 1,579,200,000 to 1,562,600,000. The knee stays at $300M, now with 6 data centers, 1,530 MW and $252M net value: Google Metroplex and Lambda Labs at Dallas-Fort Worth are approved from $300M, and xAI Colossus at no budget. The README and runbook state the new results.
|
The templates docs preview for this pull request has been deployed to Vercel!
|
relationalai 2.x refuses sum(model.union(...)) objectives: a union keeps one copy of equal values while the solver adds every term. The objective now adds the production, holding and unmet-demand totals, each summed over its own rows, with a zero default on the unmet total, which is empty when no order falls in the horizon. The unmet-demand bound duplicated the variable's own upper bound and is removed.
relationalai 2.x refuses an aggregate over model.union, since the union keeps one copy of equal values while the solver takes every arm's members. The objective now adds sum(Lane, ...) and sum(Site, ...), each naming the concept whose members it totals, and the README describes the objective that way.
relationalai 2.x renamed deployment.schema to deployment.public_schema and requires deployment.identity.internal_schema. The local DuckDB config sets both (main and main_internal); README and runbook describe the three settings.
…ium from the model RiskTier_Standard now excludes RiskTier_Preferred in its own rule, so the four tier concepts partition InsuredEntity as the README says, instead of the report subtracting Preferred after the query. The premium-by-tier rollup reads Policy.total_premium from the model and merges it on the entity id, rather than looking each id up in the policies CSV.
relationalai 2.x refuses a sum that does not identify each member, since PyRel counts equal members once while the solver counts one per row, and refuses an aggregate over model.union. Each constraint and cost sum now names its keys, the objective adds its four cost terms, and the two LTL cost terms are each one sum over (segment, period). The segment refs are defined once and reused.
READMEs and runbooks named each template's previous pin (1.0.14 through 1.27.1). Requirement and install lines now state 2.1.1, the version every pyproject.toml pins. Notes giving the release a feature first appeared in keep that minimum.
…ls read The rule cells read User.has_address, has_credit_card, has_phone and has_email, and the model text describes CreditCard, Phone and Email concepts, but the model cell declared only flat properties. The notebook now declares those concepts (identified by their value, so users sharing a card, phone or email link to the same node) and relationships, loads them with User.new, and assigns each user's weakly connected component through a rule, since the component of the full graph spans every node type.
relationalai 2.x refuses an aggregate over model.union: the union keeps one copy of equal values, while the solver takes every arm's members. Both objectives now add their separately summed cost terms. None of the terms can be empty for these templates, so none takes a default. The network_flow_planning README explains the two sums instead of the union.
The graph was built without a node concept, so Graph generated its own Node concept and the edge query read Station's id from nodes that have none. Graph(..., node_concept=Station) makes Station the graph's Node. The notebook also creates its source table with change tracking on, which the model needs to read it, uses Station.lookup for the edge endpoints, and drops a stray copy of the centrality introduction that sat before the setup cells.
relationalai 2.x refuses a sum that does not identify each member, since PyRel counts equal members once while the solver counts one per row. The revenue, salvage and cost sums name their keys in both scripts.
…roups relationalai 2.x replaces all_paths() and PathTraversal with path patterns that name their endpoints: the candidate rule uses the walk pattern's .exists() and the walk count its .all().count(). Each per-user constraint names its group keys in its where clause, which 2.x requires for a constraint with one instance per group. The problem has the same variables, constraints and objective as before.
…rollup The rollup summed one row per policy, so an entity with several policies would be counted once per policy. It now sums Policy.total_premium per InsuredEntity in the model, keeping one row per entity. The bundled data has one policy per entity, so the report is unchanged.
relationalai 2.1.1 deprecates path(...).all_paths() and warns on every call. bom-reachability, cybersecurity-attack-paths, energy_grid_planning, it-dependency-mapping, memory_supply_allocation and telco_network_recovery now write .all().paths(), which returns the same paths, and their READMEs and runbooks name it. Results are unchanged.
…t upgrades The capacity constraint holds for every substation with a request. At a substation with no upgrade options its upgrade sum has no value, which makes the constraint, and so every investment level, infeasible. The upgrade sum now defaults to 0.0. The bundled data has upgrades at every requested substation, so results are unchanged (1,562,600,000); with a request added at a substation without upgrades the plan is feasible. The README notes that revenue is the objective, so where several upgrade sets earn the same revenue the reported net value depends on the set the solver returns.
The already-read exclusion is explained where it is defined; the candidate rule now points to it.
The risk surcharge sums flow from watch-level suppliers only. With thresholds that flag no supplier, a case the README describes, the sum is empty and 2.1.1 leaves the objective without a value. Default the term to zero, as the union objective did by dropping it. Also point the memory_supply_allocation runbook at the path module's README under its current name.
rai-agent-scaffold is built on the Cortex agent (relationalai.agent), which relationalai 2.0 removed, so its pin and README stay at 1.0.14. sample-template passed use_lqp=False to Model, an argument 2.1.1's Model no longer takes.
There was a problem hiding this comment.
🟡 Changes recommended
The objective becomes undefined for networks with no positive-fixed-cost sites because the empty fixed-cost sum is not defaulted to 0.0.
1 open issue
What changed in this PR
Migrates 53 of 54 templates to RelationalAI 2.1.1 as a foundation for the later deploy-mode migration. The agent scaffold remains on 1.x because its Cortex agent API was removed in 2.0.
Changes:
- Updates dependency pins and corresponding README and runbook guidance.
- Adapts aggregates, path queries, model construction, and local deployment configuration for 2.1.1.
- Repairs two notebooks and underwriting reporting, and incorporates #108’s energy-grid capacity fix with updated results.
| File | Description |
|---|---|
| wildlife-conservation-network/README.md | Documents SDK 2.1.1. |
| wildlife-conservation-network/pyproject.toml | Pins SDK 2.1.1. |
| water_allocation/README.md | Documents SDK 2.1.1. |
| water_allocation/pyproject.toml | Pins SDK 2.1.1. |
| warehouse_allocation/README.md | Documents SDK 2.1.1. |
| warehouse_allocation/pyproject.toml | Pins SDK 2.1.1. |
| underwriting_audit/README.md | Documents SDK 2.1.1. |
| underwriting_audit/pyproject.toml | Pins SDK 2.1.1. |
| traveling_salesman/README.md | Documents SDK 2.1.1. |
| traveling_salesman/pyproject.toml | Pins SDK 2.1.1. |
| transaction_screening_local/transaction_screening_local.py | Updates DuckDB deployment schema configuration. |
| transaction_screening_local/runbook.md | Updates version and deployment guidance. |
| transaction_screening_local/README.md | Explains updated local deployment configuration. |
| transaction_screening_local/pyproject.toml | Pins SDK 2.1.1. |
| test_data_generation/pyproject.toml | Pins SDK 2.1.1. |
| telco_network_recovery/telco_network_recovery.py | Migrates path enumeration calls. |
| telco_network_recovery/README.md | Documents SDK 2.1.1. |
| telco_network_recovery/pyproject.toml | Pins SDK 2.1.1 with GNN support. |
| synthetic_order_lifecycle/README.md | Updates version and reinstall guidance. |
| synthetic_order_lifecycle/pyproject.toml | Pins SDK 2.1.1. |
| synthetic_eligibility_records/pyproject.toml | Pins SDK 2.1.1. |
| supply_chain_transport/supply_chain_transport.py | Adds aggregate keys and separate cost sums. |
| supply_chain_transport/README.md | Documents SDK 2.1.1. |
| supply_chain_transport/pyproject.toml | Pins SDK 2.1.1. |
| supply_chain_resilience/supply_chain_resilience.py | Adds cost totals with an empty-risk fallback. |
| supply_chain_resilience/README.md | Documents SDK 2.1.1. |
| supply_chain_resilience/pyproject.toml | Pins SDK 2.1.1. |
| supplier_reliability/README.md | Documents SDK 2.1.1. |
| supplier_reliability/pyproject.toml | Pins SDK 2.1.1. |
| subscriber_retention/README.md | Documents SDK 2.1.1. |
| subscriber_retention/pyproject.toml | Pins SDK 2.1.1 with GNN support. |
| sprint_scheduling/README.md | Documents SDK 2.1.1. |
| sprint_scheduling/pyproject.toml | Pins SDK 2.1.1. |
| smoker_status_prediction/README.md | Documents SDK 2.1.1. |
| smoker_status_prediction/pyproject.toml | Pins SDK 2.1.1 with GNN support. |
| simple-start/simple-start.ipynb | Fixes graph typing, lookups, and change tracking. |
| simple-start/README.md | Clarifies station-node graph construction. |
| simple-start/pyproject.toml | Pins SDK 2.1.1. |
| shipment_compliance/README.md | Documents SDK 2.1.1. |
| shipment_compliance/pyproject.toml | Pins SDK 2.1.1. |
| shift_assignment/README.md | Documents SDK 2.1.1. |
| shift_assignment/pyproject.toml | Pins SDK 2.1.1. |
| sample-template/pyproject.toml | Pins SDK 2.1.1. |
| sample-template/model/schema.py | Removes the unsupported model argument. |
| retail_planning/retail_planning.py | Names members of objective aggregates. |
| retail_planning/retail_planning_local.py | Applies matching aggregate-key changes locally. |
| retail_planning/README.md | Documents SDK 2.1.1. |
| retail_planning/pyproject.toml | Pins SDK 2.1.1 with GNN support. |
| retail_markdown/pyproject.toml | Pins SDK 2.1.1. |
| production_planning/pyproject.toml | Pins SDK 2.1.1. |
| product_configurator/README.md | Documents SDK 2.1.1. |
| product_configurator/pyproject.toml | Pins SDK 2.1.1. |
| portfolio_balancing/README.md | Documents the updated SDK pin. |
| portfolio_balancing/pyproject.toml | Pins SDK 2.1.1. |
| pod_placement/README.md | Updates version and troubleshooting guidance. |
| pod_placement/pyproject.toml | Pins SDK 2.1.1. |
| planogram_optimization/README.md | Updates version and reinstall guidance. |
| planogram_optimization/pyproject.toml | Pins SDK 2.1.1. |
| patient_cohort_recruitment/README.md | Documents SDK 2.1.1. |
| patient_cohort_recruitment/pyproject.toml | Pins SDK 2.1.1. |
| network_flow_planning/README.md | Explains separately summed objective costs. |
| network_flow_planning/pyproject.toml | Pins SDK 2.1.1. |
| network_flow_planning/network_flow_planning.py | Replaces the union aggregate with separate sums. |
| money_laundering_motif_detection/pyproject.toml | Pins SDK 2.1.1. |
| memory_supply_allocation/runbook.md | Updates path API examples and reference path. |
| memory_supply_allocation/README.md | Updates SDK and path-enumeration guidance. |
| memory_supply_allocation/pyproject.toml | Pins SDK 2.1.1 with GNN support. |
| memory_supply_allocation/memory_supply_allocation.py | Migrates dependency-path enumeration. |
| it-dependency-mapping/runbook.md | Updates path-enumeration examples. |
| it-dependency-mapping/README.md | Updates SDK and path API guidance. |
| it-dependency-mapping/pyproject.toml | Pins SDK 2.1.1. |
| it-dependency-mapping/it_dependency_mapping.py | Migrates downstream-path enumeration. |
| humanitarian-aid-supply-chain/README.md | Documents SDK 2.1.1. |
| humanitarian-aid-supply-chain/pyproject.toml | Pins SDK 2.1.1. |
| hospital_staffing/README.md | Documents SDK 2.1.1. |
| hospital_staffing/pyproject.toml | Pins SDK 2.1.1. |
| fraud-detection/README.md | Documents the updated SDK pin. |
| fraud-detection/pyproject.toml | Pins SDK 2.1.1 with GNN support. |
| fraud-detection/fraud_detection_rules.ipynb | Repairs entity relationships and component assignment. |
| financial_index_replication/README.md | Documents the updated SDK pin. |
| financial_index_replication/pyproject.toml | Pins SDK 2.1.1. |
| factory_production/README.md | Documents SDK 2.1.1. |
| factory_production/pyproject.toml | Pins SDK 2.1.1. |
| entity_resolution/README.md | Documents the updated SDK pin. |
| entity_resolution/pyproject.toml | Pins SDK 2.1.1. |
| energy_grid_planning/runbook.md | Updates frontier results after the capacity fix. |
| energy_grid_planning/README.md | Updates results, allocation explanations, and SDK guidance. |
| energy_grid_planning/pyproject.toml | Pins SDK 2.1.1 with GNN support. |
| energy_grid_planning/energy_grid_planning.py | Fixes capacity weighting and migrates path calls. |
| disease-outbreak-prevention/README.md | Updates SDK and reproducibility guidance. |
| disease-outbreak-prevention/pyproject.toml | Pins SDK 2.1.1. |
| diet/pyproject.toml | Pins SDK 2.1.1. |
| demand_planning_temporal/README.md | Documents separately summed objective costs. |
| demand_planning_temporal/pyproject.toml | Pins SDK 2.1.1. |
| demand_planning_temporal/demand_planning_temporal.py | Revises cost sums and removes a redundant constraint. |
| demand_forecasting/README.md | Documents SDK 2.1.1. |
| demand_forecasting/pyproject.toml | Pins SDK 2.1.1 with GNN support. |
| defect_root_cause/pyproject.toml | Pins SDK 2.1.1. |
| datacenter_compute_allocation/pyproject.toml | Pins SDK 2.1.1 with GNN support. |
| cybersecurity-attack-paths/README.md | Documents SDK 2.1.1. |
| cybersecurity-attack-paths/pyproject.toml | Pins SDK 2.1.1. |
| cybersecurity-attack-paths/cybersecurity_attack_paths.py | Migrates attack-path and route enumeration. |
| commercial_underwriting/README.md | Documents SDK 2.1.1. |
| commercial_underwriting/pyproject.toml | Pins SDK 2.1.1. |
| commercial_underwriting/commercial_underwriting.py | Partitions tiers and sums premiums per entity. |
| cicd_runner_allocation/README.md | Updates SDK and reproducibility guidance. |
| cicd_runner_allocation/pyproject.toml | Pins SDK 2.1.1. |
| cell_tower_coverage/README.md | Documents SDK 2.1.1. |
| cell_tower_coverage/pyproject.toml | Pins SDK 2.1.1. |
| campaign_roi/README.md | Documents SDK 2.1.1. |
| campaign_roi/pyproject.toml | Pins SDK 2.1.1. |
| book_slate_recommendation/README.md | Explains path existence and walk counting. |
| book_slate_recommendation/pyproject.toml | Pins SDK 2.1.1. |
| book_slate_recommendation/book_slate_recommendation.py | Migrates path queries and names constraint groups. |
| bom-reachability/runbook.md | Updates assembly-path enumeration examples. |
| bom-reachability/README.md | Updates path-depth guidance for the new API. |
| bom-reachability/pyproject.toml | Pins SDK 2.1.1. |
| bom-reachability/bom_reachability.py | Migrates assembly-path enumeration. |
| ad_spend_allocation/README.md | Documents SDK 2.1.1. |
| ad_spend_allocation/pyproject.toml | Pins SDK 2.1.1. |
Review effort: Balanced
Site.x_open exists only for sites with a positive fixed cost, so with none the fixed-cost sum is empty and the objective has no value. Default that sum to 0.0.
Centrality scores exclude stores and offices, so in a network whose operations all deliver to them the centrality sum is empty and the objective has no value. Default that sum to 0.0.
There was a problem hiding this comment.
🔵 Needs a closer look
The major SDK migration still requires maintainer runtime validation of retail_planning.py with full H&M tables and a GPU, plus datacenter_compute_allocation with its configured Gurobi solver.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
The comment and README name HiGHS as the default solver, but SOLVER was set to "gurobi", which fails on an engine without a Gurobi licence.
A populated cell was labelled OPTIMAL whatever the termination status, so a HiGHS run that stopped at its time limit reported "16 optimal" and persisted AllocationPlan.status OPTIMAL. Cells are now OPTIMAL or INFEASIBLE when the solve proved optimality, and FEASIBLE or UNSOLVED when it did not. The README shows the HiGHS output.
HiGHS proves the basket optimal in 204-218 s on relationalai 2.1.1 and at the previous pin, close to the 240 s limit, so a slower solver run would stop at the limit with an unproven basket.
The template writes this file on every run; it was committed by mistake.
…ring and runbook The runbook gave only the Gurobi result; it now also gives the HiGHS default (16 FEASIBLE, 8 UNSOLVED at the 240 s limit). The README no longer says Gurobi labels the same cells, which no run has checked.
It is built on relationalai.agent, which relationalai 2.0 removed, so it cannot move to 2.1.1 with the other templates. A replacement can follow on the 2.x path, where a Cortex Agent uses a deployed model's semantic view as a tool.
There was a problem hiding this comment.
🔵 Needs a closer look
The SDK major-version migration leaves the full-table/GPU retail_planning.py entrypoint unvalidated, requiring a maintainer with the H&M tables and target Snowflake/GPU environment to confirm compatibility.
No open issues 🎉
Review effort: Balanced
rai-agent-scaffold was removed, so the repository root now holds 52 template directories.

Moves the templates from their current pins (0.13.3 through 1.27.1) to relationalai 2.1.1, fixing mainly what 2.1.1 refuses and two notebooks that were already broken at their pins. Results at the current pins and at 2.1.1 are compared below, and match except where noted. This is the base for moving the templates to deploy mode, which follows as a stacked PR.
Supersedes #108 (its energy_grid_planning fix is included here).
What changed
relationalai==2.1.1in everypyproject.tomland notebook install cell; READMEs and runbooks name 2.1.1model.union0.0.demand_boundconstraintwhere.model.path(...).exists(),.all().count()) replaceall_paths()/PathTraversal; per-user constraints name their groupall_paths(). The printed problem has the same variables and objective on both releases..all().paths()instead of.all_paths(), in code and docsall_paths().deployment.public_schemaandidentity.internal_schemaModel("Template")withoutuse_lqp=FalseModelhas nouse_lqpargument.RiskTier_Standardexcludes Preferred in its own rule; premiums are summed per insured entity in the modelsumover an integer column failed on 2.1.1. The tiers now partition entities in the model.SOLVER = "highs"; populated scenario cells are labelled FEASIBLE unless the solve proves optimality"gurobi"fails on an engine without a Gurobi licence. HiGHS stops at the 240 s limit, where the old labels called every populated cell OPTIMAL.relationalai.agent), which relationalai 2.0 removed. Removed with its author's agreement; a replacement can follow on 2.x, where a Cortex Agent uses a deployed model's semantic view as a tool.Graph(..., node_concept=Station); source table created with change tracking onhas_*relationships the rule cells readResults
Pinned release vs 2.1.1.
Entry scripts and notebooks (59)
datacenter_compute_allocation/datacenter_compute_allocation.pydemand_planning_temporal/demand_planning_temporal.pyenergy_grid_planning/energy_grid_planning.pyfinancial_index_replication/financial_index_replication.pyhospital_staffing/hospital_staffing.pymemory_supply_allocation/memory_supply_allocation.pyportfolio_balancing/portfolio_balancing.pytelco_network_recovery/telco_network_recovery.pyad_spend_allocation/ad_spend_allocation.pybom-reachability/bom_reachability.pybook_slate_recommendation/book_slate_recommendation.pycampaign_roi/campaign_roi.pycell_tower_coverage/cell_tower_coverage.pycicd_runner_allocation/cicd_runner_allocation.pycommercial_underwriting/commercial_underwriting.pycybersecurity-attack-paths/cybersecurity_attack_paths.pydefect_root_cause/defect_root_cause.pydemand_forecasting/demand_forecasting.pydiet/diet.pydisease-outbreak-prevention/disease_outbreak_prevention_network.pyentity_resolution/entity_resolution.pyfactory_production/factory_production.pyfraud-detection/fraud_detection_local.pyfraud-detection/fraud_detection_rules.ipynbfraud-detection/fraud_detection.pyhumanitarian-aid-supply-chain/humanitarian_aid_supply_chain.pyit-dependency-mapping/it_dependency_mapping.pymoney_laundering_motif_detection/motif_butterfly.pymoney_laundering_motif_detection/motif_kyc_burst.pymoney_laundering_motif_detection/motif_smurf_army.pynetwork_flow_planning/network_flow_planning.pypatient_cohort_recruitment/patient_cohort_recruitment.pyplanogram_optimization/planogram_optimization.pypod_placement/pod_placement.pyproduct_configurator/product_configurator.pyproduction_planning/production_planning.pyretail_markdown/retail_markdown.pyretail_planning/retail_planning_local.pyretail_planning/retail_planning.pyshift_assignment/shift_assignment.pyshipment_compliance/shipment_compliance.pysimple-start/simple-start.ipynbsmoker_status_prediction/smoker_status_prediction_local.pysmoker_status_prediction/smoker_status_prediction.pysprint_scheduling/sprint_scheduling.pysubscriber_retention/subscriber_retention.pysupplier_reliability/supplier_reliability.pysupply_chain_resilience/supply_chain_resilience.pysupply_chain_transport/supply_chain_transport.pysynthetic_eligibility_records/synthetic_eligibility_records.pysynthetic_order_lifecycle/synthetic_order_lifecycle.pytest_data_generation/test_data_generation.pytransaction_screening_local/transaction_screening_local.pytraveling_salesman/traveling_salesman.pyunderwriting_audit/underwriting_audit.pywarehouse_allocation/warehouse_allocation.pywater_allocation/water_allocation.pywildlife-conservation-network/wildlife_conservation_network.pysample-template/template.pyDifferences, and what I could not run
problem.display()and runs unchanged on 2.1.1. transaction_screening_local fails on a fresh install at its pin, which now resolves duckdb 2.0; with duckdb 1.5.6 it runs, and its output matches 2.1.1. sample-template fails on a fresh install at its pin (0.13.3) under Python 3.11 and 3.14.paysim_minisample, on CPU: both releases give the same results.