本文整理汇总了Python中openopt.NLP.getMaxResidual方法的典型用法代码示例。如果您正苦于以下问题:Python NLP.getMaxResidual方法的具体用法?Python NLP.getMaxResidual怎么用?Python NLP.getMaxResidual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openopt.NLP
的用法示例。
在下文中一共展示了NLP.getMaxResidual方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: in
# 需要导入模块: from openopt import NLP [as 别名]
# 或者: from openopt.NLP import getMaxResidual [as 别名]
if solver == "algencan":
p.gtol = 1e-2
elif solver == "ralg":
pass
# p.debug = 1
p.debug = 1
r = p.solve(solver)
for fn in ("h", "c"):
if not r.evals.has_key(fn):
r.evals[fn] = 0 # if no c or h are used in problem
results[solver] = (
r.ff,
p.getMaxResidual(r.xf),
r.elapsed["solver_time"],
r.elapsed["solver_cputime"],
r.evals["f"],
r.evals["c"],
r.evals["h"],
)
if PLOT:
subplot(2, 1, 1)
F0 = asscalar(p.f(p.x0))
lines.append(plot([0, 1e-15], [F0, F0], color=colors[j]))
if PLOT:
for i in range(2):
subplot(2, 1, i + 1)
legend(lines, solvers)
示例2: range
# 需要导入模块: from openopt import NLP [as 别名]
# 或者: from openopt.NLP import getMaxResidual [as 别名]
#############
colors = colors[:len(solvers)]
lines, results = [], {}
for j in range(len(solvers)):
solver = solvers[j]
color = colors[j]
p = NLP(objSIR.cost, theta, df=objSIR.sensitivity,lb = lb, ub = ub, ftol = 1e-6, maxFunEvals = 1e7, maxIter = 1220, plot = 1, color = color, iprint = 0, legend = [solvers[j]], show= False, xlabel='time', goal='minimum', name='nlp3')
if solver == 'algencan':
p.gtol = 1e-1
elif solver == 'ralg':
p.debug = 1
r = p.solve(solver, debug=1)
print 'c1 evals:', cc1, 'c2 evals:', cc2, 'c3 evals:', cc3
results[solver] = (r.ff, p.getMaxResidual(r.xf), r.elapsed['solver_time'], r.elapsed['solver_cputime'], r.evals['f'], r.evals['c'], r.evals['h'])
subplot(2,1,1)
F0 = asscalar(p.f(p.x0))
lines.append(plot([0, 1e-15], [F0, F0], color= colors[j]))
# for i in range(2):
# subplot(2,1,i+1)
# legend(solvers)
subplots_adjust(bottom=0.2, hspace=0.3)
xl = ['Solver f_opt MaxConstr Time CPUTime fEvals cEvals hEvals']
for i in range(len(results)):
xl.append((expandtabs(ljust(solvers[i], 16)+' \t', 15)+'%0.2f'% (results[solvers[i]][0]) + ' %0.1e' % (results[solvers[i]][1]) + (' %0.2f'% (results[solvers[i]][2])) + ' %0.2f '% (results[solvers[i]][3]) + str(results[solvers[i]][4]) + ' ' + rjust(str(results[solvers[i]][5]), 5) + expandtabs('\t' +str(results[solvers[i]][6]),8)))
xl = '\n'.join(xl)