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

Function test_update_da

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

Source from the content-addressed store, hash-verified

136
137
138def test_update_da(ref_dirs, evaluator):
139 problem = C1DTLZ3(n_var=12, n_obj=3)
140 for i in range(2):
141 ca_x = np.loadtxt(load_to_test_resource('ctaea', 'c1dtlz3', f'case{i + 1}', 'preCA.x'))
142 CA = Population.new(X=ca_x)
143 evaluator.eval(problem, CA)
144
145 da_x = np.loadtxt(load_to_test_resource('ctaea', 'c1dtlz3', f'case{i + 1}', 'preDA.x'))
146 DA = Population.new(X=da_x)
147 evaluator.eval(problem, DA)
148
149 off_x = np.loadtxt(load_to_test_resource('ctaea', 'c1dtlz3', f'case{i + 1}', 'offspring.x'))
150 off = Population.new(X=off_x)
151 evaluator.eval(problem, off)
152
153 survival = CADASurvival(ref_dirs)
154 mixed = Population.merge(CA, off)
155 survival.ideal_point = np.min(np.vstack((DA.get("F"), mixed.get("F"))), axis=0)
156
157 post_ca_x = np.loadtxt(load_to_test_resource('ctaea', 'c1dtlz3', f'case{i + 1}', 'postCA.x'))
158 CA = Population.new(X=post_ca_x)
159 evaluator.eval(problem, CA)
160
161 Hd = Population.merge(DA, off)
162 pDA = survival._updateDA(CA, Hd, 91)
163
164 true_S1 = [151, 35, 6, 63, 67, 24, 178, 106, 134, 172, 148, 159, 41,
165 173, 145, 77, 62, 40, 127, 61, 130, 27, 171, 115, 52, 176,
166 22, 75, 55, 87, 36, 149, 154, 47, 78, 170, 90, 15, 53, 175,
167 179, 165, 56, 89, 132, 82, 141, 39, 32, 25, 131, 14, 72, 65,
168 177, 140, 66, 143, 34, 81, 103, 99, 147, 168, 51, 26, 70, 94,
169 54, 97, 158, 107, 29, 120, 50, 108, 157, 11, 85, 174, 80, 0,
170 95, 13, 142, 101, 156, 19, 8, 98, 20]
171
172 true_S2 = [78, 173, 59, 21, 101, 52, 36, 94, 17, 20, 37, 96, 90, 129,
173 150, 136, 162, 70, 146, 75, 138, 154, 65, 179, 98, 32, 97,
174 11, 26, 107, 12, 128, 95, 170, 24, 171, 40, 180, 14, 44, 49,
175 43, 130, 23, 60, 79, 148, 62, 87, 56, 157, 73, 104, 45, 177,
176 74, 15, 152, 164, 28, 80, 113, 41, 33, 158, 57, 77, 34, 114,
177 118, 18, 54, 53, 145, 93, 115, 121, 174, 142, 39, 13, 105,
178 10, 69, 120, 55, 6, 153, 91, 137, 46]
179 if i == 0:
180 assert np.all(pDA == Hd[true_S1])
181 else:
182 assert np.all(pDA == Hd[true_S2])
183
184
185def test_update(ref_dirs, evaluator):

Callers

nothing calls this directly

Calls 8

_updateDAMethod · 0.95
C1DTLZ3Class · 0.90
load_to_test_resourceFunction · 0.90
CADASurvivalClass · 0.90
mergeMethod · 0.80
newMethod · 0.45
evalMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…