RELIABILITY: ASYNCHRONOUS ACTIVE LEARNING¶
This example showcases asynchronous learning in UQ[py]Lab. This feature is useful when the user wishes to carry out the required model evaluations outside of UQ[py]Lab.
In this example, active learning is carried out without the definition of a computational model. UQ[py]Lab therefore only returns the model evaluations required to enrich the experimental design, without executing them. The user can perform their evaluation outside UQ[py]Lab and/or python, and resume the analysis once they become available.
Package imports¶
from uqpylab import sessions
import numpy as np
Start a remote UQCloud session¶
# Start the session
mySession = sessions.cloud()
# (Optional) Get a convenient handle to the command line interface
uq = mySession.cli
# Reset the session
mySession.reset()
Processing .
.
done! uqpylab.sessions :: INFO :: This is UQ[py]Lab, version 1.00, running on https://uqcloud.ethz.ch. UQ[py]Lab is free software, published under the open source BSD 3-clause license. To request special permissions, please contact: - Stefano Marelli (marelli@ibk.baug.ethz.ch). A new session (05c1f45fed224dff824417c42f047374) started.
uqpylab.sessions :: INFO :: Reset successful.
Set the random seed for reproducibility¶
uq.rng(100,'twister');
PROBABILISTIC INPUT MODEL¶
The probabilistic input model consists of two independent and identically-distributed standard Gaussian random variables:
$$X_i \sim \mathcal{N}(0, 1), \quad i = 1, 2$$
Specify the probabilistic model for the two input random variables
InputOpts = {
"Marginals": [
{"Name": "X1",
"Type": "Gaussian",
"Parameters": [0, 1]
},
{"Name": "X2",
"Type": "Gaussian",
"Parameters": [0, 1]
}
]
}
Create the INPUT object based on the specified marginals:
myInput = uq.createInput(InputOpts)
STRUCTURAL RELIABILITY¶
Failure event is defined as $g(\mathbf{x}) \leq 0$. The failure probability is then defined as $P_f = P[g(\mathbf{x})\leq 0]$.
In this example, the limit-state function g is not defined in UQLab. Instead, the samples to evaluate to enrich the experimental design $x^\ast$ are returned by the active learning algorithm. The user then evaluates them externally before resuming the analysis. For illustration purposes, only 3 iterations of the algorithm are performed here.
Initial set-up¶
Select the Reliability module and the active learning method
ALROptions = {
"Type": "Reliability",
"Method": "ALR"
}
Specify the size of the iniitial experimental design
ALROptions["ALR"] = {
"IExpDesign": {
"N": 4
}
}
Enable the asynchronous learning feature
ALROptions["Async"] = {
"Enable": True
}
Allow asynchronous learning also for the initial experimental design
ALROptions["Async"]["InitED"] = True
Run the active learning reliability analysis
myALRAnalysis = uq.createAnalysis(ALROptions)
The execution stops right before the initial experimental design is evaluated
Evaluating the initial ED¶
This first set of samples consists in the 4 initial experimental design points.
They are saved in myALRAnalysis["Results"]["NextSample"].
Xnext = np.array(myALRAnalysis["Results"]["NextSample"])
Ynext = 2.5 - (Xnext[:,0]+ Xnext[:,1])/np.sqrt(2) + 0.1 * (Xnext[:,0] - Xnext[:,1])**2
Resume the analysis by submitting the newly evaluated samples
myALRAnalysis = uq.resumeAnalysis(Ynext.tolist())
Processing .
done!
Resuming the analysis¶
The next sample is retrieved and evaluted again
Xnext = np.array(myALRAnalysis["Results"]["NextSample"], ndmin=2)
Ynext = 2.5 - (Xnext[:,0]+ Xnext[:,1])/np.sqrt(2) + 0.1 * (Xnext[:,0] - Xnext[:,1])**2
Resume the analysis by submitting the newly evaluated samples
myALRAnalysis = uq.resumeAnalysis(Ynext.tolist())
Processing .
done!
Retrieve the next sample to evalute
Xnext = np.array(myALRAnalysis["Results"]["NextSample"], ndmin=2)
Ynext = 2.5 - (Xnext[:,0]+ Xnext[:,1])/np.sqrt(2) + 0.1 * (Xnext[:,0] - Xnext[:,1])**2
Resume the analysis by submitting the newly evaluated samples
myALRAnalysis = uq.resumeAnalysis(Ynext.tolist())
Processing .
done!
In this example, convergence has not yet been achieved. However, it is possible to print and display the current state of the analysis.
Print out a report of the results
uq.print(myALRAnalysis)
--------------------------------------------------- Active learning reliability --------------------------------------------------- Pf 1.3546e-03 Beta 2.9989 CoV 0.0194 ModelEvaluations 6 PfCI [1.3032e-03 1.4060e-03] BetaCI [2.9876e+00 3.0107e+00] PfMinus/Plus [1.2186e-03 1.5154e-03] ---------------------------------------------------
Visualize the results of the analysis
uq.display(myALRAnalysis);
Terminate the remote UQCloud session¶
mySession.quit()
uqpylab.sessions :: INFO :: Session 05c1f45fed224dff824417c42f047374 terminated.
True