def test_UseCaseMonteCarlo(self): problem = otb.ReliabilityProblem31() event = problem.getEvent() # Create a Monte Carlo algorithm experiment = ot.MonteCarloExperiment() algo = ot.ProbabilitySimulationAlgorithm(event, experiment) algo.setMaximumCoefficientOfVariation(0.01) algo.setBlockSize(int(1.0e3)) algo.setMaximumOuterSampling(int(1e3)) algo.run() # Retrieve results result = algo.getResult() computed_pf = result.getProbabilityEstimate() exact_pf = problem.getProbability() print("exact_pf=", exact_pf) print("computed_pf=", computed_pf) samplesize = result.getOuterSampling() * result.getBlockSize() alpha = 0.05 pflen = result.getConfidenceLength(1 - alpha) print("%.2f%% confidence interval = [%f,%f]" % ((1 - alpha) * 100, computed_pf - pflen / 2, computed_pf + pflen / 2)) print("Sample size : ", samplesize) atol = 1.0e2 / np.sqrt(samplesize) np.testing.assert_allclose(computed_pf, exact_pf, atol=atol)
def test_ReliabilityBenchmarkProblem31(self): problem = otb.ReliabilityProblem31() print(problem) # Check probability pf = problem.getProbability() pf_exacte = 0.00018 np.testing.assert_allclose(pf, pf_exacte, rtol=1.e-15) # Check function event = problem.getEvent() function = event.getFunction() X = [0.0, 0.0] Y = function(X) assert(type(Y) is ot.Point) np.testing.assert_allclose(Y[0], 2)
def ReliabilityBenchmarkProblemList(): """ Returns the list of reliability benchmark problems. Returns ------- problems : list A list of ReliabilityProblem. """ p8 = otb.ReliabilityProblem8() p14 = otb.ReliabilityProblem14() p22 = otb.ReliabilityProblem22() p24 = otb.ReliabilityProblem24() p25 = otb.ReliabilityProblem25() p28 = otb.ReliabilityProblem28() p31 = otb.ReliabilityProblem31() p33 = otb.ReliabilityProblem33() p35 = otb.ReliabilityProblem35() p38 = otb.ReliabilityProblem38() p53 = otb.ReliabilityProblem53() p55 = otb.ReliabilityProblem55() p54 = otb.ReliabilityProblem54() p57 = otb.ReliabilityProblem57() p75 = otb.ReliabilityProblem75() p89 = otb.ReliabilityProblem89() p107 = otb.ReliabilityProblem107() p110 = otb.ReliabilityProblem110() p111 = otb.ReliabilityProblem111() p63 = otb.ReliabilityProblem63() p91 = otb.ReliabilityProblem91() p60 = otb.ReliabilityProblem60() p77 = otb.ReliabilityProblem77() pFBS = otb.FourBranchSerialSystemReliability() pRS = otb.RminusSReliability() pBeam = otb.AxialStressedBeamReliability() problemslist = [ p8, p14, p22, p24, p25, p28, p31, p33, p35, p38, p53, p55, p54, p57, p75, p89, p107, p110, p111, p63, p91, p60, p77, pFBS, pRS, pBeam, ] return problemslist