moonbit-auction

    Market mechanism design and auction simulation library in MoonBit

    auction
    mechanism-design
    simulation
    economics
    matching
    Download zip
    Author
    Version
    0.2.0
    License
    Apache-2.0
    Last updated
    2 months ago
    Downloads
    32

    No dependencies

    #moonbit-auction

    MoonBit CI License

    moonbit-auction is a strongly typed MoonBit toolkit for auction mechanism design, market clearing, matching, simulation, and welfare analysis. It is intended for reusable experiments and small production-oriented market components in procurement, cloud capacity, search advertising, and resource allocation.

    The library has no third-party runtime dependencies. All deterministic workloads, mechanism results, and analytics are implemented in MoonBit packages under src/.

    #Core capabilities

    • Single-item auctions: first-price, second-price/Vickrey, English, Dutch, all-pay, multi-round sealed, reserve pricing, and maximum-bid proxy auctions.
    • Multi-item markets: uniform-price and pay-as-bid multi-unit auctions, combinatorial WDP, clock auctions, batch double-sided clearing, quotas, and allocation plans.
    • Advertising auctions: VCG, GSP, quality-score ranking, and sponsored-search analytics.
    • Matching and agents: deferred acceptance, TTC/TTC with chains, capacitated matching, truthful/shaded/sniping agents, Q-learning, deterministic bandit policies, and budget pacing.
    • Operations and analysis: order validation, risk/compliance rules, portfolios, settlement batches, event replay, deterministic workloads, market observers, alerts, welfare/equity metrics, and regression comparisons.

    #Quick start

    Install a MoonBit stable toolchain with moonc >= 0.10.9, then run:

    moon check --deny-warn moon fmt --check moon test moon run src/main

    The executable is a dependency-free demonstration CLI. It runs the main mechanism examples and then prints reproducible benchmark records. It does not contact a service or publish data.

    #CLI and benchmark

    Run the demo and benchmark CLI with:

    moon run src/main

    The benchmark uses a deterministic generator with seed 20260824. It reports logical steps instead of wall-clock time, so the values are stable across local machines and CI runners. A fresh local run produced:

    CaseBidsAllocationsRevenueSurplusLogical stepsDigest length
    small324405.460829.764336626
    medium2568909.779916.64072645,099

    The accompanying dashboard reports 2 runs, average revenue 657.6204, average surplus 23.2025, and 12 allocations. These are outputs of the current checked-in implementation, not estimates.

    #Architecture

    pk9993/moonbit-auction ├── src/types domain types, validation, orders, portfolios, settlement, compliance ├── src/single_item classic and proxy single-item mechanisms plus auction sessions ├── src/multi_item multi-unit, combinatorial, clock, batch clearing, allocation policy ├── src/ad_auction VCG, GSP, and sponsored-search analytics ├── src/matching DA, TTC, capacitated matching, and matching diagnostics ├── src/strategy bidder agents, Q-learning, bandits, budgets, and risk metrics ├── src/simulation market engine, order book, workloads, replay, scenarios, observers ├── src/analytics welfare, statistics, benchmarks, equity, stability, and reporting └── src/main executable examples and deterministic benchmark CLI

    Each directory is a MoonBit package described by moon.pkg. Public APIs are exposed through typed records and enums; package files are split by responsibility rather than by one monolithic implementation file.

    #Tests and validation

    The repository currently contains 62 executable MoonBit tests. They cover payment rules, reserve and invalid-input behavior, empty schedules, capacity limits, duplicate and malformed orders, budget exhaustion, deterministic replay, statistical edge cases, settlement, equity, alerts, and reproducible benchmark output.

    The current source inventory is 8,170 MoonBit lines: 7,277 production lines and 893 test lines, counted from src/**/*.mbt without generated interface files.

    Recommended local validation:

    moon fmt --check moon info moon check --deny-warn moon test moon run src/main git diff --check

    moon info is included so public interface changes are visible during review. Test targets are kept package-local, while moon test exercises the full module.

    #CI

    GitHub Actions runs on pushes and pull requests to main. The workflow checks formatting, generated package interfaces, deny-warning type checking, all tests, and the executable smoke test. The stable toolchain is configured at the 0.10.9+ compatibility floor, and the benchmark workflow stores the deterministic CLI output as a build artifact.

    #License

    This project is available under the Apache License 2.0.