MCPcopy Create free account
hub / github.com/anyoptimization/pymoo / test_problems

Function test_problems

tests/problems/test_problems_wfg.py:11–32  ·  view source on GitHub ↗
(name, params)

Source from the content-addressed store, hash-verified

9@pytest.mark.parametrize('name', [f"wfg{k}" for k in range(1, 10)])
10@pytest.mark.parametrize('params', [(2, 6, 4), (3, 6, 4), (10, 20, 18)])
11def test_problems(name, params):
12 n_obj, n_var, k = params
13 problem = get_problem(name, n_var, n_obj, k)
14
15 X, F = load("problems", "WFG", f"{n_obj}obj", name.upper(), attrs=["x", "f"])
16 _F = problem.evaluate(X)
17
18 np.testing.assert_allclose(_F, F)
19
20 # this is not tested automatically
21 try:
22 optprobs_F = []
23 for x in X:
24 from optproblems.base import Individual
25 ind = Individual(phenome=x)
26 from_optproblems(problem).evaluate(ind)
27 optprobs_F.append(ind.objective_values)
28 optprobs_F = np.array(optprobs_F)
29
30 np.testing.assert_allclose(_F, optprobs_F)
31 except:
32 print("NOT MATCHING")
33
34
35

Callers

nothing calls this directly

Calls 6

get_problemFunction · 0.90
loadFunction · 0.90
IndividualClass · 0.85
from_optproblemsFunction · 0.85
evaluateMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…