Purchasing Optimization Problem I apologize in advance if this question is not formatted up to standards, as this is my first time asking a math related question on here.
I am currently working on a problem for work that I have recognized to be an optimization problem.
A bit of background. The problem I am working on involves purchasing a specific commodity, so the overarching goal is to determine when to purchase and how much to purchase at that time to minimize a specific metric (in this case, days on hand). The data I am given is grouped into weeks. When purchasing items, we are purchasing $8$ weeks in advance. For this particular problem, we are assuming that our forecasts are accurate. In addition to this, we have to buy a full train car of this commodity, which is approximately $195$ thousand pounds (so we can only buy multiples of $195$ thousand pounds). With that in mind, I have created the following optimization problem.
For simplification, let's say we are only purchasing for $3$ weeks rather than $8$.
The following are the equations and the conditions for the optimization:
Week_1_Qty= Initial_Qty - Forecast_week_1 + 195x_1
Week_2_Qty = Week_1_Qty - Forecast_week_2 + 195x_2
Week_3_Qty = Week_2_Qty - Forecast_week_3 + 195x_3


Initial_Qty, and the forecast at each week are all constants.
I am trying to minimize the following calculation of days on hand for the full three weeks in which I am purchasing(NOTE: this is not the typical financial calculation). More specifically, I am trying to find the values for $X_i$ that minimize the days on hand for this period.
sum(Week_i_QTY)/ 3*Avg_Daily_Useage 

Average daily useage is also a constant.
The only conditional statements I have are the following:
Week_1_Qty>0
Week_2_Qty>0
Week_3_Qty>0

I am not too familiar with optimization. Have I set up this optimization problem correctly and what type of optimization would I use to solve this. I am also unsure as to whether the constraints I created are set up properly (I only want to make sure that the quantity of the commodity does not go negative at any week). I was thinking linear programming, but am not for sure if this is the correct way to approach this problem.
Any advice is greatly appreciated. Once again, I apologize for the poor formatting.
I have tried running through these on online linear optimization calculators with some values for the equations I have given above and keep getting error messages on the equation I am attempting to optimize and I am unsure what I am doing wrong.
Do you believe the way that I set this up is the correct way to go about doing this? If not, what would some alternatives be.
 A: Let consider a planning time period made of m weeks.
Let be $ x_1, x_2 , \dots , x_m $ the quantity (measured in pounds) of the specific commodity to be purchased for every week in order to meet the demand. The demand for every week is known in advance and it is forecasted with a relative error (standard deviation/mean) less than 3%:
$ d_1, d_2 , \dots , d_m $
The lead time for getting the commodity from supplier requires 8 weeks and as a result it is necessary to place the purchase order in advance of 8 weeks:
$ x(t - \tau) = x_t $ where $ \tau = 8 $ weeks
For example, if today we got as optimal solution for third week x_3 = 100 pound, this means that we should place the order five weeks in advance from today, $ x_3 = x(3 - 8)  $
Because of a full train car is able to carry $k$=195,000 pounds of the commodities, we designate as
$ y_1, y_2 , \dots , y_m $
the number of train car to be hired for every specific week. Clearly $ y_i $ is a natural number.
Let $ INV_0 $ be the stock on hand at the beginning of planning time period.
The constraint that balances purchasing, demand and inventory is:
$ x_i + INV_{i-1} – INV_i = d_i $ for $i=1, \dots , m $
So, $ y_i \ge x_i / k $ where k = 195,000 pounds and therefore we request that
$ k y_i \ge d_i - INV_{i-1} + INV_i $
The goal is to keep the days on hand of commodity as minimum as possible without shortage in every week AND to hire the minimum number of train cars.
The mathematical model as PL can be written as:
$ min \left \{ \sum_{i = 1}^m y_i + \sum_{i=1}^m INV_i \right \} $
subject to:
$ \left\{ \begin{array}{l} 
k y_1 \ge d_1 - INV_0 + INV_1  \\ 
k y_2 \ge d_2 - INV_1 + INV_2 \\ 
\vdots \\
k y_m \ge d_m - INV_{m-1} + INV_m \\  \\
INV_i \ge 0   \forall \ i  \\
y_i \in N    \forall \ i
\end{array} \right. $
