Pseudo Codigo para Simulador de Politica de Inventario (S,s)

Datos:

	h :  costo de inventario, por unidad y unidad de tiempo
	b:   costo de back-order, por unidad y unidad de tiempo
	demandas :
	    llegadas con tiempos segun exp(0,1)
	    piden 1, 2, 3, 4 items con probas 1/6, 1/3, 1/3, 1/6 respectivamente
	tiempo de reposicion sigue una U[1/2, 1]

La revision es mensual, asi que se supone una unidad de tiempo de un dia, haremos una simulacion por un 
periodo T = 2 aos (730 dias).  Con esto la distribucion de los tiempos de llegada nos dice que hay un valor 
esperado de 10 llegadas por dia y la reposicion se demora entre medio y 1 dia uniformemente.

Variables de estado
  I :  nivel de inventario
  t :  tiempo de simulacion
 p :  si se ha hecho un pedido o no (binaria)

Otras variables
  R:  tiempo de la siguiente revision
  CH : costo de inventario acumulado
  CB : costo de back-order acumulado
  Q : cantidad de pedido


Eventos:
   - llegada de un cliente
   - revision
   - llegada del pedido



Programa:

Inicializacion
t = 0,  I = I_0, p = 0, u = 0
CH = CI = 0
R = 30

while t < T  do
   Dd = generar una exp(0,1)
   tR  = R - t
   if p = 0 then
       if tR <= Dd  then  
            DT = tR
            evento revision
        else
             DT = Dd
             evento llegada cliente
         endif
   else     (tR no puede ganar en este caso, ya que si p=1, u<1 y tR>28)
         if u <= Dd  then 
            DT = u
            evento llegada del pedido
         else
            DT = Dd
            evento llegada del cliente
         endif
         u = u - DT
   endif
   t = t + DT
endwhile


EVENTO REVISON
if I => 0 then
   CH = CH + h * I * DT
else
   CB = CB + b * I * DT
endif

R = R + 30
If I < s then
   u = generar uniforme [1/2, 1]
   Q = S - I
   p = 1
endif


EVENTO LLEGADA CLIENTE
if I => 0 then
   CH = CH + h * I * DT
else
   CB = CB + b * I * DT
endif

dd = generar cantidad (1,2,3,4 con probas 1/6, 1/3, 1/3, 1/6 )
I = I - dd


EVENTO LLEGADA PEDIDO
if I => 0 then
   CH = CH + h * I * DT
else
   CB = CB + b * I * DT
endif

I = I + Q
p = 0, u = 0

