Lattice modeling of proteins is commonly used to study the protein folding problem. The reduced number of possible conformations of lattice models enormously facilitates exploration of the conformational space. In this work, we suggest a method to search for the optimal lattice models that reproduced the off-lattice structures with minimal errors in geometry and energetics. The method is based on the self-consistent field optimization of a combined pseudoenergy function that includes two force fields: an "interaction field," that drives the residues to optimize the chain energy, and a "geometrical field," that attracts the residues towards their native positions. By varying the contributions of these force fields in the combined pseudoenergy, one can also test the accuracy of potentials: the better the potentials, i.e., the more accurate the "interaction field," and the smaller the contribution of the "geometrical field" required for building accurate lattice models.