# An Intelligent Approach to Allocating Resources within an Agent-Based Cloud Computing Platform
## 4 Intelligent Model for Allocating Resources  
The redistribution of resources is performed by the GMAs located in each physical server, which have greater authority than the LSAs and can request them to add/remove virtual nodes to a specific service \(k\) with specific characteristics. The GMA is a highly specialized agent which is in charge of providing the CBR architecture [23; 44]. This reasoning process is performed simultaneously in all physical machines with available resources. In the last part of the distributed algorithm, a new VM, with specific characteristics of virtual CPUs (_ccpu_) and Memory (_M_) is instantiated to meet current demand (see Figure 3). The part associated with the reasoning of CBR at each physical node is based on the experience gained in storing similar cases. The knowledge base (_KB_)--or case memory--is shared with the whole CC environment; the global knowledge of the system can be shared with each of the GMAs. Since this memory can grow considerably as a maintenance strategy, a high-speed, schema-free database, based on MongoDB, is used to provide rapid access to the stored data. The reallocation process is initiated by the SSA associated with the service that is experiencing difficulties in responding to demand, as shown in Figure 4. This figure shows a hypothetical case of communication among the agents presented in Figure 3, where service \(k\) is deployed on virtual nodes hosted by three servers (PR\({}_{1,2\text{ and i}}\)) that have been represented as vertical lines. The servers host  
Figure 3: When a service experiences difficulty, more resources must be added by means of a new virtual machine (VM). Figure 2: **(Left)** The structure of the suborganizations (consumption and supply), data repositories and control devices; **(Right)** Shows the activity of the infrastructure control service. their agents and processes as described. The communication between agents and other processes is indicated by arrows. The aim of the communication is to find a solution--S(P)--to service demand. When a service \(k\) is experiencing difficulties, the associated SSA alerts all physical machines (that host the nodes of the service) that a new allocation of resources is required to handle the demand, as shown in the messages \(m_{2}\) sent from the SSA to the remaining agents of the service in Figure 4. The message is received by the GMA from each physical server of the service, GMAs of \(PR_{1}\), \(PR_{2}\) and \(PR_{i}\) in Figure 4. The GMAs that received the message alert the remaining GMAs in the CC environment, as shown in the message \(m_{2}\) sent from the GMA of PR\({}_{1}\) to PR\({}_{2}\) in Figure 4.  
These agents ask the LMA of each machine to evaluate the level of usage of the internal resources. Each LMA generates a matrix \((l_{PR_{i}}^{t})\) with the information for the time \(t\) in order to evaluate the amount of available resources. Communication occurs between the GMA and LMA of each \(PR_{i}\), which implies the message sequence \(\left[rq_{1,1},rq_{1,2},rp_{1,3},rp_{1,4}\right]\) for the case of \(PR_{1}\) in Figure 4. This snapshot structure gathers instantaneous information \((l_{PR_{i}}^{t})\) on the complete state of resource assignment at a specific time \(t\) in the resource \(PR_{i}\) (See Table 1). With this information, the GMA determines whether the physical machine can enter the decision process. If the amount of resources in each physical machine is greater than the minimum indispensable resources required to instantiate a node associated with the service, then the reasoning process is initiated to determine the amount of resources that can be reserved for each execution node as requested by the SSA for that service. Figure 4 shows the messages \(rp_{1,5}\) and \(rq_{2,5}\) sent by CBRs in GMAs from PR\({}_{1}\) and PR\({}_{2}\), respectively, to the SSA. However, if there are no available resources, or if there are fewer