**CHAPTER 3 PROPOSED ALGORITHMS**

**3.6. METHODOLOGY**

**3.6.6. SIXTH PROPOSED METHOD**

nodes Xj and Xi where i ≠ j, and Xi ∈ X \ Π(Xj): If adding an arc aij = Xi → Xj seems not to produce a directed cycle, then Gc+1 = Gc U {aij}. A second operator is Deletion, first chooses an arc aij from nodes Xi to Xj which is already in the Gc, then deletes it from the Gc., a new solution, Gc-1= Gc\{aij}; is concerned. The third operator is Reversion, randomly selects an arc aij from A, and then turns the direction for the arc if the inversion of the arc still forms a DAG. Through this operator, a new solution, Gc\{aij } U { aji} is constructed. The last operator is Move for two nodes Xi and Xj

whose parent sets are not empty, the operator, selects a parent node of these two nodes, Xk ∈Π (Xi) and Xl ∈ Π(Xij) (k ≠ l), then changes Xk with Xl if Xl ∈ (X \ Π (Xi) U{Xi}));

Xk ∈ (X \ Π (Xj) U{Xj})) and this move operator still forms a DAG. Namely, the operator simultaneously changes the parent sets of two nodes.

algorithm’s solution construction utilizes different neighbourhood than local search. The expectation is high that the local search updates a solution formed by an elephant group.

Structure learning Bayesian network solution area formed for each potential DAG. Every elephant group inside the swarm initiates a possible solution which represents as a DAG having empty arcs. An elephant later examines the exploration area for finding the approximately near-optimal or optimal solution, which is known as the BDeu score. Equation (2-34) is used to calculate the BDeu score as the goal function of the optimization. The exploration aims for obtaining a higher BDeu score for the network structure. All initial solutions produced through iterative operations. Starting with a blank graph (G0), the arcs are appended one after another, provided that they not included in the current graph solution. The append operation performs if only if the score function of the new solution is higher than the current score and also the new solution satisfies the DAG constraint. This process continues until the quantity of the arcs equals the amount defined in advance. In the model, the solution starts assigning a population for each operator and picks the solution, which has a higher score function. Elephant group continues according to the selected operator until the process has performed a maximum number of iterations or the BDeu score does not increase any more.

Typically, the processes hold four separate operations in local optimization: Deletion, Addition, Reversion, Movement. The first three are simple operations within this domain, involve just replacing an individual edge every time from a competitor solution. It allows the inclusion of a comparatively small area near the solution. With every movement operation, on the other hand, the existing edges change the set of parents, which can make a moderately significant modification for the current solution. Therefore, if the solution not changed after applying simple operators, the move operator may improve it. Walking is the primary force utilizing the chosen operation in local optimization, which becomes further widespread while an elephant approaches the desirable solution. Walking directions, the switch with various local optimization operators, grows extra widespread as an elephant moves continuously from a solution through exploration toward a better one. Therefore, the current velocity renewed by

either elephant's best global or best local solution based on the (p) value. The ESWSA based on the probability value p can switch off from global search into local or from local to global.

The velocity of ESWSA is renewed based on the current best position of the elephant in the local search.

On the other hand, the global velocity depends on the best global solution concerning elephants in a global search, near a global best position. As shown in Figure 3.17, an elephant G0, which describes a DAG with arcs, tries reversion, move, addition, and deletion, and reaches new solutions G1, G2, G3, and G4, respectively. Assuming the best score is in G3, it will select, and the elephant will proceed to examine some similar process to get G+3 as the new solution.

**Algorithm: Structure Learning of Bayesian Network based on elephant swarm water search ****algorithm **** **

**INPUT: - datasets**** **

* NE: number of Elephant swarm *
*D: search space dimension *
*P: the switching probability p *

*Search range: the search space border *

*t**max: **maximum number of iteration number;**X**max: **upper boundary, and X**min**:- lower *
*boundary *

**OUTPUT: - learning Bayesian Network**** **

(1) *The initialized empty structure and initialize parameters of ESWSA algorithm *
*(dimension space D, size of population NE, the switching probability p, the *
*number of iteration number, upper boundary and lower boundary, (*𝐺_{𝑏𝑒𝑠𝑡,𝑖,𝑑}^{𝑡} * ). *

*and X**max** > X**min**.*

(2) *Set the velocity and position for all Elephant randomly. Comparing each *
*elephant by BDe score function, and find the best in the current position *
*(*𝑃_{𝑏𝑒𝑠𝑡,𝑖,𝑑}^{𝑡} * ).*

(3) *Assign the value of w*^{t }*according to the weight update using Equations (3-13) *
*or (3-14). *

(4) *Find a new best position by comparing the BDeu score function of each *
*elephant.*

(5) *If rand>p, update elephant velocity (V**i, d**) using equation (3-10).*

*(6)* *else rand*≤* p update elephant velocity using equation (3-11). *

*(7)* *Update the position X**i, d** using equation (3-12). *

*(8)* *Evaluate BDeu score function of the new position (*𝑋_{𝑖,𝑑}^{𝑡} *) *

(9) *If current position (*𝑋_{𝑖,𝑑}^{𝑡} * ) is better than the best position (*𝑃_{𝑏𝑒𝑠𝑡,𝑖,𝑑}^{𝑡} * ) then *
*update the best position by ((*𝑃_{𝑏𝑒𝑠𝑡,𝑖,𝑑}^{𝑡} * )= (*𝑋_{𝑖,𝑑}^{𝑡} * )) *

(10) *If ((*𝐺_{𝑏𝑒𝑠𝑡,𝑖,𝑑}^{𝑡} * )< current position then update the best solution for global by *
*(*𝐺_{𝑏𝑒𝑠𝑡,𝑖,𝑑}^{𝑡} *=(X**i,d** ))*

*(11) The best score value and solution saved. *

(12) *If X**min** *≥* X**max**, stop the iteration process, and the results are present. If not, *
*move into Step 5.*

(13) *Return the maximum BDe score.*

**Figure 3.16** ESWSA Algorithm for Structure learning Bayesian Network.

If the BDeu score of G+3 is higher Than that of G+1, it will continue to perform the
corresponding operator. The operations will repeat until the BDeu score stabilizes, or iteration
loop reaches the maximum. In the whole process, the elephant selects among the directions** **
using deletion, addition, movement and reversion operations.

**Figure 3.17** Water searching steps for one Elephant [10]