Optimize: Evaluate
POST
/api/v1/optimize/evaluateScore a caller-supplied solution without freely re-solving. Useful for auditing a manually constructed or externally produced route plan against FG-API's cost model.
Description
Accepts an EvaluateRequest: the base problem plus a list of solution_routes (resource ID and an ordered list of job IDs). Internally this is implemented by converting the routes into locks.routes and running a 1-second, 1-solution-limited solve seeded with those locks, then returning the resulting OptimizationResponse (essentially a scored echo of the provided solution).
Request body: EvaluateRequest
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| base | OptimizationRequest | required | - | The full problem definition (resources, jobs, travel, etc.). |
| solution_routes | SeedRoute[] | required | - | List of {{resource_id, stops: [{{job_id}}, ...]}} describing the solution to score. |
Response
Full OptimizationResponse reflecting the provided routes, with score, summaries, and any violations detected.
Examples
curl -X POST https://api.fieldgenius.be/api/v1/optimize/evaluate \
-H "Content-Type: application/json" \
-H "X-API-Key: your-adapter-key" \
-H "X-Client-Key: your-client-key" \
-d '{
"base": {
"travel": { "distance_matrix": [[0,6,9],[6,0,5],[9,5,0]] },
"resources": [{ "id": "van-01", "depot_index": 0 }],
"jobs": [{ "id": "stop-a", "location_index": 1 }, { "id": "stop-b", "location_index": 2 }]
},
"solution_routes": [
{ "resource_id": "van-01", "stops": [{ "job_id": "stop-a" }, { "job_id": "stop-b" }] }
]
}'import httpx
payload = {
"base": {
"travel": {"distance_matrix": [[0, 6, 9], [6, 0, 5], [9, 5, 0]]},
"resources": [{"id": "van-01", "depot_index": 0}],
"jobs": [{"id": "stop-a", "location_index": 1}, {"id": "stop-b", "location_index": 2}],
},
"solution_routes": [
{"resource_id": "van-01", "stops": [{"job_id": "stop-a"}, {"job_id": "stop-b"}]}
],
}
headers = {"X-API-Key": "your-adapter-key", "X-Client-Key": "your-client-key"}
resp = httpx.post("https://api.fieldgenius.be/api/v1/optimize/evaluate", json=payload, headers=headers)
print(resp.json()["score"])Errors
| Status | Code | Resolution |
|---|---|---|
| 422 | VALIDATION_ERROR | The base request fails validation; fix and resubmit. |
| 422 | SOLVER_INFEASIBLE | The provided routes are not feasible under the base problem's constraints (e.g. a time window the proposed sequence cannot satisfy). |