The increasing number of mobile devices, such as smartphones, tablets and laptops, as well as advances in their computing power have enabled us to consider them as resources, exploring the proximity. The use of near computing resources is growing year by year, being called as Fog computing, where the elements on the edge of the Internet are exploited, once the computer services providers could be unavailable or overloaded. Thus, this Master's project focuses on using mobile devices to provide computing services among them through a heuristic called Adapted Maximum Regret, which tries to minimize energy consumption and avoid untrustable devices. There is also top-level metaheuristic which interconnects different clusters of devices on the edge of the Internet with global information to guarantee Quality of Services (QoS). We conducted a set of experiments that showed us to avoid devices with a high degree of failures to save more energy when allocating tasks among them, as well as decreasing the applications response time and communication through adjusts in the selection algorithm of external agglomerates.