[en] Greenhouse horticulture is associated to a significant energy consumption in temperate countries, mainly for lighting and for heating. Interestingly, the potential for energy optimization and energy savings is high but requires detailed models capable of considering various system configurations and control systems. This paper provides an open-source modeling framework capable of simulating and optimizing the design and the control of both the greenhouse and the generation systems covering all energy needs. The proposed model is composed of sub-models from different scientific fields: a greenhouse climate model, a crop yield model, a large number of energy generation and storage units models and different rule-based control strategies. The association of such state-of-the-art models in a single framework provides a powerful tool for optimization purposes and allows the definition of completely customized systems by means of an object-oriented interface. In this work, various control strategies are defined and simulated, thus demonstrating the capabilities of the proposed model. Results indicate that, by performing minor changes to the control of the thermal screen, heating consumption can be reduced by 3 without any loss in crop yield. The control of heat-generation units also has a significant impact on the operational costs, which vary by up to 17 when self-consumption levels are accounted for in the control strategy.