Solving linear functions with constraints.

132 Views Asked by At

I have a table of data, for maximum available items in a given time period. With a constraint on how many of each items I can take in total. When I have taken the allowed amount of an item I can take the percentage residual of another item, so if I take items from $X_3$ in period $T_1$ I can max take 6 due to the constraint, however if there were no constraint I could have taken 8. So, I have taken 6 of the possible 8, this allows me to take the residual from another item, $(1-\rho)X_i$ for $X_i \neq X_3$, where $\rho = 6/8$, I choose to take from $X_2$ since this will give me the highest value. Which is 1, thus in $T_1$ I can get 7 items.

In $T_2$ I cannot take any more items from $X_3$ even if I wanted to since the constraint has been reached, and I can only take the amount the constraint allows me of $X_2$ which is 7 items (since I took one in $T_1$).

(Solving for the rest I get $T_2 = 8.5\bar{5}$ and $T_3 = 8$, and the total items in all periods are $23,5\bar{5}$)

Table: $X_1$, $X_2$ and $X_3$ are available items in a given time period $T_1$, $T_2$, and $T_3$ respectively, while $C$ is the total constraints connected with the items. $X_i$ are values represented by some constraint connected to $T_i$. Thus, if I take all items of a specific $X_i$ in a specific $T_i$ i cannot take any additional items (I have taken 100% of the allowed items.)

\begin{matrix} & T_1 & T_2 & T_3 & C\\ \hline X_1 & 3 & 7 & 8 & 10 \\ X_2 & 4 & 9 & 7 & 8 \\ X_3 & 8 & 5 & 6 & 6 \\ \end{matrix}

The question is:

  1. How should this be formally solved when I have to do step-wise optimization ($T_1$ then $T_2$ then $T_3$).

  2. Is it possible to optimize without regard to time periods? (Assuming this is larger then the step-wise optimization)

  3. Finally, does there exist software/code that would allow me to do this easily with data formatted as shown (or some variation of it)? (As this can become tedious and error prone done by hand with large data-sets)

Best Regards

1

There are 1 best solutions below

2
On

I would recast the time constraint on acquisition of items as a cost description, so assuming say 300 to spend in each period, the cost table looks like:

$$\begin{matrix} & T_1 & T_2 & T_3 & \text {Max #}\\ \hline X_1 & 100 & 42.8 & 37.5 & 10 \\ X_2 & 75 & 33.3 & 42.8 & 8 \\ X_3 & 37.5 & 60 & 50 & 6 \\ \end{matrix}$$

This is less clear in one way, that we can't so easily see when we are hitting the limit for a certain item, but allows clear comparison across time periods, and is more flexible in that we have already seen that taking part of an item is possible, so there is no clear reason for integer limits on items per time period. In other cases we might defer taking the most-available item if it is cheaper at another time, or if another item is also cheap in that time period. If $X_1$ were only a little cheaper in $T_1$, say 95, it would have been better to take that instead of $X_2$.

If you don't have knowledge of future prices, the approach can be simpler in some ways, although there might be some value in monitoring how closely various items are approaching their constraints even so.

  1. Using costs like this, stepping "greedily" through the lowest prices would clearly leave you slightly less optimal than your actual solution. However the availability matrix doesn't seem to hold all the answers either.

  2. I'm not sure what optimizing without regard to time periods would look like. Are you suggesting that all the time period availability gets totalled together? but then it is surely - under your worked example - just a matter of taking the most-available item, followed by the next, etc.