The paper is concerned with the energy management of a renewable energy based installation situated in an isolated rural area. The installation is composed of photovoltaic panels, a wind turbine and a battery bank, which supply a non-controllable load. An Energy Management Algorithm is proposed to decide on the switching between the installation components. The control decisions depend on the generated photovoltaic and wind turbine powers, the battery bank state of charge and the non-controllable load power demands. A fuzzy algorithm, which ensures the system's autonomy, a continuous load supply and safe operation for the battery bank, is used to decide on the connection of the installation's components. Then, using the genetic algorithm, a cost optimization of the installation operation is introduced to decide on the contribution of each power source in supplying the loads. Using measured meteorological data of the target area, the algorithm is extensively tested and the obtained results show the efficiency of the proposed algorithm in maximizing the use of the renewable energies, minimizing the installation's operation cost, guaranteeing the installation's autonomy even under climatic parameters changes while also ensuring a safe operation of the battery bank.