# Embedded PSO for Solving FJSP on Embedded Environment (Industry 4.0 Era)
## 5 Proposed Technique: Embedded Two-Level PSO-FJSP
Particles are migrated from the \"followers sub-swarms\" to the \"leaders sub-swarm\" and from the \"followers sub-swarms\" to the \"worsts sub-swarm\". * A \"stopping process\" is added for swarm size reducing to response to the request to free memory or the CPU need (presented in Algorithm 2. * A \"wake-up process\" is used if there is no need (presented in Algorithm 3). Figure 4: Flowchart of the embedded two-level PSO (E2L-PSO). ```
Swarm initialization Divide the swarm into a sub-swarm: \"leaders sub-swarm\", \"followers sub-swarm\" and \"worsts sub-swarm\". \(Total_{\mathit{inactive}}=0\). for each iteration do for each swarm do for each particle do  Mapping phase (1) if(\(LB<X\mathit{subset}\)) then  Scheduling phase (2) \(X\mathit{best}\) and \(X\mathit{nbest}\) update else if(!stop-criteria) then  go to (1)  end if  end for  end for  Migrate particles that have best solutions from the \"followers sub-swarm\" to the \"leaders sub-swarm\"  Migrate particles that have worst solutions from the \"followers sub-swarm\" to the \"worsts sub-swarm\". if(\(need!=0\)) then  Calculate the number of particles to be stopped (\(p_{\mathit{inactive}}\)) \(Total_{\mathit{inactive}}=Total_{\mathit{inactive}}+p_{\mathit{inactive}}\). Stop process (\(p_{\mathit{inactive}}\)) else ifthe number of particles in the inactive mode! = 0 then  Wake up process (\(Total_{\mathit{inactive}}\))  end if  end for
```  
**Algorithm 1** Adaptive E2L-PSO steps  
```
```  
Put 50% of \(Total_{\mathit{inactive}}\) particles in an active mode by initializing according to the \(X\mathit{nbest}\) coordinates, adding it to the \"followers sub-swarm\". Put 50% of \(Total_{\mathit{inactive}}\) particles in an active mode by randomly initializing, adding it to the \"followers sub-swarm\". ```

**Algorithm 2** Stopping process

## 6 E2L-PSO--Experimental Results

Experiments were performed on micro-controller (STM32F407 VGT6) and a ARM-based mono-processor nano-computer (Raspberry Pi B+):STM32F407 VGT6 has a 32-bit ARM Cortex-M4F core, 1 MB Flash, 192 KB RAM. * Raspberry Pi B+ has a Broadcom BCM2837 SoC with a 1.2 GHz 64-bit quad-core ARM Cortex-A53 processor and 1 GB of RAM. ### Experiment Design

The following PSO versions were designed and tested in this study:

* Standard PSO (is developed for comparison purposes only). * The one-level PSO (is utilized for comparison purposes only). * The two-level PSO without use of lower bound (is utilized for comparison purposes only). * Embedded two-level PSO (E2L-PSO). Five sets of experiments are defined:
* Experiment #1 Basic PSO vs. one-level PSO [32] vs. E2L-PSO without reduction in STM32 F407 VGT6 and Raspberry Pi B+. Two comparison criteria are used: makespan as defined by Equation (3) and the used CPU time. * Scenario 1: \"Hard reduction\" 60% reduction in CPU usage. - Scenario 2: \"Medium reduction\" 40% reduction in CPU usage. - Scenario 3: \"Soft reduction\" 20% reduction in CPU usage. Under each scenario, we have three possible cases:
- The reduction request has arrived after only 20% of the iterations are completed (Request_Period = 20%). - The reduction request has arrived after 50% of the iterations are completed (Request_Period = 50%). - The reduction request has arrived after 90% of the iterations are completed (Request_Period = 90%). - Experiment #3 Adaptive E2L-PSO stability analyses. The statistical significance of the difference in performance between E2L-PSO without CPU reduction and adaptive E2L-PSO with medium reduction is determined using Mann-Whitney tests. - Experiment #4 Adaptive E2L-PSO robustness analyses. We use the definition presented in Equation (4), where the robustness is defined as the difference of the slack time (ST) and the makespan. - Experiment #5 Comparison with previous metaheuristics. These simulations pit the E2L-PSO against 11 different metaheuristics, 5 of which are PSO based and 6 of which are from other categories (GA, TS, etc.). All comparisons are made using the same global conditions as the prior study (iteration number, swarm size, etc.).