Add Costs
Add a cost that Network Optimization must charge — today, a transport cost that changes in steps with the quantity shipped on a lane.
When to use this¶
- A lane is paid for by the truck, container or pallet space: the second truck costs a whole truck however little is on it.
- A carrier's rate changes with volume: one rate up to an agreed quantity, another above it.
- A lane has a fixed charge for being used at all, on top of a cost per unit.
A lane whose cost is simply a price per unit needs none of this: the unit cost in the scenario's lane data already says it.
Place Add Costs between Create Scenario (or Load Scenario) and Network Optimization. Chain several Add Costs nodes for several lanes, or wire a table of steps into the second input.
What you need¶
- Scenario data wired into the first input, from Create Scenario, Load Scenario, Add Constraint or another Add Costs.
- Optionally: a table wired into the second input (Cost Table) — one row per step, for as many lanes as the table names.
- The lane's own unit cost set to 0 in the scenario. A lane is priced one way: by its unit cost or by steps. A lane with a unit cost above 0 and any steps, including steps that price every quantity at zero, is refused, naming the lane.
Piecewise Linear Transport Cost¶
The cost applies to one lane: a source, a target and a transport mode. It
prices the lane's total quantity in the scenario — of one product, or of
every product together when Product is ALL.
The cost is a list of steps. Each step covers the quantities from its From to its To and has two prices. From and To are in the scenario's flow quantity units; Per unit above From is priced per same unit. For example, a scenario in pallets needs breakpoints in pallets and a price per pallet:
| Field | What it is |
|---|---|
| From | Quantity at which the step starts. |
| To | Quantity at which the step ends. Blank on the last step, which has no upper limit. |
| Total cost at From | The whole cost at the step's From. It is not added to the step before: in a truckload model the second truck's step holds the price of two trucks. In a table this column is fixed_cost. |
| Per unit above From | The cost of each unit above the step's From. 0 makes the step flat. In a table this column is cost_per_unit. |
Above its From, a step charges:
Total cost at From + Per unit above From × (quantity − From)
The panel prints this under every step with the step's own numbers, for example 2,400 plus 24.24 per unit above 99, no upper limit.
The rules the steps must follow¶
- The first step starts at 0.
- Each step starts exactly where the one before it ends: no gaps and no overlaps.
- The last step's To is blank, and only the last step's.
- The cost stays at or above zero throughout every step. A negative per-unit rate is allowed only on a bounded step that never goes below zero.
Steps that break a rule are refused with a message naming the step.
Two things follow from the steps without being typed:
- Shipping nothing costs nothing. The first step's Total cost at From is paid only when the lane is used.
- On a border, the cheaper side applies. A quantity of exactly 33 between a step ending at 33 and one starting there costs whichever step is cheaper at 33.
Example: truckloads¶
A truck holds 33 pallets and costs 800. From the fourth truck on, the cost is treated as a price per pallet:
| From | To | Total cost at From | Per unit above From |
|---|---|---|---|
| 0 | 33 | 800 | 0 |
| 33 | 66 | 1600 | 0 |
| 66 | 99 | 2400 | 0 |
| 99 | (blank) | 2400 | 24.24 |
40 pallets cost 1600, two trucks. 120 pallets cost 2400 + 24.24 × 21.
Example: a rate that drops with volume¶
10 per unit for the first 1,000 units and 8 for each unit above them:
| From | To | Total cost at From | Per unit above From |
|---|---|---|---|
| 0 | 1000 | 0 | 10 |
| 1000 | (blank) | 10000 | 8 |
The second step's total cost at From is 10000 because that is what 1,000 units cost at the end of the first step.
Modelling tip: keep the steps few¶
Every step adds a yes/no decision to the optimization, and many steps on many lanes make it slow. Model the first few truckloads as steps and the rest as one last step with a cost per unit. From about four truckloads on, the difference between whole trucks and a price per unit is small against the total.
When the total cost falls¶
Steps may make a larger quantity cheaper in total than a smaller one — a discount that applies to all units once a volume is reached does that. The run completes, provided the cost stays nonnegative, and reports a warning that names where the cost falls, because a mistyped total looks the same. If it is what you meant, nothing needs changing.
Settings¶
| Setting | What it is | Default |
|---|---|---|
| Cost type | Piecewise Linear Transport Cost. Required. | none. The node is refused until one is picked |
| Source location | The lane's source, as the scenario's lanes write it. | none |
| Target location | The lane's target. | none |
| Transport mode | The lane's transport mode. | none |
| Product | One product, or ALL for the combined quantity of every product on the lane. |
none |
| Steps | The steps described above. | none |
Driving costs from a table¶
Wire a table to the Cost Table input (the second port) to price many lanes from one node. Each row is one step; the rows of one lane are read in the order the table lists them.
| Column | Required | What it holds |
|---|---|---|
| source | yes | The lane's source |
| target | yes | The lane's target |
| transport_mode | yes | The lane's transport mode |
| product | yes | A product, or ALL |
| from | yes | Where the step starts |
| to | no | Where the step ends; blank on a lane's last step |
| fixed_cost | yes | The whole cost at from |
| cost_per_unit | yes | The cost of each unit above from |
The table uses the scenario's flow quantity units for from and to, with
cost_per_unit priced per same unit. Add Costs refuses any nonblank
quantity_unit value, naming its row and unit, because it does not convert
units in cost tables. Convert the breakpoints and the per-unit rate to the
scenario's flow quantity units upstream, then remove quantity_unit.
Changing or removing the unit label alone does not convert the tariff.
A connected table is the whole definition. The panel then shows Priced by the table on Cost Table in place of its lane and steps, and names any required column the table lacks. A node with both a table and a cost typed into its panel is refused before the run starts; the panel says so and offers to clear the typed values. A table with no rows is refused when the run reaches the node, and so is a row that leaves a required column blank, naming the row and the column.
How the result shows the cost¶
The cost counts as transport cost everywhere transport cost is shown or limited: the objective, the solve report, a Budget Limit and the scenario's cost figures. In the resulting scenario, a lane's cost is shared between its flows in proportion to their quantity, and each flow's unit cost is the average that works out to.
Workflow wiring¶
flowchart LR
n1["Load Scenario"] --> n2["Add Costs (into Scenario Data)"]
n2 --> n3["Network Optimization"]
n3 --> n4["Create Scenario"]
To price lanes from a file, wire the Import Data node carrying the table into the second port, Cost Table, and the scenario into the first.
Common mistakes¶
- Typing a step's total cost at From as the amount added at that step. It is the whole cost so far: in the truck example the second step holds 1600, not 800.
- Leaving the lane's unit cost in the scenario while adding steps — the solve refuses a lane priced both ways. Set the lane's unit cost to 0.
- A source, target, transport mode or product that matches no lane (a mistyped name) — the solve reports it rather than silently ignoring the cost.
- Two costs for the same lane and product, for example one for
ALLand one for a single product — the solve refuses the second. - Many steps on many lanes — solve time can grow significantly.
Messages this node can show¶
This node has no messages of its own.
A run gives this node 5 minutes. A node that takes longer stops with Time limit reached.
Like every node, it can also stop on the checks before a run and the run's limits.