# Costing Curves¶

Based on all the cluster calculations, **Secondary Transport Costing Navigator** creates Costing Curves from Stem Distance and Drop Size. On the Costing Curves page you can see visualizations of these Costing Curves and you can fine tune the way they are calculated.

## Stem Distance and Drop Size Intervals¶

The costing curves are based on the Allocated Cost Per THU that are calculated for the individual customer locations. As these costs are strongly influenced by the stem distance and drop size of a customer location, the costing curve for a clustering is a function of both stem distance and drop size.

To ensure that outlying data points don’t skew the costing curve, the app creates intervals for both stem distance and drop size. For each interval combination, the average Allocated Cost per THU is calculated. Based on these interval data points, a nonlinear cost function is found that minimizes the difference between the cost function values and the data points.

## M.A.P. Error [%]¶

The *M.A.P. Error* widget shows the *Mean Absolute Percentage Error* over all intervals and all customer locations respectively. The M.A.P. Error is a good indication of how well the cost function represents the data points.

It calculates the absolute difference between the data points and the cost function values as a percentage of the data points. The average is shown for both intervals and customer locations.

## Select from Feasible Scenarios¶

On the Cluster Analysis page, you can perform an analysis to find the best number of clusters as this number influences the costing curves.

When you have created a clustering for a certain number of clusters, this is called a scenario. All calculated scenarios that match your specified constraints, are called the Feasible Scenarios.

In the *Select from Feasible Scenarios* widget, you can select such a scenario. After that, the clustering, the corresponding calculations and the costing curves are loaded.

## Select from Calculated Scenarios¶

After you run scenarios on the Cluster Analysis page, this widget appears.

You can inspect all scenarios, including ones that are not feasible to your constraints (specified on the Cluster Analysis page). To inspect any scenario, drag the slider in *Select from Calculated Scenarios* to the desired number of clusters. This will load the clustering and corresponding calculations, and the costing curves.

## Cost Value Color¶

The *Cost Value Color* widget shows you which color in the graphs corresponds to which cost range.

## Cost per THU (average per interval)¶

On the Costing Allocation page the app has calculated the Allocated Cost per THU for each customer location. Each customer location has its own stem distance and drop size and these are bundled in intervals. For each interval combination, the average Cost per THU is calculated. The result is displayed in two charts: A Bubble Chart and a Bar Chart.

Bubble Chart - The Bubble Chart displays a single bubble for each stem distance and drop size interval combination. Hover over a bubble to see the ranges of these intervals and the corresponding Cost Per THU. The color of the bubbles is determined by the Cost per THU value.

High cost result in red bubbles, low cost result in green bubbles. The exact ranges of the colors can be found in the Cost Value Color Legend widget.

A yellow cross means that there are no customer locations with that specific stem distance and drop size.

Bar Chart - In the Bar Chart, you can see the same data as in the Bubble Chart. For each drop size interval, all stem distance intervals are displayed (when there are customer locations in the interval combination). The height of the bars represent the Cost per THU. The colors are the same as the corresponding bubbles in the bubble chart.

## Cost per THU (Function per interval)¶

Based on the Average Cost per THU for each interval, the app creates a cost function that minimizes the difference between the data points and the function. The resulting cost function is displayed in two charts: A Bubble Chart and a Bar Chart.

Bubble Chart - The Bubble Chart displays a single bubble for each stem distance and drop size interval combination. Hover over a bubble to see the ranges of these intervals and the corresponding Cost Per THU, calculated with the Cost Function. The color of the bubbles is determined by the Cost per THU (function) value.

High cost result in red bubbles, low cost result in green bubbles. The exact ranges of the colors can be found in the Cost Value Color Legend widget.

A yellow cross means there is no data for that interval, or the cost are zero.

Bar Chart - In the Bar Chart, you can see the same data as in the Bubble Chart. For each drop size interval, all stem distance intervals are displayed. The height of the bars represent the Cost per THU according to the cost function. The colors are the same as the corresponding bubbles in the bubble chart.

## Select from Cost Function Profiles¶

The app user can influence the cost function. By default, the app uses settings that have good results on test data. However, with your own data, you might want to fine tune the settings for the best result. Therefore, there are three Cost Function Profiles from which you can select:

- App Default - All Constraints are taken into account. Some Cost Factors are used without lower or upper bound.
- Customized - When selected a
*Constraints*widget appears. There you can select Constraints. For each item in the list of Cost Factors you can mark checkboxes for factors to use in the cost function. **Note:**After making changes to cost factors, click*Recalculate Cost Factors*to update results.

- Customized - When selected a
- Lowest difference with actual data points - All Constraints are taken into account and all Cost Factors are used without lower or upper bound. This results in a cost function that most accurately reflects the actual data points. This can result in cost curves that have weird shapes.

## Cost Factors¶

The Cost Factors table shows a list of all the possible cost factors that the app can take into account when determining the cost function. The Cost Factors are all based on a power (varying from -2 up to 2) of the stem distance or drop size or a combination of those. For each cost factor you can see (or indicate) whether the app will take it into account when determining the cost function and what the resulting value is.

For the *Customized* profile, you can restrict a cost factor to positive values by selecting `0`

the *Min* column, or negative values by selecting `0`

in the *Max* column.

The cost is the sum of the cost factors multiplied by their value.

## Minimum on Cost Values¶

The optimization model behind the app that determines the cost function, has a constraint that makes sure that the Cost per THU Values have a minimum value (by default 0.01 to avoid it being smaller or equal to zero, which is not desired). In the *Minimum on Cost Values* widget, you can specify this minimum.

## Constraints¶

The *Constraints* widget appears when the *Customized* profile is selected in Select from Cost Function Profiles. You can switch on/off the following constraints:

- Cost always Decreasing on Drop Size
- Cost always Increasing on Stem Distance
- Use Minimum on Cost Values

When one or more of these constraints is switched off, the calculation represents the data more accurately (lower M.A.P. Error).

However, these constraints guard against undesirable scenarios and turning them off may not lead to the best decision. It is possible that e.g. cost are not always decreasing on drop size, meaning that a bigger drop size can result in higher cost per THU. If there is no minimum on the cost values, they can become negative. Please be aware of this when turning off these constraints.

## 3D Example Chart¶

If you need help visualizing this data represented in 2D charts, scroll to the bottom right corner of the Costing Curves page and click *3D Example Chart*. The *3DChartExample* page shows the same vectors in a 3D representation, but uses demo data (not your data).