A combination of two complementary approaches that are widely used to predict protein structure-homology and energy-based methods-is proposed. The algorithm is discussed in detail and is demonstrated to be a useful tool for optimization. The properties of the combination are exemplified on a simple model system: structural optimization of 2D heteropolymers on a square lattice. The algorithm is considerably more efficient than simulated annealing in the system studied. The relevance of the results of the protein folding problem is discussed.