From 4e105ff139c6902fc0f2d4bc63f6bb901d131742 Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Fri, 11 Oct 2024 18:33:48 +0200 Subject: [PATCH] DeconditionedDistribution --- lib/src/InverseFORM.cxx | 18 ++++++++++-------- lib/test/t_InverseFORM_sphere.cxx | 8 ++++++-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/src/InverseFORM.cxx b/lib/src/InverseFORM.cxx index 0d033e3..76b5c1b 100755 --- a/lib/src/InverseFORM.cxx +++ b/lib/src/InverseFORM.cxx @@ -24,12 +24,18 @@ #include #include #include -#include #include #include #include #include +#if OPENTURNS_VERSION >= 102400 +#include +#else +#include +#define DeconditionedDistribution ConditionalDistribution +#endif + using namespace OT; namespace OTROBOPT { @@ -228,17 +234,13 @@ Function InverseFORM::getG(const Scalar p) newFunction.setParameter(params); RandomVector antecedent(event_.getImplementation()->getAntecedent().getImplementation()->clone()); const Distribution distribution(antecedent.getDistribution()); -#if OPENTURNS_VERSION >= 102300 const JointDistribution * p_joint = dynamic_cast(distribution.getImplementation().get()); -#else - const ComposedDistribution * p_joint = dynamic_cast(distribution.getImplementation().get()); -#endif if (p_joint) { ComposedDistribution::DistributionCollection distributionCollection(p_joint->getDistributionCollection()); for (UnsignedInteger i = 0; i < distributionCollection.getSize(); ++ i) { - if (distributionCollection[i].getImplementation()->getClassName() == "ConditionalDistribution") + if (distributionCollection[i].getImplementation()->getClassName() == "DeconditionedDistribution") { DistributionImplementation::PointWithDescriptionCollection parametersCollection(distributionCollection[i].getParametersCollection()); for (UnsignedInteger j = 0; j < parametersCollection.getSize(); ++ j) @@ -253,12 +255,12 @@ Function InverseFORM::getG(const Scalar p) } } } - const ConditionalDistribution * p_conditional = dynamic_cast(distributionCollection[i].getImplementation().get()); + const DeconditionedDistribution * p_conditional = dynamic_cast(distributionCollection[i].getImplementation().get()); if (p_conditional) { Distribution conditioning(p_conditional->getConditioningDistribution()); conditioning.setParametersCollection(parametersCollection); - ConditionalDistribution newConditional(p_conditional->getConditionedDistribution(), conditioning); + DeconditionedDistribution newConditional(p_conditional->getConditionedDistribution(), conditioning); distributionCollection[i] = newConditional; ComposedDistribution newDistribution(distributionCollection); antecedent = RandomVector(newDistribution); diff --git a/lib/test/t_InverseFORM_sphere.cxx b/lib/test/t_InverseFORM_sphere.cxx index 3fea2d2..e1c2f1b 100644 --- a/lib/test/t_InverseFORM_sphere.cxx +++ b/lib/test/t_InverseFORM_sphere.cxx @@ -2,6 +2,10 @@ #include "openturns/OTtestcode.hxx" #include "otrobopt/OTRobOpt.hxx" +#if OPENTURNS_VERSION < 102400 +#define DeconditionedDistribution ConditionalDistribution +#endif + using namespace OT; using namespace OT::Test; using namespace OTROBOPT; @@ -29,7 +33,7 @@ int main() ComposedDistribution::DistributionCollection coll; coll.add(Beta(0.117284, 0.117284, 2.9, 3.1));//R - ConditionalDistribution eDist(LogNormal(L0, 0.1, 0.), eParams); + DeconditionedDistribution eDist(LogNormal(L0, 0.1, 0.), eParams); coll.add(eDist);//e coll.add(WeibullMin(3.16471, 9.21097, 0.0));//p @@ -62,7 +66,7 @@ int main() // FORM must yield the same probability on the limit state with parameter set to the optimum eColl[0] = Dirac(result.getParameter()[0]); eParams = ComposedDistribution(eColl); - eDist = ConditionalDistribution(LogNormal(result.getParameter()[0], 0.1, 0.0), eParams); + eDist = DeconditionedDistribution(LogNormal(result.getParameter()[0], 0.1, 0.0), eParams); coll[1] = eDist; myDistribution = ComposedDistribution(coll); vect = RandomVector(myDistribution);