We will solve a simple optimization problem for a function of one variable. Given a dataset of historical prices of a product from two suppliers, our task is to identify what share of the product we should buy from each of the suppliers to make the best possible investment in the future.
Our Company is aiming to minimize production costs of some goods. During the production process, an essential product P is used, which can be supplied from one of two partners - supplier A and supplier B. Our consultants requested the historical prices of product P from both suppliers A and B, which were provided as monthly averages for the period from February 2018 to March 2020.
Our plan is to purchase the same amount of product P monthly. Choosing the supplier, we noticed, that there were some periods in the past, when it would be more profitable to use supplier A (the prices of product P were lower), and other periods to work with supplier B. For the Budget model we can set some percentage of the goods to be purchased from supplier A (e.g. 60%) and the remaining part from supplier B (e.g. 40%), but this split should be kept consistent for the whole of the twelve months period.
Based on the historical prices, is there a particular percentage which will be more profitable to supply from Company A, and the remaining part from Company B? Or maybe it does not matter and we can work just with one of the suppliers?
Denoting prices of the product P from Company A and Company B as ππ΄ (USD) and ππ΅ (USD) respectively, and the volume of the product to be supplied per month as π (units), the total cost in USD is:
$$ f(\omega) = p_A \omega n + p_B (1 - \omega) n $$
where 0β€πβ€1 is the parameter. If π=1 , all goods will be supplied from Company A, and if π=0, from Company B. In case of 0<π<1, some percentage will be allocated to both.
As it is planned to keep the volume π constant over the next twelve months, in the mathematical model the common approach is to put π=1. We can do this, because nothing depends on the volume and the end result will be the same. Now the total cost will be simpler:
$$ f(\omega) = p_A \omega + p_B (1 - \omega) $$
Obviously, you do not know the future prices ππ΄ and ππ΅, only historical values (prices {π1π΄,β―,πππ΄} and {ππ΅1,β―,ππ΅π} π months). And historically there were various periods of time when it was better to take π=1 ( ππ΄π<ππ΅π ) or π=0 ( πππ΄>πππ΅ ). Is it possible now to choose some π value that would provide some evidence of minimum costs in the future?
This is a standardΒ portfolio managementΒ (investment) problem well known in statistics, where based on the historical prices you need to make investment decision to maximize profit (minimize costs). we need to minimize the loss function πΏ(π). The approach is to calculate π(π) for each of the historical prices πππ΄ and πππ΅ ,ππ(π) = πππ΄π + πππ΅(1βπ). Then take an average of those values
$$ \overline{f(\omega)} = \text{mean} \left( f^i(\omega) \right) = \frac{1}{k} \sum_{i=1}^{k} f^i(\omega) $$
and look for such value of π which makes ππ(π) as "stable" as possible - varying as little as possible from the average. This means that you would want to minimize the sum of the differences.
$$ \left( f^i(\omega) - \overline{f(\omega)} \right) $$
As the differences can be negative or positive, a common approach is to take the squares of those and take an average of the squares: This equation calculates the mean squared error (MSE) for a function f(Ο).
$$ \mathcal{L}(\omega) = \frac{1}{k} \sum_{i=1}^{k} \left( f^i(\omega) - \overline{f(\omega)} \right)^2 $$
In statistics πΏ(π) is called a variance of {π1(π),β―,ππ(π)}. The aim is to minimize the variance πΏ(π), where π β [0,1]. Statistical theory shows that there is an π β [0,1] value which minimizes function πΏ(π) and it can be found using some properties of the datasets {π1π΄,β―,πππ΄} and {π1π΅,β―,πππ΅}.