Research Article Cost-Effective Energy Usage in a Microgrid Using a Learning Algorithm Chaimaa Essayeh , Mohammed Raiss El-Fenni, and Hamza Dahmouni Department of Communication Systems, INPT, Madinat Al Irfane, Rabat, Morocco Correspondence should be addressed to Chaimaa Essayeh; chaimaa.essayeh@gmail.com Received 1 January 2018; Accepted 12 March 2018; Published 22 April 2018 Academic Editor: Qiangfu Zhao Copyright © 2018 Chaimaa Essayeh et al. Tis is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited. Te microgrid is a new concept of integrating the distributed energy resources (DER) within the grid. Te management of the heterogeneous sources of energy presents a challenge, especially as most of the DER are unpredictable. Besides, implementing microgrids should be economically benefcial to the customer; this will raise the challenge of decreasing the costs while ensuring the energy balance. In this paper, we used a stochastic approach based on a model-free Markov decision process (MDP) to derive the optimal strategy for the home energy management system. Te approach aims to decrease the energy bill while taking into account the intermittency of the renewable energy resources (DER) and other constraints. While other proposals charge the battery from the utility energy, making the state of charge (SOC) of the battery a deterministic variable, our work adopts a scenario where the battery is charged from the excess of the generated energy, which makes the SOC a nondeterministic variable afected by the uncertain character of the renewable energy. Terefore, our model considers the randomness at two levels: renewable energy level and battery SOC level. We take into account the complexity of the solution, and we propose a simple strategy that can be implemented easily in microgrids. 1. Introduction Te electric grid is one of the big consumers of the fuel. Such type of energy source is exhaustible and is getting to disappear in the too near future. Electricity suppliers across the world are now searching for new alternatives to compensate it and are making solid steps to incorporate new technologies in many aspects of the grid. With the raise of the new green technologies such as the PV panels, the wind turbines, and the electrical batteries, new ways of consuming energy emerge. In particular, the incorporation of such technologies with an information infrastructure created the concept of the smart grid [1]. Tough it has not yet a standardized defnition or a defned architecture, the smart grid can be seen as the innovation that will transform the electric grid from centralized and producer-controlled to a distributed and consumer-driven grid. Te opportunities ofered are countless, and the inte- gration of the ICT infrastructure leads to a rich content and multiple scenarios of use. In fact, with the help of the ICT infrastructure, more information is provided and this will enable an efcient control and monitoring of the grid system. Te home energy management system (HEMS) is one of the research felds associated with the smart grid concept. How to manage the energy efciently and optimally using the new resources of energy and taking advantage of the ICT infrastructure is the core topic of the HEMS. Several distributed architectures of the HEMS are suggested in the literature; some of them propose a multiagent system [2, 3] to monitor the diferent technologies (power electronics, telecommunications, generation, and storage energy systems) that compose the energy management system [4]. Others proposed architectures that manage the energy fow at the substations; the local generated energy is sold to the utility instead of being consumed locally. Te utility integrates then controlling strategies at substations to prioritize the DER and make them the frst energy supply for the customers [5, 6]. Other works have suggested the use of the smart microgrid (grid) architecture (e.g., [7–10]). Te US Department of Energy (DOE) defnes the grid as “a group of interconnected Hindawi Wireless Communications and Mobile Computing Volume 2018, Article ID 9106430, 11 pages https://doi.org/10.1155/2018/9106430