Is there a way of seeing steps in importance sampling?

80 Views Asked by At

In the following code from Openturns FORM example:

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)

Create the output random vector Y=model(X)

Y = ot.CompositeRandomVector(model, inputVector)

Create the event Y > 4

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

Create a FORM algorithm

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

Run the algorithm and retrieve the result

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

Create the post analytical importance sampling simulation algorithm

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

result = algo.getResult()

Create the post analytical controlled importance sampling simulation algorithm

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

Is it possible to see the values of X1, X2 and Y during the optimisation?

I am hoping to implement this on a simulation that takes a few minutes to run- so would be good to watch the steps of the optimisation process.

Thanks :-)

1

There are 1 best solutions below

0
On

You just have to set the verbose flag in the solver:

solver.setVerbose(True)

then you will see how Cobyla steps during the finding of the design point:

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
...

Note that the optimization is done in the standard space. You will have to implement logs in your code wrapper if you want to get the same information but in the physical space.

Cheers

Régis