本文整理汇总了Python中openopt.NLP.x0方法的典型用法代码示例。如果您正苦于以下问题:Python NLP.x0方法的具体用法?Python NLP.x0怎么用?Python NLP.x0使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openopt.NLP
的用法示例。
在下文中一共展示了NLP.x0方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: help
# 需要导入模块: from openopt import NLP [as 别名]
# 或者: from openopt.NLP import x0 [as 别名]
you should read help(NLP) for more details,
also reading /examples/nlp_1.py and other files from the directory is highly recommended
Each class has some expected arguments
e.g. for NLP it's f and x0 - objective function and start point
thus using NLP(myFunc, myStartPoint) will assign myFunc to f and myStartPoint to x0 prob fields
alternatively, you could use it as kwargs, possibly along with some other kwargs:
"""
p = NLP(x0=15, f=lambda x: x ** 2 - 0.4, df=lambda x: 2 * x, iprint=0, plot=1)
# after the problem is assigned, you could turn the parameters,
# along with some other that have been set as defaults:
p.x0 = 0.15
p.plot = 0
def f(x):
return x if x > 0 else x ** 2
p.f = f
# At last, you can modify any prob parameters in minimize/maximize/solve/manage functions:
r = p.minimize("ralg", x0=-1.5, iprint=-1, plot=1, color="r")
# or
# r = p.manage('ralg', start = False, iprint = 0, x0 = -1.5)