Nowadays, due to the advantages of high peak power, high average power, ultra-short pulse, and fully coherent characteristics, the high-repetition-rate free-electron laser (FEL) is thriving in many countries around the world. The thermal load caused by high-repetition-rate FEL poses a great challenge to the mirror surface shape. Especially in the case of high average power, how to perfectly control the mirror shape to maintain the coherence of the beam has become a difficult problem in beamline design. In addition to multi-segment PZT, when multiple resistive heaters are used to compensate for the mirror shape, the heat flux (or power) generated by each heater must be optimized to obtain sub-nanometer height error. This article establishes MHCKF model for the mirror surface deformation under the combined effect of the mirror initial deformation, the thermal deformation caused by X-rays, and the deformation compensated by multiple heaters. By searching the perturbation term in the mathematical model, the least squares solution of the heat fluxes generated by all heaters can be obtained. This method can not only set multiple constraints on the heat fluxes but also quickly obtain their values when minimizing the mirror shape error. It overcomes the problem of time-consuming optimization processes encountered by traditional finite element analysis software, especially in the context of multi-parameter optimization. This article focuses on the offset mirror in the FEL-1 beamline at S3FEL. Using this method, the optimization of 25 heat fluxes generated by all resistive heaters was accomplished within a few seconds utilizing an ordinary laptop. The results indicate that the height error RMS decreased from 40 nm to 0.009 nm, and the slope error RMS reduced from 192.7nrad to 0.4nrad. Wave-optics simulations show that the wavefront quality has been significantly improved. In addition, some factors affecting mirror shape error, such as the number of heaters, higher repetition rate, film coefficient, and the length of copper tube, were analyzed. The results show that the MHCKF model and optimization algorithm can effectively solve the optimization problem of compensating for the mirror shape with multiple heaters.