To apply the thermal comfort to the optimization of building layout, a variable design method based on Kmeans clustering is proposed. The evaluation was based on numerical simulation, genetic algorithm and universal thermal climate index (UTCI) to implement the building layout optimization on Matlab. Finally, the building layouts with centralized type, decentralized type and edge flow type water configuration were optimized, respectively. The results show that after the optimization, a reduction of 0.1∼0.6°C of UTCI was observed. We concluded that under moderate heat stress, the increase in wind velocity is the key to thermal comfort improvement.