Skip to content

feat: hierarchical multi-structure auction with post-review fixes#2

Open
miciav wants to merge 31 commits into
mainfrom
feat/uv-migration-and-extended-tests
Open

feat: hierarchical multi-structure auction with post-review fixes#2
miciav wants to merge 31 commits into
mainfrom
feat/uv-migration-and-extended-tests

Conversation

@miciav
Copy link
Copy Markdown
Member

@miciav miciav commented May 19, 2026

Summary

  • Implements hierarchical multi-structure auction (Sections 4.5-4.7 of the coordination paper) as a standalone hierarchical_auction/ package registered in run.py as method hierarchical
  • Every accepted reservation maps to a concrete y[buyer_node, seller_node, function] flow; token conflict resolution is deferred and cumulative
  • Post-review fixes: structure price caching bug, real latency wired from graph, global feasibility invariant enforced at runtime, dead code removed, public exports expanded

Key changes

  • hierarchical_auction/ — new package: types, structure, structure_graph, token_manager, pricing, flow_mapper, engine, runner
  • run.pyhierarchical added to method choices
  • Fix: engine.pycompute_structure_price moved outside for f loop (removes fragile zero-sentinel caching)
  • Fix: runner.py — real latency extracted from graph via _extract_latency(graph), passed to both define_bids and run_higher_levels; latency_weight is now effective in production
  • Fix: engine.pyassert token_manager.check_global_feasibility() enforces Invariant 3 after each level loop
  • Cleanup: removed dead omega = result.omega assignment, bid_price field, expanded __init__.py exports

Test plan

  • uv run pytest tests/test_hierarchical_types.py tests/test_hierarchical_structure_graph.py tests/test_hierarchical_token_manager.py tests/test_hierarchical_pricing.py tests/test_hierarchical_flow_mapper.py tests/test_hierarchical_engine.py tests/test_hierarchical_runner.py tests/test_coverage_expansion.py -v — all 42 pass
  • uv run pytest --cov --cov-report=term-missing -q — 94 tests pass, 51% coverage
  • uv run ruff check . — zero errors
  • uv run mypy — zero errors

🤖 Generated with Claude Code

miciav and others added 30 commits February 16, 2026 16:03
All quality gates pass:
- 83 tests pass (18 hierarchical-specific)
- ruff: clean
- mypy: clean
- coverage: 51% (hierarchical_auction core: 87-96%)
…are after hierarchical levels

- engine: broadcast service_quantum per-function, skip seller==buyer,
  sort candidates by effective bid, compute quantity = min(want, tokens*quantum)
- runner: extract compute_offloaded_demand(), initialize rmp_omega,
  recompute compute_social_welfare after hierarchical allocations,
  pass rmp_omega to check_stopping_criteria
- token_manager: preserve quantity ratio on partial token acceptance
- tests: +5 tests for service quantum, no self-allocation, seller
  preference, offloaded demand, partial acceptance ratio
…unction

Removed the fragile zero-sentinel guard (`if np.allclose(structure_price, 0.0)`)
that prevented recomputation when the legitimate price is zero (eta=0, zero node
prices). The call to compute_structure_price is now made once per structure,
immediately before the inner per-function loop, making intent explicit and safe.
Added regression test for a two-function zero-price network.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… production

Add _extract_latency helper using nx_adjacency_matrix with network_latency weight,
call it once before the time loop, and pass the result to both define_bids and
run_higher_levels (replacing the previous np.zeros placeholders).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… call

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…blic exports

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ze loops, cache available tokens, move engine out of loop
…LI parsing

Brings coverage from 52% to 60% (+406 covered statements). Highlights:
- models/sp.py 44→86%, models/auction_models.py 45→84%
- generate_data.py 49→76%, run_centralized_model.py 37→63%
- what_if_analysis.py 33→53%, run_faasmacro.py 26→35%

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add config_files/planar_hierarchical.json for running the hierarchical
auction model on Sage-generated planar degree-3 graphs (Nn 10-50, 3
repetitions). Document the workflow and conda install requirement in README.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- fix: omega_bar and y_bar params use PYO_PARAM_TYPE (NonNegativeReals)
  instead of PYO_VAR_TYPE — solver outputs can be fractional
- fix: import PYO_PARAM_TYPE in models/sp.py
- fix: use nx. prefix for circular_ladder_graph and adjacency_matrix
  in generators/generate_data.py after merge removed explicit imports
- fix: add hierarchical termination condition format to postprocessing
  parser in run.py (missing obj. deviation / best it fields)
- fix: remove undefined title_key references in rlagents/postprocessing.py
- feat: add pre-commit ruff hook (pre-push stage)
- test: regression tests for omega_bar/y_bar float domain and missing import
- config: update planar_hierarchical.json load to sinusoidal trace type

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- hierarchical runner now saves runtime.csv with 'tot' column so that
  results_postprocessing can read it without falling back to FaaS-MACrO
  log parsing
- fix deviation append to handle None (not just the string "None") in
  load_termination_condition for hierarchical TC format

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace planar_hierarchical.json with planar_comparison.json covering
centralized, faas-macro, and hierarchical on planar degree-3 graphs.
Update README accordingly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
faas-macro now writes runtime.csv with a 'tot' column at the end of
each run, matching the format expected by results_postprocessing and
consistent with what was added to the hierarchical runner.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant