In developing countries such as in Africa, rural areas are not always connected to the national or regional electric grid. As there is a huge potential for solar energy production, photovoltaics are established to supply electricity for operating critical infrastructures with battery systems and diesel generators installed for redundancy. These systems have the potential for further utilization. As a first step, overproduction of solar energy is offered to households due to simple control rules observing battery levels. This paper proposes an optimization method for energy allocation by process graphs or P-graphs. The method provides preliminary estimations on optimal periodical energy balances between energy producers, storage, and consumers of different priorities. These preliminary estimations serve as reconciliation parameters for advanced real-time control of energy distribution. Each step of transforming the practical problem of multiperiod energy distribution to the language of process network synthesis and then optionally to mathematical programming is detailed. To represent the problem adequately, the original formulation of process network synthesis is extended to take into account potential targets and intermediate entities that cannot be accumulated. The work aims to provide better utilization of renewable energy sources and storage. The microgrid profit and return of investment can also be improved by the proposed methodology.