Optimiciti Developer PortalOptimiciti Developer Portal
  • Pricing
  • Documentation
  • API Reference
  • Back to Optimiciti
Information
Problem
    Submit an optimization runpostPoll a run's status (never its routes)getCancel the optimization run identified by the problemId parameterpost
Utilities
    Health Checkget
Billing
    This month's task usagegetList public plansget
History
    Get User RunspostGet Run IdspostGet Run SummariespostList Example ScenariospostGet Run ResultspostGet a published example scenariogetUpdate Run NamepostDelete Runpost
Data-processing
    Calculate a cost matrix for the given locationspost
Optimization
    Get Run StatuspostCancel Runpost
System
    Read Rootget
Schemas
powered by Zuplo
Optimiciti API Specification
Optimiciti API Specification

Data-processing

Prepare travel data - build the travel-cost matrix (durations and distances between your locations) that a problem needs.


Calculate a cost matrix for the given locations

POST
https://api.optimiciti.com
/cost_matrix

Calculate a cost matrix for the given locations and travel costs. This is useful for calculating travel durations and distances between locations.

Calculate a cost matrix for the given locations › Request Body

This schema defines the request body for calculating a cost matrix. It includes the locations and travel costs to use for calculating the cost matrix.
CostMatrixRequest
​Location[] · required

The locations to use for calculating the cost matrix.

costSettings
​CostSettings · required

The settings to use for calculating travel costs between locations. This includes the cost metric (duration or distance), cost multiplier, cost adder, and methods for calculating distances and durations.

​TravelCost[]

The travel costs to use for calculating the cost matrix. If not provided, the cost matrix will be calculated automatically based on the latitude and longitude of the locations. A partial cost matrix can be provided to avoid recalculating travel durations and distances between locations.

coordinateSystem
​CoordinateSystem · enum

Which coordinate family this problem's locations use. geographic (the default, and what every existing payload means) uses latitude/longitude on the Earth. cartesian uses unbounded x/y on an arbitrary plane, for scenarios with positions but no addresses. It describes the DATA, not the costing, so it is set once per request rather than per cost setting - and it decides which distance/duration methods are valid.

Enum values:
geographic
cartesian
Default: geographic

Calculate a cost matrix for the given locations › Responses

Cost matrix calculated. data.travelCostResponses holds one entry per location pair (duration, distance, and cost); data.travelCostErrors lists any pairs that could not be computed. This array drops straight into a solve: set problemData.travelCosts to data.travelCostResponses on your POST /problem request.

Make sure durations come back populated. With the defaults (no travelCosts supplied → autoCalculate* true, geo) every pair is computed. The trap is a matrix whose durations are null: the solver reads a null duration as an unreachable arc. You can produce that by sending autoCalculateDuration: false (or otherwise leaving durations empty). If that leaves no usable pair in the whole matrix, POST /problem rejects it with 400 UNCOSTED_TRAVEL_MATRIX (its 400 response says what counts as usable). If only some pairs are empty, /problem accepts the matrix and returns a succeeded run with the stops behind those pairs left unassigned and no error. An all-zero matrix is not the same thing — it solves fine, with every stop assigned and 0 total distance. (An absent/empty matrix at /problem is rejected outright with MISSING_TRAVEL_COSTS.) So confirm the returned duration values are populated before solving, and read the assigned count in the results.

success
​boolean
​CostMatrixResponse

The response schema for a cost matrix calculation request. This includes the travel costs and any errors encountered during the calculation.

POST/cost_matrix
curl https://api.optimiciti.com/cost_matrix \ --request POST \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer <token>' \ --data '{ "locations": [ { "locationId": "depot", "locationName": "Depot", "latitude": 39.7684, "longitude": -86.1581, "isDepot": true }, { "locationId": "a", "locationName": "Stop A", "latitude": 39.791, "longitude": -86.148 }, { "locationId": "b", "locationName": "Stop B", "latitude": 39.755, "longitude": -86.175 } ], "costSettings": { "costMetric": "duration", "autoCalculateDistance": true, "autoCalculateDuration": true, "distanceMethod": "geo", "durationMethod": "geo" } }'
Example Request Body
{ "locations": [ { "locationId": "depot", "locationName": "Depot", "latitude": 39.7684, "longitude": -86.1581, "isDepot": true }, { "locationId": "a", "locationName": "Stop A", "latitude": 39.791, "longitude": -86.148 }, { "locationId": "b", "locationName": "Stop B", "latitude": 39.755, "longitude": -86.175 } ], "costSettings": { "costMetric": "duration", "autoCalculateDistance": true, "autoCalculateDuration": true, "distanceMethod": "geo", "durationMethod": "geo" } }
json
application/json
Example Responses
{ "success": true, "data": { "travelCostResponses": [ { "fromLocationId": "550e8400-e29b-41d4-a716-446655440000", "toLocationId": "550e8400-e29b-41d4-a716-446655440001", "fromLocationName": "Chicago", "toLocationName": "Indianapolis", "vehicleTypeId": "550e8400-e29b-41d4-a716-446655440000", "vehicleType": "Truck", "duration": 0, "distance": 0, "cost": 0, "status": "s", "errorMessage": null } ], "travelCostErrors": [ { "errorMessage": "Missing latitude or longitude for at least one location.", "errorDescription": "One or both locations are missing latitude or longitude." } ] } }
json
application/json

HistoryOptimization