0

在以下来自 Openturns FORM 示例的代码中:

import openturns as ot
model = ot.SymbolicFunction(['x1', 'x2'], ['x1^2+x2'])
R = ot.CorrelationMatrix(2)
R[0,1] = -0.6
inputDist = ot.Normal([0.,0.], R)
inputDist.setDescription(['X1', 'X2'])
inputVector = ot.RandomVector(inputDist)

创建输出随机向量 Y=model(X)

Y = ot.CompositeRandomVector(model, inputVector)

创建事件 Y > 4

threshold = 4.0
event = ot.ThresholdEvent(Y, ot.Greater(), threshold)

创建 FORM 算法

solver = ot.Cobyla()
startingPoint = inputDist.getMean()
algo = ot.FORM(solver, event, startingPoint)

运行算法并检索结果

algo.run()
result_form = algo.getResult()
print(result_form)

创建分析后重要性采样模拟算法

algo = ot.PostAnalyticalImportanceSampling(result_form)
algo.run()
print(algo.getResult())

result = algo.getResult()

创建分析后受控重要性采样模拟算法

algo = ot.PostAnalyticalControlledImportanceSampling(result_form)
algo.run()
print(algo.getResult())

在优化过程中是否可以看到 X1、X2 和 Y 的值?

我希望在需要几分钟才能运行的模拟中实现这一点——所以最好看看优化过程的步骤。

谢谢 :-)

4

1 回答 1

1

您只需在求解器中设置详细标志:

solver.setVerbose(True)

然后您将看到 Cobyla 在寻找设计点期间的步骤:

cobyla: the initial value of RHO is 1.000000E-01 and PARMU is set to zero.
cobyla: NFVALS =    1, F = 0.000000E+00, MAXCV = 3.999990E+00
cobyla: X = 0.000000E+00   0.000000E+00
cobyla: NFVALS =    2, F = 5.000000E-03, MAXCV = 4.049990E+00
cobyla: X = 1.000000E-01   0.000000E+00
cobyla: NFVALS =    3, F = 5.000000E-03, MAXCV = 3.919990E+00
cobyla: X = 0.000000E+00   1.000000E-01
cobyla: increase in PARMU to 3.370787E-02
cobyla: NFVALS =    4, F = 5.000000E-03, MAXCV = 3.897541E+00
cobyla: X =-5.299989E-02   8.479983E-02
...

请注意,优化是在标准空间中完成的。如果您想在物理空间中获取相同的信息,则必须在代码包装器中实现日志。

干杯

雷吉斯

于 2021-07-27T10:00:17.443 回答