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

Function test_association

tests/algorithms/test_ctaea.py:24–52  ·  view source on GitHub ↗
(ref_dirs, evaluator)

Source from the content-addressed store, hash-verified

22
23
24def test_association(ref_dirs, evaluator):
25 problem = C1DTLZ3(n_var=12, n_obj=3)
26 ca_x = np.loadtxt(load_to_test_resource('ctaea', 'c1dtlz3', 'case3', 'preCA.x'))
27 CA = Population.new(X=ca_x)
28 evaluator.eval(problem, CA)
29
30 da_x = np.loadtxt(load_to_test_resource('ctaea', 'c1dtlz3', 'case3', 'preDA.x'))
31 DA = Population.new(X=da_x)
32 evaluator.eval(problem, DA)
33
34 off_x = np.loadtxt(load_to_test_resource('ctaea', 'c1dtlz3', 'case3', 'offspring.x'))
35 off = Population.new(X=off_x)
36 evaluator.eval(problem, off)
37
38 true_assoc = np.loadtxt(load_to_test_resource('ctaea', 'c1dtlz3', 'case3', 'feasible_rank0.txt'))
39 true_niche = true_assoc[:, 1]
40 true_id = true_assoc[:, 0]
41 sorted_id = np.argsort(true_id)
42
43 survival = CADASurvival(ref_dirs)
44 mixed = Population.merge(CA, off)
45 survival.ideal_point = np.min(np.vstack((DA.get("F"), mixed.get("F"))), axis=0)
46
47 fronts = NonDominatedSorting().do(mixed.get("F"), n_stop_if_ranked=len(ref_dirs))
48 I = np.concatenate(fronts)
49 niche, _ = survival._associate(mixed[I])
50 sorted_I = np.argsort(I)
51
52 assert (niche[sorted_I] == true_niche[sorted_id]).all()
53
54
55def test_update_ca(ref_dirs, evaluator):

Callers

nothing calls this directly

Calls 10

_associateMethod · 0.95
C1DTLZ3Class · 0.90
load_to_test_resourceFunction · 0.90
CADASurvivalClass · 0.90
NonDominatedSortingClass · 0.90
mergeMethod · 0.80
newMethod · 0.45
evalMethod · 0.45
getMethod · 0.45
doMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…