

def test_multifidelity_warm_start(self):
    mm = MultiFiMetaModel(nfi=2)
    mm.add_param('x', 0.0)
    surr = MockSurrogate()
    mm.add_output('y', 0.0, surrogate=surr)
    mm.warm_restart = True
    prob = Problem(Group())
    prob.root.add('mm', mm)
    prob.setup(check=False)
    prob['mm.train:x'] = [0.0, 0.4, 1.0]
    prob['mm.train:x_fi2'] = [0.1, 0.2, 0.3, 0.5, 0.6]
    prob['mm.train:y'] = [1.0, 1.4, 2.0]
    prob['mm.train:y_fi2'] = [1.1, 1.2, 1.3, 1.5, 1.6]
    prob.run()
    expected_xtrain = [np.array([[0.0], [0.4], [1.0]]), np.array([[0.1], [0.2], [0.3], [0.5], [0.6]])]
    expected_ytrain = [np.array([[1.0], [1.4], [2.0]]), np.array([[1.1], [1.2], [1.3], [1.5], [1.6]])]
    np.testing.assert_array_equal(surr.xtrain[0], expected_xtrain[0])
    np.testing.assert_array_equal(surr.xtrain[1], expected_xtrain[1])
    np.testing.assert_array_equal(surr.ytrain[0], expected_ytrain[0])
    np.testing.assert_array_equal(surr.ytrain[1], expected_ytrain[1])
    prob['mm.train:x'] = []
    prob['mm.train:y'] = []
    prob['mm.train:x_fi2'] = [2.0]
    prob['mm.train:y_fi2'] = [1.0]
    mm.train = True
    prob.run()
    expected_xtrain = [np.array([[0.0], [0.4], [1.0]]), np.array([[0.1], [0.2], [0.3], [0.5], [0.6], [2.0]])]
    expected_ytrain = [np.array([[1.0], [1.4], [2.0]]), np.array([[1.1], [1.2], [1.3], [1.5], [1.6], [1.0]])]
    np.testing.assert_array_equal(surr.xtrain[0], expected_xtrain[0])
    np.testing.assert_array_equal(surr.xtrain[1], expected_xtrain[1])
    np.testing.assert_array_equal(surr.ytrain[0], expected_ytrain[0])
    np.testing.assert_array_equal(surr.ytrain[1], expected_ytrain[1])
    prob['mm.train:x'] = [3.0]
    prob['mm.train:x_fi2'] = [3.0]
    prob['mm.train:y'] = [4.0]
    prob['mm.train:y_fi2'] = [4.0]
    mm.train = True
    prob.run()
    expected_xtrain = [np.array([[0.0], [0.4], [1.0], [3.0]]), np.array([[0.1], [0.2], [0.3], [0.5], [0.6], [2.0], [3.0]])]
    expected_ytrain = [np.array([[1.0], [1.4], [2.0], [4.0]]), np.array([[1.1], [1.2], [1.3], [1.5], [1.6], [1.0], [4.0]])]
    np.testing.assert_array_equal(surr.xtrain[0], expected_xtrain[0])
    np.testing.assert_array_equal(surr.xtrain[1], expected_xtrain[1])
    np.testing.assert_array_equal(surr.ytrain[0], expected_ytrain[0])
    np.testing.assert_array_equal(surr.ytrain[1], expected_ytrain[1])

dataset/ETHPy150Open OpenMDAO/OpenMDAO/openmdao/components/test/test_multifi_meta_model.py MultiFiMetaModelTestCase.test_multifidelity_warm_start/original