本文整理汇总了Python中pele.optimize.LBFGS.set_state方法的典型用法代码示例。如果您正苦于以下问题:Python LBFGS.set_state方法的具体用法?Python LBFGS.set_state怎么用?Python LBFGS.set_state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pele.optimize.LBFGS
的用法示例。
在下文中一共展示了LBFGS.set_state方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_state
# 需要导入模块: from pele.optimize import LBFGS [as 别名]
# 或者: from pele.optimize.LBFGS import set_state [as 别名]
def test_state(self):
# do several minimization iterations
for i in xrange(10):
self.minimizer.one_iteration()
# get the state and save it
ret = self.minimizer.get_result()
state = self.minimizer.get_state()
x1 = ret.coords.copy()
# do several more iteration steps
for i in xrange(10):
self.minimizer.one_iteration()
# now make a new minimizer and do several iterations
minimizer2 = LBFGS(x1, self.pot)
minimizer2.set_state(state)
for i in xrange(10):
minimizer2.one_iteration()
# test that the two minimizers are in the same state
ret1 = self.minimizer.get_result()
ret2 = minimizer2.get_result()
self.assertEqual(ret1.energy, ret2.energy)
self.assertTrue((ret1.coords == ret2.coords).all())
state1 = self.minimizer.get_state()
state2 = minimizer2.get_state()
self.assertTrue((state1.y == state2.y).all())
self.assertTrue((state1.s == state2.s).all())
self.assertTrue((state1.rho == state2.rho).all())
self.assertTrue((state1.dXold == state2.dXold).all())
self.assertTrue((state1.dGold == state2.dGold).all())
self.assertEqual(state1.H0, state2.H0)
self.assertEqual(state1.k, state2.k)