Abstract. Methods of simulated annealing and genetic programming over probabilistic program traces are developed firstly. These methods combine expressiveness of Turing-complete probabilistic languages, in which arbitrary generative models can be defined, and search effectiveness of meta-heuristic methods. To use these methods, one should only specify a generative model of objects of interest and a fitness function over them without necessity to implement domain-specific genetic operators or mappings from objects to and from bit strings. On the other hand, implemented methods showed better quality than the traditional mh-query on several optimization tasks. Thus, these results can contribute to both fields of genetic programming and probabilistic programming.