def test_ReliabilityBenchmarkMetaAlgorithm(self): maximumEvaluationNumber = 1000 maximumAbsoluteError = 1.0e-3 maximumRelativeError = 1.0e-3 maximumResidualError = 1.0e-3 maximumConstraintError = 1.0e-3 nearestPointAlgorithm = ot.AbdoRackwitz() nearestPointAlgorithm.setMaximumEvaluationNumber( maximumEvaluationNumber) nearestPointAlgorithm.setMaximumAbsoluteError(maximumAbsoluteError) nearestPointAlgorithm.setMaximumRelativeError(maximumRelativeError) nearestPointAlgorithm.setMaximumResidualError(maximumResidualError) nearestPointAlgorithm.setMaximumConstraintError(maximumConstraintError) problem = otb.ReliabilityProblem8() metaAlgorithm = otb.ReliabilityBenchmarkMetaAlgorithm(problem) benchmarkResult = metaAlgorithm.runFORM(nearestPointAlgorithm) print(benchmarkResult.summary()) benchmarkResult = metaAlgorithm.runSORM(nearestPointAlgorithm) print(benchmarkResult.summary()) benchmarkResult = metaAlgorithm.runLHS(maximumOuterSampling=10000) print(benchmarkResult.summary()) benchmarkResult = metaAlgorithm.runMonteCarlo( maximumOuterSampling=10000) print(benchmarkResult.summary()) benchmarkResult = metaAlgorithm.runFORMImportanceSampling( nearestPointAlgorithm) print(benchmarkResult.summary()) benchmarkResult = metaAlgorithm.runSubsetSampling() print(benchmarkResult.summary())
def test_RP8Function(self): problem = otbenchmark.ReliabilityProblem8() event = problem.getEvent() inputVector = event.getAntecedent() distribution = inputVector.getDistribution() referencePoint = distribution.getMean() drawEvent = otbenchmark.DrawEvent(event) i = 3 j = 4 gCC34 = drawEvent.buildCrossCutFunction(i, j) X = [referencePoint[i], referencePoint[j]] y1 = gCC34(X) print("X=", X, "y1=", y1) np.testing.assert_almost_equal(y1, [270.0])
def test_ReliabilityBenchmarkProblem8(self): problem = otb.ReliabilityProblem8() print(problem) # Check probability pf = problem.getProbability() pf_exacte = 0.000784 np.testing.assert_allclose(pf, pf_exacte, rtol=1.0e-15) # Check function event = problem.getEvent() function = event.getFunction() X = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] Y = function(X) assert type(Y) is ot.Point np.testing.assert_allclose(Y[0], 0.0)
def test_UseCase(self): problem = otb.ReliabilityProblem8() event = problem.getEvent() # Create a Monte Carlo algorithm experiment = ot.MonteCarloExperiment() algo = ot.ProbabilitySimulationAlgorithm(event, experiment) algo.setMaximumCoefficientOfVariation(0.05) algo.setMaximumOuterSampling(int(1e5)) 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() print("Sample size : ", samplesize) atol = 1.0 / np.sqrt(samplesize) np.testing.assert_allclose(computed_pf, exact_pf, atol=atol)
def test_RP8(self): problem = otbenchmark.ReliabilityProblem8() event = problem.getEvent() inputVector = event.getAntecedent() distribution = inputVector.getDistribution() ( bounds, marginalProb, ) = distribution.computeMinimumVolumeIntervalWithMarginalProbability( 1.0 - 1.0e-6) # drawEvent = otbenchmark.DrawEvent(event) # Avoid failing on CircleCi # _tkinter.TclError: no display name and no $DISPLAY environment variable try: _ = drawEvent.drawSample(500) _ = drawEvent.draw(bounds) except Exception as e: print(e) sampleSize = 500 i = 3 j = 4 _ = drawEvent.drawSampleCrossCut(sampleSize, i, j)
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