Spaces:
Sleeping
title: SolverForge Deliveries
emoji: 🚚
colorFrom: green
colorTo: blue
sdk: docker
app_port: 7860
pinned: false
license: apache-2.0
short_description: SolverForge delivery-route optimization example
SolverForge Deliveries
solverforge-deliveries is a SolverForge vehicle-routing example with retained
jobs, route geometry, insertion recommendations, and a browser plan viewer.
It answers one concrete question:
"Given depots, vehicles, delivery stops, capacities, and time windows, which vehicle should visit each delivery and in what order?"
Documentation Map
README.mdQuick start, concepts, API surface, and the shortest learning path.WIREFRAME.mdArchitecture and request/data flow across backend, runtime, maps, and UI.AGENTS.mdRepo-specific contribution, validation, and documentation rules.MakefileThe supported local command surface for development, validation, and Docker-based Hugging Face Space preparation.DockerfileThe Docker Space image build, using Rust 1.95 and published crates.io dependencies.
Current Dependency Shape
The app package version is 1.0.1; the release binary is
solverforge_deliveries.
This repo requires Rust 1.95 and is configured against published crates.io
dependencies. Direct dependency declarations currently pin these published
versions:
solverforge0.11.1solverforge-ui0.6.5solverforge-maps2.1.3axum0.8.9tokio1.52.1tokio-stream0.1.18tower-http0.6.8tower0.5.3serde1.0.228serde_json1.0.149rand0.10.1uuid1.23.1parking_lot0.12.5http-body-util0.1.3
The app metadata in solverforge.app.toml mirrors that published dependency
shape and records solverforge-cli 2.0.1 as the current scaffold metadata
line.
What SolverForge Is Doing Here
Deliveryis a problem fact: a stop the solver must place in a route.Vehicleis a planning entity: each vehicle owns one mutable route.Vehicle.delivery_orderis the list planning variable.Planis the planning solution, matching the currentsolverforge-clidefault solution name andsrc/domain/plan.rsfile shape.- Constraints score assignment coverage, capacity, time-window violations, and total travel time.
solver.tomlselects list construction heuristics and local-search moves. It matches the hospital example's stop policy: 30 seconds total, or 5 seconds without improvement.
The app ships three city datasets:
PHILADELPHIA(default)HARTFORDFIRENZE
Each dataset has ten vehicles: 82 Philadelphia deliveries, 50 Hartford deliveries, and 80 Firenze deliveries. Philadelphia is the default road-network baseline, and all current seed data has enough aggregate vehicle capacity and reachable street-front coordinates for the configured delivery stops.
Quick Start
make run-release
Then open http://localhost:7860.
To inspect the command surface:
make help
Validation
Standard validation:
make test
Full local validation:
make ci-local
Space image validation:
make space-build
Live road-network smoke:
make test-live-road
make test includes Rust tests, browserless frontend tests, and Playwright
browser tests. The Playwright defaults point at the sibling
../solverforge-ui checkout's Node modules; set PLAYWRIGHT and
PLAYWRIGHT_NODE_PATH when using a different local installation.
make ci-local adds the Docker image build used by the Hugging Face Space.
make pre-release runs make ci-local and then the live road-network smoke
test. The live road test may touch the local .osm_cache/ through
solverforge-maps; that cache is ignored by git and by Docker builds.
Hugging Face Space Deployment
This repo is Docker-Space ready. The Space reads the README front matter,
builds Dockerfile, and expects the app to bind PORT=7860.
Local Space-equivalent commands:
make space-build
make space-run
Read The Code In This Order
src/domain/mod.rsTheplanning_model!manifest and public domain exports.src/domain/plan.rsThePlansolution and list-variable shadow-refresh wiring.src/domain/delivery.rsandsrc/domain/vehicle.rsThe fact and planning-entity models.src/domain/route_metrics/Route preparation, CVRP hooks, scoring preview, route geometry, and insertion ranking.src/constraints/mod.rsThe constraint-set assembly point.src/constraints/*.rsOne scoring rule per file.src/data/data_seed/entrypoints.rsPublic demo-data IDs and generator dispatch.src/data/data_seed/{philadelphia,hartford,firenze}/City depots and delivery coordinates.src/solver/service.rsRetained-job orchestration overSolverManager<Plan>.src/api/routes.rs,src/api/dto.rs, andsrc/api/sse.rsREST, DTO, and event-stream contracts.static/app/main.mjsBrowser controller.static/app/models/andstatic/app/ui/Frontend plan normalization, preview modeling, layout, maps, tables, and modals.
Project Shape
src/domain/Planning model, domain types, route metrics, and test-only model checks.src/constraints/Incremental SolverForge scoring rules.src/data/Deterministic city demo-data generator.src/solver/Retained-job facade and runtime event payload formatting.src/api/Axum routes, DTOs, and SSE endpoint.static/app/Browser modules built on stocksolverforge-uiassets.DockerfileMulti-stage Rust 1.95 Alpine build for the Hugging Face Docker Space.tests/api_contract/Integration tests for catalog, jobs, lifecycle, SSE, and road-network smoke.tests/frontend_models.test.mjsBrowserless frontend model tests.tests/e2e/Playwright tests for the served browser app, including asset loading, dataset switching, route highlighting, and retained solve start/stop.
REST API
GET /healthGET /infoGET /demo-dataGET /demo-data/{id}POST /jobsGET /jobs/{id}GET /jobs/{id}/statusGET /jobs/{id}/snapshotGET /jobs/{id}/analysisGET /jobs/{id}/routesPOST /jobs/{id}/pausePOST /jobs/{id}/resumePOST /jobs/{id}/cancelDELETE /jobs/{id}GET /jobs/{id}/eventsPOST /recommendations/delivery-insertions
Lifecycle semantics:
pauserequests a runtime-managed pause and checkpoint.resumecontinues from the retained checkpoint.cancelstops a live or paused job.deleteremoves a terminal retained job before the next fresh solve.snapshot_revision={n}is optional for snapshots, analysis, and routes.- SSE reconnects bootstrap from the retained runtime status/event state.
Routing Modes
road_network is the default and uses solverforge-maps to fetch or load a
road graph for the current plan bounds. straight_line is available as a fast
draft/testing mode. Route geometry is returned by /jobs/{id}/routes and drawn
in the browser map only when it matches the active snapshot and routing mode.
Road-network geometry follows the solverforge-maps graph route, projects each
leg endpoint onto the nearest road segment, and then stitches the exact
depot/delivery coordinate back in so visible legs reach the markers. The route
list highlights by vehicle id, not by line color, so one selected vehicle route
is emphasized while the rest of the map geometry is dimmed without changing the
user's current map viewport.
Solver Policy
solver.toml is embedded by Plan and is the runtime source of truth:
list_clarke_wrightbuilds delivery routes.list_k_optimproves construction output before local search.- local search combines nearby list change/swap, reverse, k-opt, ruin, and limited sublist moves.
late_acceptanceandaccepted_countcontrol acceptance and retained candidates.- solving stops after 30 seconds total or after 5 unimproved seconds, matching the hospital tutorial.
The city seeds have coherent capacity and reachable road-network coordinates so
local search can reach feasible 0hard road-network solutions. Current seed
sizes are 82 Philadelphia deliveries, 50 Hartford deliveries, and 80 Firenze
deliveries, each with ten vehicles.