# Why the optimal value that minimizes a function does not satisfy condition?

I have found a solved example of A Stochastic Two-Period Model with No Setup Cost in the book Operational Research by Hillier, 7th edition, that has a lot of complicated calculations to arrive to the solution.

In the following example, $$c=$$cost of ordering, $$h=$$cost of holding, $$p=$$shortage cost and $$𝑦^0_𝑖$$ is the optimal order-up-to level in period 𝑖.

The part where things start to complicate, is when making the substitution of $$y_1^0$$ into $$C_1(x_1)$$.

Clearly will not be an easy calculation by hand since $$C_1$$ has this function $$L$$, that it's evaluated with diferent arguments, which are two integrals.

I am not sure what form the argument of $$\displaystyle \min_{y_1\ge x_1}\{\dots\}$$ will have, nor what would be best to do next. My book mentions this OR Courseware but since I have the pdf file book I don't have the disk? is refering to.

And my question is what can I do here in order to find the optimal $$y_1^0$$ without having to deal with lots and lots of calculations by hand?

Any suggestions are very appreciated.

The $$C_1(x_1):$$

The $$L(z):$$

# edit.

Following the comment of Larry, I substitute $$y_1^0$$ in the equation equal to zero (below the $$C_1(x_1)$$ definition in the image).

I assumed $$y_1^0=5$$ to be the optimal and this is what I got

$$-15+(15+10)\frac{5}{10}+(10-15)\Phi(5-2)+(15+10)\int_0^{3}\Phi(5-\xi)\phi_D(\xi)d\xi$$ $$=more\ calculations$$ $$=-\frac {11}{8}$$ This is different than $$0$$, which I don't understand why, the equation should have had the value $$0$$ because the book mentioned the optimal was $$y_1^0=5$$ and not $$y_1^0=6$$. Also the optimal should satisfy the equation equal to zero, but does not.

I really don't see what am I doing wrong? I did check twice the calculations of the expression and found no errors.

$$\star$$ Note: I asked this question on MSE https://math.stackexchange.com/questions/3246019/why-the-optimal-value-that-minimizes-a-function-does-not-satisfy-condition and currently has a bounty (grape period bounty to be exact) and I asked to migrate but it was not possible :(

• This question is very hard to follow. You haven't defined the notation (e.g., $y_1^0$) or provided sufficient context. The actual questions you are trying to ask are sprinkled throughout the post and are not that clear. I would encourage you to edit the question to make the question more concise and easy to follow. Nevertheless, I will try to answer and see whether that helps. – LarrySnyder610 Jun 11 '19 at 2:47
• @LarrySnyder610 Hi Larry, the context (the $y^0_1,y^0_2$) is the same as the other question of mine that you answered. I'll edit anyway. – user441848 Jun 11 '19 at 3:02
• I know that. But other readers of this question will not know that. You didn't even link to the original question. Remember that SE sites are supposed to be building a body of knowledge that will potentially be of use to many people, not just the individual person asking the question. – LarrySnyder610 Jun 11 '19 at 3:12

## 1 Answer

The text from the book tells you that the optimal value of $$y_1$$ is $$y_1^0 = 5.42$$. This comes from solving the optimality condition (the equation after "satisfies the equation") for $$y_1^0$$.

Presumably, somewhere in the example it says that the base-stock levels must be integers. Therefore, they plug the neighboring values, $$y_1^0 = 5$$ and $$y_1^0 = 6$$, into the objective function to see which one gives the better value. (This relies on the objective function being convex.) They found that $$y_1^0=5$$ is better. But it is not surprising that when you plug $$y_1^0=5$$ into the optimality condition, you don't get $$0$$; $$y_1^0 = 5$$ is only optimal because it has to be an integer.

(Similarly, if you want to minimize $$(x-\frac14)^2$$, the optimality condition is $$2(x-\frac14)=0$$; if $$x$$ must be an integer, you'd plug in $$x=0$$ and $$x=1$$ and pick the better value; but if you plug that value into the optimality condition, the LHS won't equal $$0$$.)

Now, to calculate the objective function for $$y_1^0=5$$ or $$6$$, I think they (or you) are skipping some logic here. The optimal policy is a base-stock policy, which means that you are looking for the optimal base-stock level, $$y_1^0$$. The cost of a given base-stock level $$y_1$$ is not given by calculating $$C_1(y_1)$$; it is given by setting $$x_1 =$$ something small (e.g., $$-10$$) and then calculating what's inside the $$\min_{y_1\ge x_1}\{\cdots\}$$ for that value of $$y_1$$. The idea is, assuming the inventory level $$x_1$$ is small enough that we will place an order in this period, what will be the cost if we place an order up to $$y_1$$?

The line in the book "substituting $$y_1^0=5$$ and $$y_1^0=6$$ into $$C_1(x_1)$$ seems misleading to me because it sounds like you're supposed to set $$x_1=5$$ and $$6$$, but that is wrong.