Optimization of discrete variable stochastic systems by computer simulation