1 //                                               -*- C++ -*-
2 /**
3  *  @brief Multiple FORM result
4  *
5  *  Copyright 2005-2021 Airbus-EDF-IMACS-ONERA-Phimeca
6  *
7  *  This library is free software: you can redistribute it and/or modify
8  *  it under the terms of the GNU Lesser General Public License as published by
9  *  the Free Software Foundation, either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This library is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU Lesser General Public License for more details.
16  *
17  *  You should have received a copy of the GNU Lesser General Public License
18  *  along with this library.  If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 #include "openturns/MultiFORMResult.hxx"
22 #include "openturns/PersistentObjectFactory.hxx"
23 #include "openturns/DistFunc.hxx"
24 
25 
26 BEGIN_NAMESPACE_OPENTURNS
27 
28 CLASSNAMEINIT(MultiFORMResult);
29 
30 static const Factory<PersistentCollection<FORMResult> > Factory_PersistentCollection_FORMResult;
31 static Factory<MultiFORMResult> Factory_MultiFORMResult;
32 
33 
MultiFORMResult()34 MultiFORMResult::MultiFORMResult()
35   : PersistentObject()
36   , eventProbability_(-1.0)
37 {
38   // Nothing to do
39 }
40 
MultiFORMResult(const FORMResultCollection & collection)41 MultiFORMResult::MultiFORMResult(const FORMResultCollection & collection)
42   : PersistentObject()
43   , eventProbability_(-1.0)
44   , formResultCollection_(collection)
45 {
46   // Nothing to do
47 }
48 
49 /* Virtual constructor */
clone() const50 MultiFORMResult * MultiFORMResult::clone() const
51 {
52   return new MultiFORMResult(*this);
53 }
54 
55 
56 /* EventProbability accessor */
setEventProbability(const Scalar eventProbability)57 void MultiFORMResult::setEventProbability(const Scalar eventProbability)
58 {
59   eventProbability_ = eventProbability;
60 }
61 
62 /* Generalized reliability index */
getGeneralisedReliabilityIndex() const63 Scalar MultiFORMResult::getGeneralisedReliabilityIndex() const
64 {
65   if (formResultCollection_.getSize() == 1)
66     return formResultCollection_[0].getGeneralisedReliabilityIndex();
67   else
68     return DistFunc::qNormal(eventProbability_, true);
69 }
70 
getEventProbability() const71 Scalar MultiFORMResult::getEventProbability() const
72 {
73   return eventProbability_;
74 }
75 
getFORMResultCollection() const76 MultiFORMResult::FORMResultCollection MultiFORMResult::getFORMResultCollection() const
77 {
78   return formResultCollection_;
79 }
80 
81 /* String converter */
__repr__() const82 String MultiFORMResult::__repr__() const
83 {
84   OSS oss;
85   oss << "class=" << MultiFORMResult::GetClassName()
86       << " eventProbability=" << eventProbability_
87       << " size=" << formResultCollection_.getSize();
88   return oss;
89 }
90 
91 
92 /* Method save() stores the object through the StorageManager */
save(Advocate & adv) const93 void MultiFORMResult::save(Advocate & adv) const
94 {
95   PersistentObject::save(adv);
96   adv.saveAttribute("eventProbability_", eventProbability_);
97   adv.saveAttribute("formResultCollection_", formResultCollection_);
98 }
99 
100 
101 /* Method load() reloads the object from the StorageManager */
load(Advocate & adv)102 void MultiFORMResult::load(Advocate & adv)
103 {
104   PersistentObject::load(adv);
105   adv.loadAttribute("eventProbability_", eventProbability_);
106   adv.loadAttribute("formResultCollection_", formResultCollection_);
107 }
108 
109 
110 END_NAMESPACE_OPENTURNS
111