SDK Templates

List of available templates

Below is an in depth list of all available templates within the sdk command suite of Nextmv CLI.

Available templates

Focus AreaTemplate NameUse Case
vehicle routingroutingSolves a VRP for delivery, distribution, and sourcing problems
vehicle routingrouting-matrix-inputSolves a VRP using a custom matrix
vehicle routingmeasure-matrixInput generator for the routing-matrix-input template
vehicle routingtime-dependent-measureSolves a VRP for measures dependent on time (ie. time windows)
vehicle routingunique-matrix-measureSolves a VRP with a unique matrix that reduces input size
vehicle routingcloud-routingSolves a VRP for existing Nextmv routing app customers
clusteringclusterGroups a set of data points into clusters based on similarities
clusteringcluster-tspCreates a set of clusters equal to the number of vehicles, then solves a TSP for each vehicle
packingknapsackMaximizes the total value without exceeding weight capacity, given a collection of items with a value and weight
packingmip-knapsackSolves the knapsack problem using Mixed Integer Programming
schedulingshift-schedulingAssigns one worker to each shift while maximizing worker happiness
schedulingpager-dutyAssigns users to shifts for incident response on-call duty using input and output data structures compatible with PagerDuty API
customnew-appProvides a skeleton for creating a completely custom model
puzzlesudokuFills a 9x9 grid such that all columns and all 3x3 subgrids contain the numerals 1 through 9
allocationmip-meal-allocationDemonstrates how to solve a Mixed Integer Programming problem using Nextmv


For use solving a vehicle routing problem (VRP). This includes use cases for delivery, distribution, and sourcing, such as: food delivery, waste management, ridesharing, and more. The routing template uses the Nextmv Router Engine to assign and sequence vehicle visits to stops in the form of routes.

standard input:

  • vehicles - list of vehicle id
  • stops - array of stop id, and position

Check out our router engine options how-to guide for a full list of options that can easily be configured to solve most routing problems and our routing tutorial for more information on using the routing template


Similar to the routing template, cloud-routing solves a VRP but uses a different input structure which handles flexible and optional constraints based on the input file. The input handling of this cloud-routing template matches that of the Nextmv routing app.

standard input:

  • vehicles - array of vehicle id, capacity and start location
  • stops - array of stop id, position and quantity

Optional constraints such as penalties, precedence, and shifts are outlined in our router engine options how-to guide.


A cluster is a collection of points that are similar to one another in some way. The goal of clustering is to find natural groupings of the data, such that the points within a cluster are more similar to each other than to points in other clusters.

Clustering has a wide range of applications in various fields, such as:

  • vehicle routing: group customers or delivery locations based on proximity/similarities. Clustering can be used to identify patterns in customer demand, such as time of day or day of the week, and then use this information to optimize the routing plan accordingly.

  • marketing: segment customers into different groups based on their demographics, purchasing habits, interests, etc. This can help companies target their marketing efforts more effectively.

  • data analysis: identify patterns and relationships in large datasets, which can help organizations make more informed decisions.

  • social network analysis: identify groups of individuals with similar characteristics or behavior in social networks, which can help researchers understand how information spreads and how communities form.

The main entities involved in the cluster template are the data points to be clustered and the clusters themselves. Each data point is a representation of an object or phenomenon in the real world, and a cluster is a group of similar data points.

standard input:

  • points - each data point to be clustered
  • clusters - number of total clusters to create
  • maximum_weight - max weight value allowed per cluster
  • weight - weight given to each point
  • maximum_points - max number of points assigned to a given cluster

For more information on clusters, check out the sdk cluster package reference guide.


The cluster-tsp template reads a routing input data format but instead of solving a VRP directly, it creates a set of clusters in a pre-processing step, similar to the cluster template. The number of clusters created match the number of vehicles available in the input file, the cluster size is calculated such that points are distributed evenly among them. Then, for each vehicle, a traveling salesman problem (TSP) is solved. This is achieved by using the Attributes option in the routing engine.

Standard input:

  • vehicles - list of vehicle id
  • stops - array of stop id and position
  • stop_weight - weight given to each stop
  • cluster_capacities - max weight allowed for each cluster

For more information, check out the clustered routes tutorial.


The knapsack problem is a common combinatorial optimization problem: Given a set of items, each with a weight and a value, determine which items to include in the collection so that the total weight is less than or equal to a given limit while maximizing the total value.

This template has a wide range of applications, such as:

  • Bin packing: stacking objects into bins and not caring about how it’s stacked.

  • Simple marketing spend: optimizing spend for a single marketing campaign.

  • Material cutting problems: Finding the best way to cut steel coils or irregular shapes out of some textiles with least waste/clippings.

  • Pallet packing: stacking objects in a particular way (e.g., so nothing gets crushed due to weight, etc.).

standard input:

  • items - array of potential item id, value, and weight
  • capacity - an integer representing the max weight of the knapsack

For more information about the knapsack template, check out the knapsack tutorial


Solves the knapsack problem using Mixed Integer Programming and the open-source solver HiGHS.

Assigns a set number of items to a knapsack (or container). Not all items must be assigned. Optimize for the most valuable set of items possible while not exceeding the container's carrying capacity.

standard input:

  • items - array of item_id, value, weight, and volume
  • weight_capacity - max weight the knapsack can hold
  • volume_capacity - max volume the knapsack can accept


Assigns one worker to each shift while maximizing worker happiness score (the number of times a preference of a worker has been met) and covering all shifts with as few workers as possible.

standard input:

  • days - number of days in the schedule
  • workers - number of available workers
  • preference - array of shift_type including workers who prefer a type of day
  • unavailable - array of worker and unavailable days

This template is applicable to a wide range of applications that vary in terms of complexity. This can include:

  • nurse scheduling
  • sports scheduling
  • teacher coverage
  • driver assignments
  • cloud resource allocation

For additional information, check out our shift scheduling tutorial


Assigns users to shifts (days) for incident response on-call duty using input and output data structures compatible with PagerDuty API.


  • schedule_start - the start date of the schedule
  • schedule_end - the end date of the schedule
  • users - list of users to assign to shifts, containing name, id, type, and optional unavailable days and preferences

Click here to learn how to set up and run the pager duty app, and for more background on applying the pager-duty app, check out our blog.


This is a template shell that provides a skeleton with guidance on how to utilize store to create a completely custom model. If you want to build a completely new model from scratch, start with this template, which gives sensible defaults for how to structure, validate, and generate a new store.


Creating an algorithmic solver for Sudoku puzzles is a common optimization programming challenge. the sudoku template demonstrates how this can be done with Nextmv. This template completes a 9x9 grid such that all columns, rows, and 3x3 subgrids contain the numerals 1 through 9.

standard inputs:

  • 9x9 matrix listing initial values (1 through 9) and empty spaces (represented by 0)


To solve a Mixed Integer Problem (MIP) is to optimize a linear objective function of many variables, subject to linear constraints. We demonstrate this by solving a demo-problem we named mip-meal-allocation.

This template allocates meals (diets) consisting of carrot and endive ingredients to bunnies with the goal of maximizing their happiness through good diets and nutrition. This template uses the open-source solver HiGHS to maximize the number of binkies our bunnies will execute by selecting their meal.

A binky is when a bunny jumps straight up and quickly twists its hind end, head, or both. A bunny may binky because it is feeling happy or safe in its environment.

The input defines a number of meals we can use to maximize binkies, which indicates their level of happiness. Each meal consists out of one or more items and in total we can only use the number of items we have in stock.

standard input:

  • items - array of food name and amount in stock
  • meals - array of meal name, number of binkies produced, and list of ingredients


When using the routing-matrix-input template, the measure-matrix app must be run first to generate the necessary input required for this template.

A modeling kit for VRPs, this template shows how to use a custom matrix that is passed via an input file. Together with measure-matrix, these templates create a matrix of points from a measure that is accepted by the routing app. For more information on using the routing-matrix-input template, check out the custom matrices tutorial.

standard input:

  • stops - array of stop id and position
  • vehicles - list of vehicle id
  • starts - list of vehicle start location
  • ends - list of vehicle end location
  • shifts - array of vehicle shift start and end times
  • duration_matrix - matrix of point to point costs in travel time
  • distance_matrix - matrix of point to point costs in distance


Serves as an input generator for the routing-matrix-input app. The generated input data includes matrices for distance and travel time using one of our supported measures.

For more information on using the measure-matrix template, check out the custom matrices tutorial.


In real world VRPs, it is often needed to take the time of the day into account when calculating routes, e.g. to calculate correct ETAs during rush hours. The time dependent measure template shows you how to make use of time dependent measures and apply different costs according to time. This template is based on the routing template and can easily be combined with more options that are shown there like time windows or capacities (among many more).

standard input:

  • vehicles - list of vehicle id
  • stops - array of stop id and position
  • shifts - array of start and end times for each vehicle

For additional information, check out the time dependent measures tutorial.


The purpose of this template is to reduce input file size.

If the input has many duplicate stops, instead of passing a full matrix for each point, you can find all unique points in the matrix and use a unique matrix and a list of all unique points. Every stop then references a unique point. This data can then be used to recreate a full matrix as it is expected by the solver.

If the input has many duplicate stops input file size can be reduced drastically.

standard input:

  • stops - array of stop id and position
  • vehicles - list of vehicle id
  • starts - list of vehicle start location
  • ends - list of vehicle end location
  • unique_points - a unique set of locations that need to be visited
  • unique_matrix - represents a matrix of costs for going from each of the unique points to another

Check out the unique-matrix-measure tutorial to learn more about using this template.

Page last updated

Go to on-page nav menu