The development of effective design solutions for many construction projects requires taking into account the bearing capacity and the cost of manufacturing the superstructure and the foundation as a single system. We suggested an algorithm of complex optimal design of a steel flat frame for the building frame, and foundation posts under its columns on the natural foundation. It is proposed to minimize the cost of materials of basic variable parts of the structure. The search is carried out using a genetic algorithm on the discrete sets of standard sizes of cross-sections of frame rods, sizes in terms of foundation bases and base steel plates, foundations heights and overhangs of their jumps, concrete and reinforcement grades, diameters and installation steps of longitudinal reinforcement bars. The rod design scheme is used for the frame. The influence of normal forces in bars on their bending strains is taken into account. Vertical and angular compliances of ground base are taken into consideration. The example of optimizing a three-span steel frame and foundation posts of a building during the construction process in the town of Bryansk is given.