*2.2.1.4 System parameters*


The credit of a Worker Agent increases if the following situations [4]:


*Agent Based Load Balancing in Grid Computing DOI: http://dx.doi.org/10.5772/intechopen.94219*

6.The communication load is small.

*2.2.1.2 Agent selection policy*

parameters [4]:

*2.2.1.3 Worker agent dependent parameters*

migration process should be prohibited.

affinity between an agent and its running host.

4.The agent's remaining execution time is short.

destination resource.

*2.2.1.4 System parameters*

agents migrate.

machine.

**60**

5.The agent's size is large.

1.The Worker Agent's load reduces.

The selection policy handles which Worker Agent is migrated whenever there is a necessity. We assign a numerical value, called credit, to every Worker Agent. The credit value designates the capacity of the agent to remain undisturbed in case of migration. For a Worker Agent, the higher its credit value, the higher its opportunity to stay at the same machine. In other words, its opportunity to be selected for migration is lower. The LBC Agent assigns credit to each Worker Agent and chooses which agent requests to be migrated using the credit. Any Worker Agent with high credit will be given more opportunity to preserve its current location (the resource

the agent resides in) with less opportunity to be selected for migration.

*Artificial Intelligence - Latest Advances, New Paradigms and Novel Applications*

The credit value of a Worker Agent is assumed to depend on two types of parameters, namely Worker Agent dependent parameters and System dependent

1. Its computational load, as it represents the main source of resource loading.

2. Its communication load, as it represents another source of resource loading.

3.Agent's size, an agent migrates through the network to its new destination, thus an agent with big size is predictable to take more time to reach its

4.Agent's priority, the interruption of a high priority agent running to perform a

1.Reliability of the communication path between resources, the migrating agent

2.Availability of required resource on the source host, this factor represents the

3. Source Host's loading, the host with high load will be more subject to let some

delivery is not assured when the physical path reliability is low.

The credit of a Worker Agent increases if the following situations [4]:

2. It communicates frequently with other worker Agents in other resources.

3. It has a high familiarity with the local machine. For example, it needs a special type of processors, I/O devices, or large volumes of data localized at the

7.The communication path between hosts is not reliable.


In contrast, the credit value of Worker Agent reduces in the following situations:

1.The Worker Agent's load Increases


Using a multiple linear regression operation, we will try to gather all the mentioned factors into one equation, In linear regression, the relationship between a dependent variable, Y, and an independent variable X, is modeled by Y = a + βX. This interpretation of coefficient, it is appropriate only when the independent variable is continuous (quantitative). To incorporate qualitative independent variables into the regression model and formulate the model so the variables have interpretable coefficients, There are two commonly used methods for coding qualitative variables so they can be used in regression models, dummy coding and effect coding [4, 5]. To include the variables qualitative in the equation, we will use the simplest way which is the dummy coding, which assigns values "1" and "0" to reflect the presence and absence, For example, if we take a qualitative variable Resource availability Ri, we assigned value 1 when the resource is available and 0 if it is not available. The final equation can be written as:

$$\begin{aligned} \text{Credit A}\_{i} &= \mathbf{b}\_{0} + \mathbf{b}\_{1}\mathbf{W}\_{i} + \mathbf{b}\_{2}\mathbf{U}\_{i} + \mathbf{b}\_{3}\mathbf{R}\_{i} + \mathbf{b}\_{4}\mathbf{L}\mathbf{d}\_{i1} + \mathbf{b}\_{5}\mathbf{L}\mathbf{d}\_{i2} + \mathbf{b}\_{6}\mathbf{H}\_{i1} + \mathbf{b}\_{7}\mathbf{H}\_{i2} \\ &+ \mathbf{b}\_{8}\mathbf{P}\_{i1} + \mathbf{b}\_{9}\mathbf{P}\_{i2} + \mathbf{b}\_{10}\mathbf{S}\_{i} \end{aligned} \tag{2}$$

Having a big coefficient means that this variable will make the agent tends to stay rather than being migrated.

b1: Computation load Coefficient: if b1 is a relatively large negative value then an agent having a big computation load is more likely to be migrated as its credit value will be reduced. If b1 is a positive value then the resource that has a big computational load value will be excepted from the list of receiver resources.

b2: Communication load Coefficient: if b2 has a negative value, then we can assume that an agent has a big communication load, it is more matter to migration as its credit value will be small. Since b2 has the smallest weight among the regression coefficients then it has the weakest effect on the credit value and therefore the migrating agent selection. If b2 is a positive value, so when it is multiplied by the communication load, a resource that has a big communication load value will be excepted from the list of receiver resources.

b3: Resource Availability Coefficient: when Ri = 1, b3 has relatively large values, that means that the agent finds the needed resource on the running host thus it is less subject for migration.

b4, b5: Host Load Coefficient: b4 has a higher load than b5 because when the running host is underloaded or balanced, it is less matter to select one of its agents to be migrated.

b6, b7: Reliability's Coefficient: if Hi1,Hi2 = 1,1 then b6, b7 have relatively large values because that's means that the agent may not reach the destination node through the unreliable network, thus the migration frequency is less.

LBC Agent: Gathering Information Algorithm

*Agent Based Load Balancing in Grid Computing DOI: http://dx.doi.org/10.5772/intechopen.94219*

Send LoadR to its Resource Agent associated

Sends LoadR to its Resource Agent associated;

Sends LoadR to its Resource Agent associated;

if (events\_happens () = 2 or events\_happens () = 3) then

if (events\_happens () = 1 or events\_happens () = 4) then

Calculates the total local load host LoadR by using Eq. (1) and sends it for Resource Agent

Adds Worker Agents for the list of Worker Agents and adds their load

Removes Worker Agents from the list of Worker Agents and subtract their

Loop wait for load change//depends on happening of any of defined events

Calculates Credits of Worker Agents (by using Eq. (2);

If (Worker Agent Termination) then events\_happens () =1; End If If (Worker Agent Start) then events\_happens () =2; End If

If (Cluster.state = unbalanced) then events\_happens () = 8; End If

Input: receive LoadR from LBC Agent, Worker Agents info

Keeping track of the number of alive Worker Agents on the local host;

If (Incoming Migrating Worker Agent) then events\_happens () = 3; End If If (Worker Agent Departure) then events\_happens () = 4; End If If (Arrival of any new resource) then events\_happens () = 5; End If

If (Withdrawal of any existing resource in the local host) then events\_happens () = 6;End If If (Loadcluster > Sthreshold)then events\_happens () = 7; End If//Sthreshold saturation threshold

Input: Worker Agents info Output: LoadR = resource load

Creates the list of Worker Agents;

values for the load of resource.

load from the load of resource

Function events\_happens () output Type: integer

Resource Agent: Workload Estimation

Started up LBC Agent associated; Started up Worker Agents associated; Receives LoadR from LBC Agent associated; Sends LoadR to its Cluster Agent associated;

Output: {

}

**63**

{

{

{

}

{

} End Loop }

b8, b9: Priority's Coefficient: the high or moderate priority mean b8 and b9 have high weight because the high or moderate priority agent are less matter to be migrated.

b10: Agent size Coefficient: a big size agent mean b10 has a positive sign which means that a medium-size agent will be less matter for migration as they will encounter more loads in the transmission.

#### *2.2.1.5 Location policy*

After a Worker Agent is determined to migrate, we have to select the receiving resource. The location policy defines to which destination resource the selected Worker Agent will be migrated to. The Cluster Agent selects the destination resource. For this purpose, it executes the following actions:

When the Cluster Agent receives the load information from its resources, it Partition cluster into an overloaded resources list (OLD), under-loaded resources list (ULD), and balanced list (BLD) and it sorts OLD by descending order of their load and ULD by ascending order of their load. The resource will be in an overloaded list if its load is high. The resource will be in the underloaded list if its load is low. The resource is not into the overloaded list or the underloaded, after that the Cluster agent sorts the overloaded resources list by descending order relative to their Load and sorts underloaded resources list by ascending order relative to Their Load. In the next step, Cluster Agent determines the sender resource and the receiver resource, where the sender resource is the first resource in the overloaded resources list and the receiver is the first resource in the underloaded resources list. Each Worker agent records the communication load between all the resources. If the receiver resource has the highest communication load with the migrated Agent then it is selected as the receiver resource else we must select another receiver resource from the list of underloaded resources. This is because, if a receiver resource is an external resource, the load of Worker Agent may not reduce due to large external communication. Instead, the load may rise.

#### *2.2.1.6 Worker agent migration*

The Worker Agent selection is related to its credit value while the receiver resource is the most under loaded resource. The migration decision is taken by a Cluster Agent that sends it for Migration Agent associated. The proposed MAS employs a mobile-agent system to support the migration of an agent. For migrating the Worker Agents, the status of the system and the agents currently operate or registered have to be considered. The receiver resource has to have more than one running agent. The Migration Agent sends a request message to the AMS agent. Then, the AMS sends an authentication message along with timestamp to it. The Migration Agent sends a request message of migration along with the authentication message to the DLA (Dynamic Library Agent) of the receiver resource. The DLA then sends the Worker Agent code after verifying the authentication and validation of the message. Finally, the Worker Agent migrates itself to the receiver resource or migrates a clone agent, in calling the doMove () method by the migrating agent with as parameter the receiver resource. The migrated agent is executed by the Dynamic Library Agent, and if the migrated one is a clone agent, it records itself to the platform by itself.

*Agent Based Load Balancing in Grid Computing DOI: http://dx.doi.org/10.5772/intechopen.94219*

b6, b7: Reliability's Coefficient: if Hi1,Hi2 = 1,1 then b6, b7 have relatively large values because that's means that the agent may not reach the destination node

b8, b9: Priority's Coefficient: the high or moderate priority mean b8 and b9 have

b10: Agent size Coefficient: a big size agent mean b10 has a positive sign which means that a medium-size agent will be less matter for migration as they will

After a Worker Agent is determined to migrate, we have to select the receiving resource. The location policy defines to which destination resource the selected Worker Agent will be migrated to. The Cluster Agent selects the destination

When the Cluster Agent receives the load information from its resources, it Partition cluster into an overloaded resources list (OLD), under-loaded resources list (ULD), and balanced list (BLD) and it sorts OLD by descending order of their

overloaded list if its load is high. The resource will be in the underloaded list if its load is low. The resource is not into the overloaded list or the underloaded, after that the Cluster agent sorts the overloaded resources list by descending order relative to their Load and sorts underloaded resources list by ascending order relative to Their Load. In the next step, Cluster Agent determines the sender resource and the receiver resource, where the sender resource is the first resource in the overloaded resources list and the receiver is the first resource in the underloaded resources list. Each Worker agent records the communication load between all the resources. If the receiver resource has the highest communication load with the migrated Agent then it is selected as the receiver resource else we must select another receiver resource from the list of underloaded resources. This is because, if a receiver resource is an external resource, the load of Worker Agent may not reduce due to large external communication. Instead, the load may rise.

The Worker Agent selection is related to its credit value while the receiver resource is the most under loaded resource. The migration decision is taken by a Cluster Agent that sends it for Migration Agent associated. The proposed MAS employs a mobile-agent system to support the migration of an agent. For migrating the Worker Agents, the status of the system and the agents currently operate or registered have to be considered. The receiver resource has to have more than one running agent. The Migration Agent sends a request message to the AMS agent. Then, the AMS sends an authentication message along with timestamp to it. The Migration Agent sends a request message of migration along with the authentication message to the DLA (Dynamic Library Agent) of the receiver resource. The DLA then sends the Worker Agent code after verifying the authentication and validation of the message. Finally, the Worker Agent migrates itself to the receiver resource or migrates a clone agent, in calling the doMove () method by the migrating agent with as parameter the receiver resource. The migrated agent is executed by the Dynamic Library Agent, and if the migrated one is a clone agent, it records itself to

load and ULD by ascending order of their load. The resource will be in an

high weight because the high or moderate priority agent are less matter to be

through the unreliable network, thus the migration frequency is less.

*Artificial Intelligence - Latest Advances, New Paradigms and Novel Applications*

resource. For this purpose, it executes the following actions:

encounter more loads in the transmission.

migrated.

*2.2.1.5 Location policy*

*2.2.1.6 Worker agent migration*

the platform by itself.

**62**

LBC Agent: Gathering Information Algorithm Input: Worker Agents info Output: LoadR = resource load { Creates the list of Worker Agents; Calculates the total local load host LoadR by using Eq. (1) and sends it for Resource Agent Send LoadR to its Resource Agent associated Loop wait for load change//depends on happening of any of defined events { if (events\_happens () = 2 or events\_happens () = 3) then { Calculates Credits of Worker Agents (by using Eq. (2); Adds Worker Agents for the list of Worker Agents and adds their load values for the load of resource. Sends LoadR to its Resource Agent associated; } if (events\_happens () = 1 or events\_happens () = 4) then { Removes Worker Agents from the list of Worker Agents and subtract their load from the load of resource Sends LoadR to its Resource Agent associated; } End Loop }

Function events\_happens () output Type: integer If (Worker Agent Termination) then events\_happens () =1; End If If (Worker Agent Start) then events\_happens () =2; End If If (Incoming Migrating Worker Agent) then events\_happens () = 3; End If If (Worker Agent Departure) then events\_happens () = 4; End If If (Arrival of any new resource) then events\_happens () = 5; End If If (Withdrawal of any existing resource in the local host) then events\_happens () = 6;End If If (Loadcluster > Sthreshold)then events\_happens () = 7; End If//Sthreshold saturation threshold If (Cluster.state = unbalanced) then events\_happens () = 8; End If

Resource Agent: Workload Estimation Input: receive LoadR from LBC Agent, Worker Agents info Output: { Started up LBC Agent associated; Started up Worker Agents associated; Receives LoadR from LBC Agent associated; Sends LoadR to its Cluster Agent associated; Keeping track of the number of alive Worker Agents on the local host; }

For every resourcei of cluster do

*Agent Based Load Balancing in Grid Computing DOI: http://dx.doi.org/10.5772/intechopen.94219*

If (resourcei is saturated) then OLD OLD ∪ resourcei;

Sort OLD by descending order relative to their LoadR; Sort ULD by ascending order relative to their LoadR; Selects the first resource of OLD list as sender resource; Selects the first resource of ULD list as receiver resource;

Migration Agent: Worker Agent Migration algorithm Input: Sender Resource, Receiver Resource

If receives an authentication message from AMS agent then

Sends an Acknowledgment for its related Cluster Agent;

LoadR < Bthreshold: ULD ULD ∪ resourcei;

LoadR = Bthreshold: BLD BLD∪ resourcei;

Sends this information for Migration Agent;

Output: an Acknowledgment

Sends migration request for AMS agent;

DL Agent sends code for the Worker Agent; Worker Agent migrates itself to the receiver resource;

*2.2.2 Intra grid load balancing algorithm*

avoid making useless agent migration.

Input: Loadcluster

**65**

mation will be considered in the next period.

Cluster Agent: intra-grid load balancing algorithm

LoadR > Bthreshold: OLD OLD ∪ resourcei; /\* Bthreshold is balanced threshold \*/

Receives Sender Resource and Receiver Resource from its related Cluster Agent.

Sends a request message for Dynamic Library Agent of the receiver resource;

Waits for an Acknowledgment from the Dynamic Library Agent of receiver resource;

Load balancing at this level is used if the Cluster Agent fails to balance its load among its related resources. In this case, each overloaded cluster migrates Worker Agents from its overloaded resources to underloaded clusters. In contrast to the intra-cluster level, we should consider the communication cost among clusters. Knowing the global state of each cluster, the overloaded cluster can send its Worker Agents for under-loaded clusters. The selected under-loaded clusters are those that require minimal communication cost for migrating agents from overloaded clusters. The agent can be transferred only if the sum of its latency in the source cluster and cost transfer is lower than its latency on the receiver cluster. This assumption will

We associate a period to each Cluster Agent, during which each Cluster Agent sends its current load information to the other clusters. So, a Cluster Agent can receive new load information about another one at any time. This updated infor-

{

Else Switch Case 1:

Case 2:

Case3:

{

}

Cluster Agent: Knowledge Algorithm Input: receives tasks from AgentGrille, LoadR, LoadC Output: Cluster Load, table of resources information { sends tasks among Resource Agents; create the table of resources information; receive LoadR from the resource Agents under its control; Updates the table of resources information; if (events\_happens () = 5) then { Create Resource Agent for the new resource; Creates LBC Agent for the new resource; Creates Worker Agents for new resource; Sends tasks among Resource Agent of new resource Adds information of the new resource for table of resources information Updates the table of resources information; } if (events\_happens () = 6) then { Kill Resource Agent of the destroyed resource; Kills LBC Agent of the destroyed resource; Kills Worker Agents for the destroyed resource; Removes information of the destroyed resource from table of resources information Updates the table of resources information; } Diffuses Cluster Load to other Cluster Agents;}

AgentLBC: Selection policy Algorithm Input: AgentWorkers info Output: AgentWorkers list are sorted by the ascending order of their credit value, selected AgentWorker { Orders the list of Worker Agents by ascending order of their Credit values; Selects the first Worker Agent from the list for migration; Sends this information for Migration Agent;

}

Cluster Agent: location policy algorithm Input: table of resources information, LoadR,Loadcluster Output: Sender Resource, Receiver Resource { if (events\_happens () = 7)//cluster is saturated intra-grid load balancing algorithm Else If (events\_happens () =8) then { Partitions Table of resources information into overloaded resources table (OLD), under-loaded resources table (ULD) and balanced resources table (BLD) OLD φ; ULD φ; BLD φ

*Agent Based Load Balancing in Grid Computing DOI: http://dx.doi.org/10.5772/intechopen.94219*

Cluster Agent: Knowledge Algorithm

sends tasks among Resource Agents; create the table of resources information;

if (events\_happens () = 5) then

if (events\_happens () = 6) then

Updates the table of resources information;

Create Resource Agent for the new resource; Creates LBC Agent for the new resource; Creates Worker Agents for new resource; Sends tasks among Resource Agent of new resource

Updates the table of resources information;

Kill Resource Agent of the destroyed resource; Kills LBC Agent of the destroyed resource; Kills Worker Agents for the destroyed resource;

Updates the table of resources information;

AgentLBC: Selection policy Algorithm

Input: AgentWorkers info

Diffuses Cluster Load to other Cluster Agents;}

{

{

}

{

}

AgentWorker {

}

{

Else

{

**64**

Input: receives tasks from AgentGrille, LoadR, LoadC Output: Cluster Load, table of resources information

receive LoadR from the resource Agents under its control;

Adds information of the new resource for table of resources information

*Artificial Intelligence - Latest Advances, New Paradigms and Novel Applications*

Removes information of the destroyed resource from table of resources information

Output: AgentWorkers list are sorted by the ascending order of their credit value, selected

Partitions Table of resources information into overloaded resources table (OLD), under-loaded

Orders the list of Worker Agents by ascending order of their Credit values;

Selects the first Worker Agent from the list for migration;

Sends this information for Migration Agent;

Cluster Agent: location policy algorithm

intra-grid load balancing algorithm

If (events\_happens () =8) then

OLD φ; ULD φ; BLD φ

Input: table of resources information, LoadR,Loadcluster Output: Sender Resource, Receiver Resource

if (events\_happens () = 7)//cluster is saturated

resources table (ULD) and balanced resources table (BLD)

For every resourcei of cluster do { If (resourcei is saturated) then OLD OLD ∪ resourcei; Else Switch Case 1: LoadR > Bthreshold: OLD OLD ∪ resourcei; /\* Bthreshold is balanced threshold \*/ Case 2: LoadR < Bthreshold: ULD ULD ∪ resourcei; Case3: LoadR = Bthreshold: BLD BLD∪ resourcei; Sort OLD by descending order relative to their LoadR; Sort ULD by ascending order relative to their LoadR; Selects the first resource of OLD list as sender resource; Selects the first resource of ULD list as receiver resource; Sends this information for Migration Agent;

Migration Agent: Worker Agent Migration algorithm Input: Sender Resource, Receiver Resource Output: an Acknowledgment Receives Sender Resource and Receiver Resource from its related Cluster Agent. Sends migration request for AMS agent; If receives an authentication message from AMS agent then { Sends a request message for Dynamic Library Agent of the receiver resource; DL Agent sends code for the Worker Agent; Worker Agent migrates itself to the receiver resource; Waits for an Acknowledgment from the Dynamic Library Agent of receiver resource; Sends an Acknowledgment for its related Cluster Agent; }
