Spaces:
Paused
title: SolverForge Field Service Routing
emoji: 🧰
colorFrom: indigo
colorTo: blue
sdk: docker
app_port: 7860
pinned: false
license: apache-2.0
short_description: SolverForge field-service routing example
SolverForge FSR
solverforge-fsr is a SolverForge field-service routing app with retained
jobs, technician schedules, road-network geometry, and a browser map workspace.
It answers one concrete question:
"Given technicians, service visits, skills, parts, shifts, territories, and road-network travel, which technician should serve each visit and in what order?"
Quick Start
make run-release
Then open http://localhost:7860.
To inspect the supported command surface:
make help
Documentation Map
README.mdQuick start, model concepts, validation, REST API, and solver policy.WIREFRAME.mdAs-built architecture and runtime/data flow across backend, routing, and UI.AGENTS.mdCodex-facing maintenance, validation, and documentation rules.MakefileSupported local commands for development, validation, Docker, and Space work.DockerfileDocker Space image build using Rust 1.95 and the declared crates.io line.
Current Dependency Shape
- Package:
solverforge-fsr; version is declared inCargo.toml - Release binary:
solverforge_fsr - Rust:
1.95 - SolverForge runtime:
solverforge0.19.3 - SolverForge core helpers:
solverforge-core0.19.3 - Browser UI assets:
solverforge-ui0.6.5 - Routing engine:
solverforge-maps2.1.4 - Scaffold metadata:
solverforge-cli2.2.2insolverforge.app.toml
The app serves registry-backed Rust dependencies, local static browser modules, and Axum API routes from one process.
Model Concepts
Locationis a problem fact: a depot or customer coordinate.ServiceVisitis a problem fact: a customer job the solver must place in a route.TravelLegis a problem fact: precomputed duration, distance, and reachability between two locations.TechnicianRouteis the planning entity: one route owned by one technician.TechnicianRoute.visitsis the list planning variable: the ordered visit sequence SolverForge changes.FieldServicePlanis the planning solution with the currentHardSoftScore.
The app ships one deterministic STANDARD Bergamo dataset with two depots, six
technicians, 24 customer locations, and 48 service visits.
Constraints
Hard constraints:
- Every service visit is assigned exactly once, and route visit indexes are valid.
- Every route leg is reachable.
- The assigned technician has the required skills.
- The assigned technician carries the required parts.
- Visits fit their time windows.
- Routes fit technician shift capacity.
Soft constraints:
- Total travel time is minimized.
- Workload is balanced across technicians.
- Territory affinity is preferred.
- Deadline slack is rewarded more strongly for higher-priority visits.
REST API
GET /healthGET /infoGET /demo-dataGET /demo-data/{id}POST /jobsGET /jobs/{id}DELETE /jobs/{id}GET /jobs/{id}/statusGET /jobs/{id}/snapshotGET /jobs/{id}/analysisGET /jobs/{id}/routesPOST /jobs/{id}/pausePOST /jobs/{id}/resumePOST /jobs/{id}/cancelGET /jobs/{id}/events
snapshot_revision={n} is optional for snapshots, analysis, and route
geometry. Route geometry reports unreachable, snap-failed, and no-path legs as
segment statuses so one failed road leg does not hide the rest of the route.
Solver Policy
solver.toml is embedded by FieldServicePlan and is the runtime source of
truth.
list_round_robincreates the first visit distribution.- Local search combines list change, list swap, sublist change, sublist swap,
and reverse moves over
TechnicianRoute.visits. hill_climbingwithfirst_best_score_improvingkeeps this tutorial easy to reason about.- Solving stops after 60 seconds.
Road-network routing is prepared from the deterministic Bergamo coordinates and
stored as TravelLeg facts before solving.
Validation
Standard validation:
make test
Full local validation:
make ci-local
make test runs Rust tests, JavaScript syntax checks, and Playwright browser
tests. make ci-local adds formatting, clippy, release build, and Docker image
build.
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/field_service_plan.rsThe solution type, fact collections, route entities, transient index normalization, route shadow refresh, and score.src/domain/location.rs,src/domain/service_visit.rs, andsrc/domain/travel_leg.rsThe problem facts the solver reads.src/domain/technician_route.rsandsrc/domain/route_metrics.rsThe planning entity, list variable SolverForge mutates, and route shadow measurements used by stock constraints.src/data/data_seed.rsandsrc/data/bergamo_*.rsDemo ID, Bergamo data assembly, static fact catalogs, routing preparation, and cache policy.src/constraints/mod.rsThe score model assembled from SolverForge constraints.src/constraints/*.rsOne business scoring rule per file. Most rules use stockConstraintFactorystreams; duplicate visit assignment uses a custom incremental counter so retained score analysis counts only real duplicate groups.src/solver/service.rsRetained-job orchestration overSolverManager<FieldServicePlan>.src/api/routes.rs,src/api/dto.rs,src/api/route_geometry.rs, andsrc/api/sse.rsHTTP routes, transport DTOs, route geometry, and live-event streaming.static/app.jsandstatic/app-*.jsBrowser lifecycle, dataset loading, route rendering, maps, tables, and API guide.
Project Shape
src/domain/Planning model, domain types, route entities, and route shadow measurements.src/constraints/SolverForge scoring rules, one business rule per file; most use stock streams.src/data/Deterministic Bergamo demo data and road-network preparation.src/solver/Retained-job facade and runtime event payload formatting.src/api/Axum routes, DTOs, route geometry, and SSE endpoint.static/Browser workspace built on stocksolverforge-uiassets.tests/e2e/Playwright browser tests for the served app.
