本文整理汇总了Python中openmdao.api.KrigingSurrogate.linearize方法的典型用法代码示例。如果您正苦于以下问题:Python KrigingSurrogate.linearize方法的具体用法?Python KrigingSurrogate.linearize怎么用?Python KrigingSurrogate.linearize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openmdao.api.KrigingSurrogate
的用法示例。
在下文中一共展示了KrigingSurrogate.linearize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_scalar_derivs
# 需要导入模块: from openmdao.api import KrigingSurrogate [as 别名]
# 或者: from openmdao.api.KrigingSurrogate import linearize [as 别名]
def test_scalar_derivs(self):
surrogate = KrigingSurrogate()
x = array([[0.], [1.], [2.], [3.]])
y = x.copy()
surrogate.train(x, y)
jac = surrogate.linearize(array([[0.]]))
assert_rel_error(self, jac[0][0], 1., 1e-3)
示例2: test_vector_derivs
# 需要导入模块: from openmdao.api import KrigingSurrogate [as 别名]
# 或者: from openmdao.api.KrigingSurrogate import linearize [as 别名]
def test_vector_derivs(self):
surrogate = KrigingSurrogate()
x = array([[a, b] for a, b in
itertools.product(linspace(0, 1, 10), repeat=2)])
y = array([[a+b, a-b] for a, b in x])
surrogate.train(x, y)
jac = surrogate.linearize(array([[0.5, 0.5]]))
assert_rel_error(self, jac, array([[1, 1], [1, -1]]), 1e-5)
示例3: test_vector_derivs
# 需要导入模块: from openmdao.api import KrigingSurrogate [as 别名]
# 或者: from openmdao.api.KrigingSurrogate import linearize [as 别名]
def test_vector_derivs(self):
surrogate = KrigingSurrogate()
n = 15
x = np.array([[a, b] for a, b in
itertools.product(np.linspace(0, 1, n), repeat=2)])
y = np.array([[a+b, a-b, a+2*b] for a, b in x])
surrogate.train(x, y)
jac = surrogate.linearize(np.array([[0.5, 0.5]]))
assert_rel_error(self, jac, np.array([[1, 1], [1, -1], [1, 2]]), 5e-4)