The Task
Our task was to create software for the computer shop that
sells RAM. The computer shop orders certain amount of
RAM units at fixed time stages. The supply must be optimized
when the demand is unknown.
Analysis
Optimal ordering of supplies is an important application
of sequential statistical decisions. Our task is based on
general "Bride problem" task. The main difference is that
the bride marries only once and no divorce is permitted.
That is wrong if the "marriage" represents buying RAM.
The user can specify these parameters:
· cw - wholesale price of one RAM unit (>0).
· cr - retail price of one RAM unit (>0).
· N - number of time stages (natural).
· L - loss due to short supply including fines for breaking
supply contracts and/or damages to reputation as a reliable
retailer(>0).
· D - shop warehouse size in RAM units (natural).
· W - maximal RAM demand (natural).
· lambda - expected RAM demand (>=0).
All these parameters correspond to the stage N - i, i =
0, 1, …, N - 1. Solving recurrent equations at each stage
one defines the sequence of optimal supplies and the optimal
expected utilities that depend on unsold RAM units left
from the previous stages. Results are stored in optimization
tables. Using arrays this way one reduces computing time
considerably, because array access operations need much
less time as compared to multi-dimensional optimization.
User interface
When the user starts the program, it opens the main window:
The user can specify the following parameters:
· Number of time stages (default value 5 )
· Retail price of one RAM unit (default value 200.00 )
· Wholesale price of one RAM unit (default value 100.00
)
· Loss due to short supply (default value 10.00 )
· Warehouse size in RAM units (default value 100 )
· Maximal RAM demand (default value 100 )
· Expected RAM demand (default value 50 )
The user can perform the following actions:
· Recalculate the results - press the button ' Build optimization
tables '.
Then the results are calculated depending on the given data
and stored in the optimization tables. The results are presented
in the graphical form.
· Customize graphical view - the user can select which
part of information he wants to view by specifying checkboxes:
1. "Show optimal supply chart"
2. "Show maximal utility chart"
If the user checks " Show optimal supply chart", optimal
supply chart when given the number of unsold RAM units from
previous stage appears:

If the user checks " Show maximal utility chart", maximal
utility chart when given the number of unsold RAM units
from previous stage appears:

For each number of unsold RAM units the optimal supply
and maximal utility curves are represented in different
colors.
Note, that in order to keep the clear view in these charts
not for all numbers of unsold RAM units from previous
stages maximal utility and optimal supply curves are drawn.
· To stop building optimization tables - simply press the button 'Stop'
· In the "Expert" panel the user can specify the time stage
and the supply of RAM units leftover in this stage. By pressing
"Get optimal RAM supply by stage", the optimal RAM supply
by the next time stage is shown.

During algorithm analysis, these inconsistencies have been noticed:
1)Utility function was incorrect (according to it, maximum amount of RAM should be
always purchased):
It should be substituted with this one:
2)Formula
should be substituted by this one (as utility in N+1 stage depends on
the number of unsold units in stage N+1, which in turn depends on the number of unsold units and demand in stage N):

References
1. "A
Set of Examples of Global and Discrete Optimization 2",
Homework for graduate students by Jonas Mockus
© 2001