Using optimization algorithms and developing dispatch strategies are essential in sizing renewable energy systems to ensure optimal performance, cost-effectiveness, and sustainability. This study employs the Teaching-Learning-based Optimization (TLBO) algorithm to determine the optimal size of a Combined Heat and Power (CHP) system. The optimization results are validated using the Genetic Algorithm (GA) and Particle Swarm Optimization (PSO). Furthermore, a novel dispatch strategy is developed to make an informed decision when using different energy sources. The strategy considers a 24-h foresight of upcoming electrical demand, solar irradiation, temperature, and wind speed. The developed dispatch strategy has led to a reduction in cost and excess electricity compared to the pre-prepared strategies. The energy sources employed include Photovoltaic panels (PV), Wind Turbines (WT), Diesel Generators (DG) with heat recovery capability, battery banks, and boilers to supply electrical and thermal demand. A Levelized cost of energy (LCOE) of 0.142 $/kWh is obtained for the PV/WT/DG/Battery/Boiler system. Although the three algorithms find almost similar optimal solutions, TLBO exhibits better convergence speed than PSO and GA. A comparison with HOMER software control strategies shows the developed dispatch strategy is 3.4% and 15.5% more efficient than Cycle Charging and Load Following strategies, respectively. Lastly, a comprehensive economic sensitivity analysis is performed to investigate the effect of inflation and discount rates on the size of components and final objective functions.