# An Intelligent Approach to Allocating Resources within an Agent-Based Cloud Computing Platform
## 4 Intelligent Model for Allocating Resources
During the reuse phase, a solution to the problem is prepared, based on the cases that have been retrieved:  
* If the case base does not contain a similar past case, the solution to the problem is associated with the minimum resources determined at the level where the service is instantiated: \[S(P)=\left(M_{min},\ vcpu_{min}\right)\]* If similar cases were recovered, the solution to the problem would be the case closest to the new one, multiplied by the efficiency of the most similar case: \[\text{S}(\text{P})=\left(\text{M}^{\prime}\times\left(E_{m}\left(1\right)+E_{M} \left(1\right)\right)\text{, }\text{vcpu}^{\prime}\times\left(E_{m}\left(2\right)\right)\right)\] (4)
* In the case where there are not many resources available and the values assigned to the previous solution are higher than the values assumed by the machine, the result of the case would be the maximum amount of resources available in the machine. \[\text{S}(\text{P})=\left(\text{PR (Mmax), PR (vcpumin)}\right)\] (5)  
When the solution to the case is calculated, it is sent to the SSA. This agent reactively chooses the node that would provide a higher amount of resources at the VM level. In the subsequent review stage, the new node is deployed, and its use is evaluated from both a micro and macro perspective. In this way, the efficiency of the solution is obtained. Finally, in the last step of the CBR, both the case and the value of the efficiency are stored so that they can be reused in future executions. The proposed adaptation model is distributed, which makes it possible to improve the high availability of the system, since the decision-making process is made throughout the entire CC system. Furthermore, this model can distribute the strength of the calculation, which requires obtaining the solution; as a result, the impact that the search for a solution has on the CC environment is reduced. ```
CBR Algorithm INPUT: P, the description of the problem (case) to solve for a service \(k\). OUTPUT: S(P), the solution to problem P. REQUURE: KB: the knowledge base, \(d\): dissimilarity metric of cases, E: compute the solution efficiency of a case, #vm: VM number for a case, \(ar\): the available resource amount, \(ur\): the used resource amount, \(Service\). used service, T: service use period. \(\rho:\) dissimilarity metric of the service use period
```  
**Algorithm 1** Steps performed by the case-based reasoning algorithm involved in each global manager to allocate resources demanded by a service. ```
CBR Algorithm INPUT: P, the description of the problem (case) to solve for a service \(k\). OUTPUT: S(P), the solution to problem P. REQUURE: KB: the knowledge base, \(d\): dissimilarity metric of cases, E: compute the solution efficiency of a case, #vm: VM number for a case, \(ar\): the available resource amount, \(ur\): the used resource amount, \(Service\). used service, T: service use period. \(\rho:\) dissimilarity metric of the service use period
```  
**Algorithm 2** The proposed adaptation model is distributed, which makes it possible to improve the high availability of the system, since the decision-making process is made throughout the entire CC system. Furthermore, this model can distribute the strength of the calculation, which requires obtaining the solution; as a result, the impact that the search for a solution has on the CC environment is reduced.