Teg: simulation optimization