GuidesAPI Reference
Guides

Objectives

The objective function (or simply objective) in optimization problems is the function whose value is to be minimized or maximized over the set of all feasible solutions that satisfy the problem constraints. A classical objective function in the Vehicle Routing Problem (VRP) domain is the minimization of total distance. However, real life scenarios require different objective functions or even more than one considered simultaneously. Good examples of different objectives would be fair work distribution, prioritization of particular jobs over others, reducing the amount of tours over total cost, etc.

Tour Planning allows you to specify objectives using the problem's optional property objectives

Supported objectives

The list of supported objectives is:

  • minimizeUnassigned: minimizes the number of unassigned jobs
  • minimizeCost: minimizes the total solution cost (implicitly could minimize distance, duration and fixed cost)
  • minimizeDistance minimizes the total traveled distance
  • minimizeDuration: minimizes total duration calculated as the sum of all tour durations
  • optimizeTourCount optimizes the number of tours in the solution. The objective has an extra parameter:
    • action: if set to minimize then it minimizes the number of tours in the solution. If it is set to maximize then it maximizes the number of tours in the solution
  • optimizeTaskPosition: controls the position of job task activities in the tour. When specified, the task position is considered as a soft constraint, and the solver tries to minimize the number of its violations. When not specified, but position property is defined on job task's level, then it is considered as a hard constraint, which cannot be violated.

Objectives are specified in a hierarchy using the objectives property:

"objectives": [
    {
      "type": "minimizeUnassigned"
    },
    {
      "type": "minimizeCost"
    }
]

In this example, the objective minimizeUnassigned is highest in the hierarchy, meaning it will govern the optimization stronger than the other objective. As a consequence the optimization algorithm will favor solutions with fewer unassigned jobs over solutions with lower cost. Note that having the minimizeUnassigned at lower levels of the hierarchy, e.g. after minimizeCost in the above example, might lead to unexpected results like having all jobs unassigned.

Default objectives

In case you did not specify the objectives, by default the solver minimizes the amount of unassigned jobs with highest importance, the number of tours with medium importance and with least importance the total cost. This is equal to the following definition:

"objectives": [
    {
      "type": "minimizeUnassigned"
    },
    {
      "type": "optimizeTourCount",
      "action": "minimize"     
    },
    {
      "type": "minimizeCost"
    }
]

When relying on the default objectives, make sure that they serve the purpose of your optimization. For example, if you care more about the cost of using your fleet, and you have a hybrid fleet of small and large vehicles with large ones being more expensive, then probably you need to put minimizeCost above optimizeTourCount in the objectives hierarchy. Otherwise, default objectives will tend to use the large vehicles, that are more expensive, as this will result in less total number of used vehicles.

The next section describes some implicit conventions and rules that are noteworthy when defining objectives.

Definition rules

  • objectives are specified as an array
  • the order of objectives in the array defines the importance of objectives from more important to less important
  • minimizeCost objective must be present
  • minimizeUnassigned objective must be present
  • each specific objective can be defined only once
  • an empty objectives definition is not allowed (see default objective)

Objectives in combination with territory, priority and job task position features

If the problem has territory, priority or job task position feature and whether the objectives property is set or not, the following applies.

  • If the problem has the territory feature, then satisfying it will get the highest importance.
  • If the problem has the job priority feature, then satisfying it will get the highest importance unless the problem has the territory feature, then it will be the second-highest importance.
  • In case the problem has the job task position feature, then it will be considered as a hard constraint.

Advanced objectives

Disclaimer: This is an ALPHA feature under development

Extended objectives used for optimization. Can be used to define the individual objectives that make up the objective function for optimization.

This feature CAN NOT be used together with objectives.

Supported advanced objectives

The list of supported advanced objectives is:

  • minimizeUnassigned: minimizes the number of unassigned jobs
  • minimizeCost: minimizes the total solution cost
  • minimizeTours: minimizes the number of used vehicles
  • maximizeTours: maximizes the number of used vehicles
  • optimizeTaskPosition: controls position of job task activities in the tour. When specified, the task position is considered as a soft constraint and the solver tries to minimize amount of its violations
  • minimizeDistance: minimizes total distance
  • minimizeDuration: minimizes total duration calculated as the sum of all tour durations
  • balanceMaxLoad: balances max load across all tours
  • balanceActivities: balances activities across all tours
  • balanceDistance: balances distance across all tours
  • balanceDuration: balances duration across all tours
  • maximizePriorityJobs: maximizes assignment of prioritized jobs
  • tourOrder: (deprecated) controls order of job activities in the tour
  • maximizeTerritoryJobs: achieves desired jobs distribution between vehicles considering the territories in which these vehicles operate
  • visuallyAppealingTours: produces a more visually appealing tours in contrast to cost/balancing considerations
  • minimizeTourOverlap: produces less overlapping tours, that are more geographically separated and more compact
  • serveInClusters: serves jobs in clusters

Example:

"advancedObjectives": [
  [
    {
      "type": "balanceActivities",
      "options": {
        "threshold": 0.1
      }
    }
  ],
  [
    {
      "type": "minimizeUnassigned"
    }
  ],
  [
    {
      "type": "minimizeCost"
    }
  ]
]