# Educational Competition Optimizer

The Educational Competition Optimizer (ECO) is an optimization algorithm inspired by competition dynamics in educational systems and proposed by Junbo Lian et al..

### Inspiration

Competition is a fundamental part of the modern educational landscape, where students continuously strive to improve their abilities and meet the stringent demands of academic institutions. This competitive environment mirrors the nature of optimization problems, where a search space must be explored to find the optimal solution. As the level of education rises, so does the intensity of the competition. The ECO algorithm simulates this competitive process, using principles of elite retention, greedy selection, and a balanced approach between exploration and exploitation.
The concept of ECO draws its inspiration from these educational competitions, offering a fresh perspective on metaheuristic optimization algorithms by metaphorically linking education and problem-solving. As a result, it provides a framework to develop better strategies for addressing complex real-world optimization problems.

### Population Initialization

To simulate the chaotic environment caused by a lack of education, the ECO algorithm uses logistic chaos mapping for population initialization. The logistic equation models chaotic systems and can be expressed as follows:
$x_{i}=\alpha \cdot x_{i-1}\cdot (1-x_{i-1}),\quad 0\leq x_{0}\leq 1,\quad \alpha =4$
Here, $X_{i}$ represents the value at iteration $i$, and $X_{i-1}$ represents the value at the previous iteration. These values are mapped onto the search space using:
$X_{i}=lb+(ub-lb)\cdot X_{i}$
Where $lb$ and $ub$ are the search space boundaries.

### ECO Algorithm Stages

The ECO algorithm is structured to simulate three main educational stages: primary school, middle school, and high school. Each stage models a different level of competition and complexity in problem-solving.

#### Stage 1: Primary School

In this stage, schools determine their locations based on the average position of the population, and students aim for the closest school. The top 20% of the population is categorized as schools, while the remaining 80% are students. These roles are dynamic and change throughout the iterations.
The mathematical behavior of schools and students is governed by the following equations:
${\text{Schools: }}X_{i}^{t+1}=X_{i}^{t}+w\cdot (X_{\text{imean}}^{t}-X_{i}^{t})\cdot {\text{Levy}}(dim)$
${\text{Students: }}X_{i}^{t+1}=X_{i}^{t}+w\cdot ({\text{close}}(X_{i}^{t})-X_{i}^{t})\cdot {\text{randn}}$
$w=0.1\cdot ln(2-t/Max_{\text{iter}})$
Where $X_{i}^{t}$ denotes the current position, $X_{\text{mean}}^{t}$ is the average position, and $w$ is the adaptive step size.
Average vector position $X_{mean}^{t}$ & Average position $X_{imean}^{t}$: $X_{mean}^{t}$ represents the average position of each element of the vector for the $i_{th}$ school in the $t_{th}$ round of iteration. $X_{imean}^{t}$ denotes the average position of the current swarm, denoted as $X_{imean}^{t}$.

#### Stage 2: Middle School

At this stage, schools take into account both the average and optimal locations of the population. The top 10% of the population is designated as schools, while the rest remain students. Academic competition intensifies, and students’ motivation and patience are modeled by variables $P$ and $E$, respectively.
The equations governing this stage are as follows:
$P=4\cdot {\text{randn}}\cdot \left(1-{\frac {i}{\text{Max iter}}}\right)$
$E={\frac {\pi }{P}}\cdot {\frac {i}{\text{Max iter}}}$
${\text{Schools: }}X_{i}^{t+1}=X_{i}^{t}+\left(X_{\text{best}}^{t}-X_{\text{mean}}^{t}\right)\cdot \exp \left({\frac {i}{\text{Max iter}}}-1\right)\cdot {\text{Levy}}({\text{dim}})$
${\text{Students: }}X_{i}^{t+1}={\begin{cases}X_{i}^{t}-w\cdot {\text{close}}(X_{i}^{t})-P\cdot \left(E\cdot w\cdot {\text{close}}(X_{i}^{t})-X_{i}^{t}\right),&R_{1}<H\\X_{i}^{t}-w\cdot {\text{close}}(X_{i}^{t})-P\cdot \left(w\cdot {\text{close}}(X_{i}^{t})-X_{i}^{t}\right),&R_{1}\geq H\end{cases}}$
Schools and students update their positions using these parameters, with schools focusing on the best location and students competing for the closest available school.The talent values of different students are simulated using the random number $R_{1}$, which takes on a value within the range of [0, 1].

#### Stage 3: High School

At the high school level, schools adopt a meticulous approach to selecting their teaching locations. They consider not only the average population location but also the best and worst locations within their population. This comprehensive assessment helps them make informed decisions about their educational location. In contrast, all students converge toward the current best location, which is identified as the best high school location. The optimization process motivates every student to strive for admission to this best high school. During each iteration, the top 10% of the population, determined by their fitness, are designated schools, while the remaining 90% continue as students. The following mathematical expressions represent this behavior.
${\text{Schools: }}X_{i}^{t+1}=X_{i}^{t}+\left(X_{\text{best}}^{t}-X_{i}^{t}\right)\cdot {\text{randn}}-\left(X_{\text{best}}^{t}-X_{i}^{t}\right)\cdot {\text{randn}}$
${\text{Students: }}X_{i}^{t+1}={\begin{cases}X_{\text{best}}^{t}-P\cdot \left(E\cdot X_{\text{best}}^{t}-X_{i}^{t}\right),&R_{2}<H\\X_{\text{best}}^{t}-P\cdot \left(X_{\text{best}}^{t}-X_{i}^{t}\right),&R_{2}\geq H\end{cases}}$
The talents of individual students are represented by a random number denoted as $R_{2}$, which falls within the range of $[0,1]$.

### Pseudo-code of ECO Algorithm

Below is the simplified pseudo-code for the ECO algorithm, outlining its steps:
In the ECO algorithm, the optimization process begins with the random generation of a population of candidate solutions. Throughout iterative updates, ECO's search strategy explores regions near the optimal solution and adjusts each solution's position based on the current best solution. ECO is designed to maintain a balance between exploration and exploitation by introducing six different search strategies across three stages: primary school, middle school, and high school competitions, where schools and students interact at different levels to refine the search process.