Costs can be calculated using a cost function which relates overall expenditure to the volume of each class of traffic. But it is also necessary to determine whether expenditure is adequate to cover costs; when it is not (usually because of market failure) shadow prices may have to be set for some goods.