Skip to content

Commit

Permalink
Update space for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thieu1995 committed Oct 31, 2023
1 parent 146b743 commit 462fa7e
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 19 deletions.
5 changes: 3 additions & 2 deletions tests/bio_based/test_WHO.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
# Github: https://github.com/thieu1995 %
# --------------------------------------------------%

from mealpy import FloatVar, WHO, Optimizer
import numpy as np
import pytest

from mealpy import FloatVar, WHO, Optimizer


@pytest.fixture(scope="module") # scope: Call only 1 time at the beginning
def problem():
Expand All @@ -23,7 +24,7 @@ def objective_function(solution):


def test_BaseWHO_results(problem):
model = WHO.OriginalWHO(epoch=10, pop_size=50, n_explore_step = 3, n_exploit_step = 3, eta = 0.15, p_hi = 0.9,
model = WHO.OriginalWHO(epoch=10, pop_size=50, n_explore_step=3, n_exploit_step=3, eta=0.15, p_hi=0.9,
local_alpha=0.9, local_beta=0.3, global_alpha=0.2, global_beta=0.8, delta_w=2.0, delta_c=2.0)
g_best = model.solve(problem)
assert isinstance(model, Optimizer)
Expand Down
4 changes: 2 additions & 2 deletions tests/evolutionary_based/test_GA.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
# Github: https://github.com/thieu1995 %
# --------------------------------------------------%

from mealpy import FloatVar, GA, Optimizer
import numpy as np
import pytest

from mealpy import FloatVar, GA, Optimizer


@pytest.fixture(scope="module") # scope: Call only 1 time at the beginning
def problem():
Expand All @@ -31,4 +32,3 @@ def test_GA_results(problem):
assert isinstance(model, Optimizer)
assert isinstance(g_best.solution, np.ndarray)
assert len(g_best.solution) == len(model.problem.lb)

5 changes: 3 additions & 2 deletions tests/swarm_based/test_ABC.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
# Github: https://github.com/thieu1995 %
# --------------------------------------------------%

from mealpy import FloatVar, ABC, Optimizer
import numpy as np
import pytest

from mealpy import FloatVar, ABC, Optimizer


@pytest.fixture(scope="module") # scope: Call only 1 time at the beginning
def problem():
Expand All @@ -25,7 +26,7 @@ def objective_function(solution):

def test_ABC_results(problem):
models = [
ABC.OriginalABC(epoch=10, pop_size=50, couple_bees=(16, 4), patch_variables=(5.0, 0.985), sites=(3, 1))
ABC.OriginalABC(epoch=10, pop_size=50, n_limits=50)
]
for model in models:
g_best = model.solve(problem)
Expand Down
3 changes: 2 additions & 1 deletion tests/swarm_based/test_ACOR.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
# Github: https://github.com/thieu1995 %
# --------------------------------------------------%

from mealpy import FloatVar, ACOR, Optimizer
import numpy as np
import pytest

from mealpy import FloatVar, ACOR, Optimizer


@pytest.fixture(scope="module") # scope: Call only 1 time at the beginning
def problem():
Expand Down
3 changes: 2 additions & 1 deletion tests/swarm_based/test_ALO.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
# Github: https://github.com/thieu1995 %
# --------------------------------------------------%

from mealpy import FloatVar, ALO, Optimizer
import numpy as np
import pytest

from mealpy import FloatVar, ALO, Optimizer


@pytest.fixture(scope="module") # scope: Call only 1 time at the beginning
def problem():
Expand Down
7 changes: 4 additions & 3 deletions tests/swarm_based/test_BFO.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
# Github: https://github.com/thieu1995 %
# --------------------------------------------------%

from mealpy import FloatVar, BFO, Optimizer
import numpy as np
import pytest

from mealpy import FloatVar, BFO, Optimizer


@pytest.fixture(scope="module") # scope: Call only 1 time at the beginning
def problem():
Expand All @@ -25,8 +26,8 @@ def objective_function(solution):

def test_BFO_results(problem):
models = [
BFO.OriginalBFO(epoch=10, pop_size=50, Ci = 0.01, Ped = 0.25, Nc = 5, Ns = 4, d_attract=0.1, w_attract=0.2, h_repels=0.1, w_repels=10),
BFO.ABFO(epoch=10, pop_size=50, C_s=0.1, C_e=0.001, Ped = 0.01, Ns = 4, N_adapt = 2, N_split = 40),
BFO.OriginalBFO(epoch=10, pop_size=50, Ci=0.01, Ped=0.25, Nc=5, Ns=4, d_attract=0.1, w_attract=0.2, h_repels=0.1, w_repels=10),
BFO.ABFO(epoch=10, pop_size=50, C_s=0.1, C_e=0.001, Ped=0.01, Ns=4, N_adapt=2, N_split=40),
]
for model in models:
g_best = model.solve(problem)
Expand Down
5 changes: 3 additions & 2 deletions tests/swarm_based/test_BSA.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
# Github: https://github.com/thieu1995 %
# --------------------------------------------------%

from mealpy import FloatVar, BSA, Optimizer
import numpy as np
import pytest

from mealpy import FloatVar, BSA, Optimizer


@pytest.fixture(scope="module") # scope: Call only 1 time at the beginning
def problem():
Expand All @@ -25,7 +26,7 @@ def objective_function(solution):

def test_BSA_results(problem):
models = [
BSA.OriginalBSA(epoch=10, pop_size=50, ff = 10, pff = 0.8, c1 = 1.5, c2 = 1.5, a1 = 1.0, a2 = 1.0, fc = 0.5)
BSA.OriginalBSA(epoch=10, pop_size=50, ff=10, pff=0.8, c1=1.5, c2=1.5, a1=1.0, a2=1.0, fc=0.5)
]
for model in models:
g_best = model.solve(problem)
Expand Down
5 changes: 3 additions & 2 deletions tests/swarm_based/test_CSO.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
# Github: https://github.com/thieu1995 %
# --------------------------------------------------%

from mealpy import FloatVar, CSO, Optimizer
import numpy as np
import pytest

from mealpy import FloatVar, CSO, Optimizer


@pytest.fixture(scope="module") # scope: Call only 1 time at the beginning
def problem():
Expand All @@ -25,7 +26,7 @@ def objective_function(solution):

def test_CSO_results(problem):
models = [
CSO.OriginalCSO(epoch=10, pop_size=50, mixture_ratio = 0.15, smp = 5, spc = False, cdc = 0.8, srd = 0.15, c1 = 0.4, w_min = 0.4, w_max = 0.9)
CSO.OriginalCSO(epoch=10, pop_size=50, mixture_ratio=0.15, smp=5, spc=False, cdc=0.8, srd=0.15, c1=0.4, w_min=0.4, w_max=0.9)
]
for model in models:
g_best = model.solve(problem)
Expand Down
5 changes: 3 additions & 2 deletions tests/swarm_based/test_EHO.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
# Github: https://github.com/thieu1995 %
# --------------------------------------------------%

from mealpy import FloatVar, EHO, Optimizer
import numpy as np
import pytest

from mealpy import FloatVar, EHO, Optimizer


@pytest.fixture(scope="module") # scope: Call only 1 time at the beginning
def problem():
Expand All @@ -25,7 +26,7 @@ def objective_function(solution):

def test_EHO_results(problem):
models = [
EHO.OriginalEHO(epoch=10, pop_size=50, alpha = 0.5, beta = 0.5, n_clans = 5)
EHO.OriginalEHO(epoch=10, pop_size=50, alpha=0.5, beta=0.5, n_clans=5)
]
for model in models:
g_best = model.solve(problem)
Expand Down
5 changes: 3 additions & 2 deletions tests/swarm_based/test_FA.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
# Github: https://github.com/thieu1995 %
# --------------------------------------------------%

from mealpy import FloatVar, FA, Optimizer
import numpy as np
import pytest

from mealpy import FloatVar, FA, Optimizer


@pytest.fixture(scope="module") # scope: Call only 1 time at the beginning
def problem():
Expand All @@ -25,7 +26,7 @@ def objective_function(solution):

def test_FA_results(problem):
models = [
FA.OriginalFA(epoch=10, pop_size=50, max_sparks = 50, p_a = 0.04, p_b = 0.8, max_ea = 40, m_sparks = 50)
FA.OriginalFA(epoch=10, pop_size=50, max_sparks=50, p_a=0.04, p_b=0.8, max_ea=40, m_sparks=50)
]
for model in models:
g_best = model.solve(problem)
Expand Down

0 comments on commit 462fa7e

Please sign in to comment.