Simulation templates
The SWAT API supports templating simulation objects, which simplifies creating, maintaining, and updating configurations and predefined routes without having to build a simulation from scratch each time. The ability to save predefined routes and routing profiles enables support for situations where routes are preplanned (like milk runs or static routes). Templates repesent an instance of the simulation object that can be quickly copied over (cloned) into a another simulation, for example, for a new day of operations.
Each project can have multiple simulation templates, each with time-based rules that determine which simulation should be selected to copy over for a specific date and/or time. This is controlled by the recurrence field of the simulation object, which is used to choose a simulation template for the selected date. If multiple simulation templates are available for the same selected time, recurrence_priority is used to select one.
SWAT APIs also offer a streamlined process for uploading bookings with automatic creation of a simulation based on a template. The same rules apply to order upload.
A set of business rules is invoked to ensure that time windows for objects (for example, open times for nodes, vehicle operating hours, and processing pipeline time windows) are adjusted appropriately during this process.
To create a simulation from a template two options are available:
- Explicitly create a simulation
- Upload booking\orders and autocreate the simulation during that process
Time window adjustment rules
- Sets
simulation.start_timeto the desired value. - Calculates
simulation.end_timeas the sum ofstart_timeand the duration of the source simulation, unlessend_timeis explicitly specified.
Subsequently, the following fields are adjusted relative to the new simulation.start_time:
simulation.booking_start_timesimulation.booking_end_timevehicle.start_timevehicle.end_timesimulation_processor.start_timesimulation_processor.end_timesimulation_processor.vehicle_filter_expression['start_time', 'end_time'](recursively)simulation_processor.bookings_filter_expression['min_pickup_time*', 'max_pickup_time*', 'min_dropoff_time*', 'max_dropoff_time*'](recursively)
There is always a chance that the timings of newly created objects may appear beyond the simulation timings due to incorrect or intentional setup of templates. For instance, time bounds are explicitly verified for vehicles, and their IDs are reported in the response. However, cloning a simulation with invalid vehicles is still permitted.