Repository navigation
Conversation
…hines - Engine split into grid → model → ports → engine → adapters → app layers, with policies (fifo, fifo_strict, sjf, best_fit, random), arrival sources (poisson, batch), usage generators (random, deeprm) and observers (viz, metrics, log), a spec-based CLI and an adapter registry. - Machine time is a sliding window: advancing a tick moves a head index and rows are compacted once every n_ticks ticks, instead of shifting every grid each tick (300 machines × 1000 ticks: ~415 ms → ~6 ms per episode, identical results). - C ABI (src/app/capi.zig, `zig build lib`) and the sched_env Python package: Gymnasium env with zero-copy NumPy views and action masks, stepping of built-in policies, a matplotlib visualizer, and a Stable-Baselines3 MaskablePPO training example. - Benchmarks (SIMD, engine, CPU-vs-GPU fit mask), integration and Python tests, and docs (guide, python, architecture, data layout). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- tests/scenario_test.zig: 18 hand-worked scenarios with exact expected placements, waits, makespan and reward (blocking, multi-machine, exact fit, time-varying profiles, per-resource limits, backfill vs strict FIFO, SJF, best_fit, illegal actions, action masks, admission and rejection reasons, truncation, skip_empty, reward kinds, reset). - Property test: 20 random episodes with random, sometimes illegal, actions checked at every step against a naive reference simulator (free capacity per tick, legality, reward, makespan); small horizon so the sliding window compacts often. - Wire the new test into `zig build test`; document test coverage in docs/guide.md and CLAUDE.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Policies: `tetris` (multi-resource alignment over the job's whole duration, Grandl et al. 2014) and `tetris_srpt` (alignment minus weight·ε·duration, the paper's SRPT combination; default weight 1.5). Policy specs now accept options: any numeric field of a policy struct, e.g. `--policy tetris_srpt:weight=2` (also from Python). - Arrivals: `mmpp` (two-state Markov-modulated Poisson, short-range bursts), `pareto` (heavy-tailed gaps) and `selfsimilar` (Pareto ON/OFF sources, long-range dependent, H = (3 − α)/2). Unit test checks mean rate, determinism and index of dispersion across window sizes. - Reward is now a port (`ports.Reward`, `engine.setReward`) receiving the waiting and running jobs; adapters `neg_in_system` (default), `neg_waiting`, `zero` and `slowdown` (DeepRM −Σ 1/T_j, optional bounded slowdown via min_dur). Running jobs are tracked as `RunningJob`. - CLI `--reward <spec>`, C API reward spec string, Python `reward=` takes the same specs. - Scenario tests for slowdown, Tetris vs best_fit, tetris_srpt weights; docs: policies, arrival burstiness and reward tables, trade-off results. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- `trace` observer (src/adapters/observers/trace.zig): writes every event plus each job's demand profile and the machine capacities as JSON Lines (`--observe trace:path=run.jsonl`), self-contained per episode. - C API `sim_trace_open/close`; Python `env.start_trace()/stop_trace()`. - Python `sched_env.replay.load_trace` rebuilds one frame per tick from a trace without the simulator; `python/examples/replay.py` lists episodes and animates them with the existing visualizer. - Tests: Zig test parses every line and checks event counts; Python test checks replayed frames and stats match a live run exactly. - Docs: recording/replay section, observer tables. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Sorry @dev0Guy, your pull request is larger than the review limit of 150,000 diff characters |
Runs on pushes to main/setup and on pull requests, on ubuntu-latest (x86-64, AVX2) and macos-latest (arm64, NEON) so both SIMD widths are covered: zig build test, the same tests with -Dlanes=32, a smoke run of every policy × arrival process with the trace observer, libsched, the Python tests (without SB3/PyTorch) and a replay of the recorded trace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…re" memo - Jobs keeps waiting jobs in a doubly linked list in (arrival, slot) order: oldest() is O(1) and `fifo` stops at the first job that fits instead of scanning the whole pool (same tie-breaking as before). - Jobs.blocked: one bit per job meaning "fits on no machine this tick". Capacity only shrinks within a tick, so the bit stays valid until the engine clears it on tick advance. Used by rules.firstMachine, the action mask and the pair-scanning policies (best_fit, tetris, random). - Results are identical (56 reference episodes across all policies and workloads diff clean). fifo up to 11.9x faster (300 machines, pool 1024: 1683 → 141 ms), sjf up to 5.1x; best_fit/tetris unchanged on large clusters (dominated by scoring fitting pairs). - Tests: randomized list-order test against brute force; the reference property test now also checks firstMachine and the memo every step. - A per-(job, machine) fit cache was also tried and measured slower (the fit test costs about as much as a lookup), so it is not included; documented in docs/data-layout.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PairCache keeps (job, machine) scores across decisions and recomputes only the column of the machine that changed, using new Machines.epoch/stamp change counters (engine calls touch() on placement). Decisions are bit-identical to a full scan; a property test compares against a fresh policy at every step. 300 machines: best_fit 11x, tetris 14x, tetris_srpt 5.7x faster. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Builds the job-to-machine scheduling simulator out from the initial skeleton.
weight), random; policy specs accept numeric options.random,deeprm; arrivalspoisson,batch,mmpp(bursty),pareto(heavy-tailed),selfsimilar(Pareto ON/OFF, H = (3−α)/2).Rewardport withneg_in_system(default),neg_waiting,slowdown(DeepRM),zero.zig build lib) +sched_envGymnasium env with zero-copy views and action masks, Stable-Baselines3 MaskablePPO example, matplotlib visualizer.traceobserver writes JSON Lines;replay.pyrebuilds and animates episodes offline.Testing
zig build test: unit tests, integration tests, hand-worked scenarios, and a property test against a naive reference simulator (20 random episodes, checked every step). Deliberately planted bugs were each caught.PYTHONPATH=python pytest python/tests:check_env, masked episodes, policy stepping, sliding-window views, visualizer, and trace replay matching a live run frame for frame.🤖 Generated with Claude Code