Better energy management systems for buildings could play a significant role in achieving nowadays greenhouse gas emission reduction targets. In this context, a regulation algorithm to manage the interaction between local renewable energy production, local energy storage devices and an external power source (power grid) was developed. The innovative aspect of this project compared to existing solution is the simultaneous optimization following three criteria: the external energy consumption, the cost and ecological impacts. The new optimization algorithm is based on the genetic algorithm method due to the large solutions space and the non-linearity of the optimization function. This method is coupled to a physical model of the building under study (a typical dwelling house) and its energetic network (production and storage). In addition, weather forecast data as well as data on the user habits are integrated. This paper shows the results of the optimization algorithm applied to a set of realistic values. The genetic algorithm is compared to a pure random optimization approach and their optimization efficiencies are analyzed. Finally, the best strategy obtained by the genetic algorithm for a realistic computation time of several minutes is presented and investigated in detailed. This results shows that the genetic algorithm can perform a 48 hours simulation with no outcome costs, a global production of 4.3 kWh of energy and a greenhouse gas production of -1.4 kg of CO2 equivalent, whereas the consumption of the building costs +1.3 CHF, consumes 7.0 kWh of energy and generates +1.3 kg of CO2 equivalent.