【问题标题】:Is there a way of seeing steps in importance sampling?有没有办法查看重要性抽样的步骤?
【发布时间】:2021-09-29 13:52:42
【问题描述】:

在以下来自 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的值?

我希望在需要几分钟才能运行的模拟中实现这一点 - 因此可以很好地观察优化过程的步骤。

谢谢:-)

【问题讨论】:

    标签: forms sampling reliability openturns


    【解决方案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
    ...
    

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

    干杯

    雷吉斯

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-01
      • 1970-01-01
      • 2021-06-20
      • 1970-01-01
      • 2019-08-26
      相关资源
      最近更新 更多