Skip to content

Stage 3 MILP objective and plan_cost disagree, so tie-breaking changes reported cost #1566

Backlog

Description

@zzylol

Problem, by example

Planning the paper n100 workload twice, once before and once after #1564 (Stage 3 solves independent MILP blocks separately), gives two plans with the same MILP objective but different reported plan cost.

Command (same for both binaries; measured today on the local machine, binaries built from the base and head of #1564):

asap_planner --workload paper.n100.promql.json --workload paper.n100.sql.json \
  --sql-catalog-table <http> --sql-catalog-table <flows> \
  --run-until stage3 --format text --verbose
before #1564 (b9c7fdf) after #1564 (70830b0)
selection MILP: objective 6.732615e5/s 6.732615e5/s
cost_per_second (plan_cost of the selected plan) 6.528505e5 6.732607e5
solve time 24.2 s 9.7 s

Expected: for any optimal selection, the reported plan_cost equals the MILP objective (up to float rounding), so that which optimal selection HiGHS returns cannot change the reported cost.

Not measured here: which cost terms account for the 3% (the verbose output prints per-node costs, but this issue does not attribute the difference to specific terms). Finding them is the first step of the fix.

Why it happens

Stage 3 selects a plan by minimizing the MILP objective, then computes plan_cost separately from the selected nodes. The two are meant to be the same quantity (a debug assert in lib.rs compares them), but for some cost terms the MILP charges something different from what plan_cost charges for the same selection. For plans where the terms agree, tie-breaking cannot matter; for the n100 tie, one optimal selection has a 3% lower plan_cost than another, so the MILP treats as equal two plans that plan_cost does not.

#1564 changed which optimal selection is returned: each independent block is solved as its own HiGHS problem, so the search path (and so the tie-break) differs from the single whole-model solve. The change is correct, since the optimum is the same, and it was accepted as is. It only exposed the gap. The review of #1564 noted this: plans with equal-cost ties may differ from earlier plans at the same cost.

The same gap is already visible elsewhere: eval workloads that declare a service Zipf skew show the Stage 3 objective and plan_cost differing by about 3e-6 relative.

Proposal

Preferred: make the objective equal plan_cost for every term, so the MILP is minimizing exactly the reported number. Find the terms where the MILP coefficient differs from the plan_cost computation for the same selected node (compare the per-node cost breakdown of the two n100 selections), and make both use one definition.

Alternative, if some term cannot be linearized exactly: break ties by plan_cost, for example a second solve with the objective fixed at its optimum and plan_cost minimized, or a tiny secondary objective term. This is a fallback, since it hides the gap instead of removing it.

Scope and acceptance

In scope: the Stage 3 MILP objective and the plan_cost computation. Out of scope: solve speed, block splitting, HiGHS settings.

Done when:

Status and related work

Activity

  1. added
    bug
    cost-model
    optimizer
    on Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcost-modeloptimizer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions