~ubuntu-branches/ubuntu/maverick/openturns/maverick

« back to all changes in this revision

Viewing changes to lib/src/Uncertainty/Algorithm/Analytical/SORM/SORMResult.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2008-11-18 06:32:22 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20081118063222-pa0qncclrerrqkg2
Tags: 0.12.2-1
* New upstream release
* Bug fix: "New upstream release available (0.12.2)", thanks to Jerome
  Robert (Closes: #506005).
* Applied patch by J. Robert.
* debian/control: build-depends on libxml2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//                                               -*- C++ -*-
2
2
/**
3
3
 *  @file  SORMResult.cxx
4
 
 *  @brief Result implements the results obtained from the Second Order Reliability Method
 
4
 *  @brief SORMResult implements the results obtained from the Second Order Reliability Method
5
5
 *
6
6
 *  (C) Copyright 2005-2007 EDF-EADS-Phimeca
7
7
 *
20
20
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21
21
 *
22
22
 *  @author: $LastChangedBy: dutka $
23
 
 *  @date:   $LastChangedDate: 2008-05-21 11:21:38 +0200 (mer, 21 mai 2008) $
24
 
 *  Id:      $Id: SORMResult.cxx 815 2008-05-21 09:21:38Z dutka $
 
23
 *  @date:   $LastChangedDate: 2008-09-13 22:37:56 +0200 (sam 13 sep 2008) $
 
24
 *  Id:      $Id: SORMResult.cxx 929 2008-09-13 20:37:56Z dutka $
25
25
 */
26
26
#include <cmath>
27
27
#include <complex>
34
34
#include "Matrix.hxx"
35
35
#include "Log.hxx"
36
36
#include "Normal.hxx"
 
37
#include "StandardEvent.hxx"
37
38
#include "PersistentObjectFactory.hxx"
38
39
 
39
40
namespace OpenTURNS
51
52
      typedef Base::Func::NumericalMathFunction NumericalMathFunction;
52
53
      typedef Base::Common::Log                 Log;
53
54
      typedef Distribution::Normal              Normal;
54
 
 
55
 
      CLASSNAMEINIT(SORM::Result);
56
 
 
57
 
      static Base::Common::Factory<SORM::Result> RegisteredFactory("SORM::Result");
 
55
      typedef Model::StandardEvent              StandardEvent;
 
56
 
 
57
      CLASSNAMEINIT(SORMResult);
 
58
 
 
59
      static Base::Common::Factory<SORMResult> RegisteredFactory("SORMResult");
58
60
 
59
61
      /*
60
62
       * @brief  Standard constructor: the class is defined by an optimisation algorithm, a failure event and a physical starting point
61
63
       */
62
 
      SORM::Result::Result(const NumericalPoint & standardSpaceDesignPoint,
63
 
                           const Event & limitStateVariable,
64
 
                           const Bool isStandardPointOriginInFailureSpace,
65
 
                           const String & name):
66
 
        Analytical::Result(standardSpaceDesignPoint, limitStateVariable, isStandardPointOriginInFailureSpace, name),
 
64
      SORMResult::SORMResult(const NumericalPoint & standardSpaceDesignPoint,
 
65
                             const Event & limitStateVariable,
 
66
                             const Bool isStandardPointOriginInFailureSpace,
 
67
                             const String & name):
 
68
        AnalyticalResult(standardSpaceDesignPoint, limitStateVariable, isStandardPointOriginInFailureSpace, name),
67
69
        standardDistribution_(limitStateVariable.getImplementation()->getAntecedent().getImplementation()->getDistribution().getStandardDistribution()),
68
70
        standardMarginal_(standardDistribution_.getMarginal(0))
69
71
      {
74
76
        Matrix gradient(limitStateFunction.gradient(getStandardSpaceDesignPoint()));
75
77
        /* Get the first column */
76
78
        gradientLimitStateFunction_ = gradient * NumericalPoint(1, 1.0);
77
 
 
78
 
        for (UnsignedLong i = 0; i < gradient.getNbRows(); i++)
79
 
          {
80
 
            gradientLimitStateFunction_[i] = gradient(i, 0);
81
 
          }
82
 
 
83
79
        /* compute its hessian */
84
80
        SymmetricTensor hessian(limitStateFunction.hessian(getStandardSpaceDesignPoint()));
85
81
        /* Get the first sheet */
126
122
        catch (NotDefinedException & ex) {
127
123
          Log::Info(ex.str());
128
124
        }
129
 
      } // end SORM::Result::Result
 
125
      } // end SORMResult::Result
130
126
 
131
127
      /* Default constructor */
132
 
      SORM::Result::Result():
133
 
        Analytical::Result(),
 
128
      SORMResult::SORMResult():
 
129
        AnalyticalResult(),
134
130
        hessianLimitStateFunction_(),
135
131
        gradientLimitStateFunction_(),
136
132
        sortedCurvatures_(),
147
143
      }
148
144
 
149
145
      /* Virtual constructor */
150
 
      SORM::Result * SORM::Result::clone() const
151
 
      {
152
 
        return new Result(*this);
153
 
      }
154
 
 
155
 
      /* Destructor */
156
 
      SORM::Result::~Result()
157
 
      {
158
 
        // Nothing to do
 
146
      SORMResult * SORMResult::clone() const
 
147
      {
 
148
        return new SORMResult(*this);
159
149
      }
160
150
 
161
151
      /* The function that actually evaluates the event probability with SORM Breitung approximation */
162
 
      void SORM::Result::computeEventProbabilityBreitung()
 
152
      void SORMResult::computeEventProbabilityBreitung()
163
153
        throw(NotDefinedException)
164
154
      {
165
155
        NumericalScalar beta(getHasoferReliabilityIndex());
184
174
          {
185
175
            eventProbabilityBreitung_ = 1.0 - eventProbabilityBreitung_;
186
176
          }
187
 
      } // end SORM::Result::computeEventProbabilityBreitung
 
177
      } // end SORMResult::computeEventProbabilityBreitung
188
178
 
189
179
        /* EventProbabilityBreitung accessor */
190
 
      NumericalScalar SORM::Result::getEventProbabilityBreitung() const
 
180
      NumericalScalar SORMResult::getEventProbabilityBreitung() const
191
181
      { 
192
182
        return eventProbabilityBreitung_;
193
183
      }
194
184
 
195
185
      /* The function that actually evaluates the curvatures of the standard limite state function at the standard design point */
196
 
      void SORM::Result::computeCurvatures()
 
186
      void SORMResult::computeCurvatures()
197
187
      {
198
188
        /* see Mefisto v3.2 documentation */
199
189
        /* we calculate the main curvatures */
218
208
        sortedCurvatures_ = (NumericalPoint::dot(gradientLimitStateFunction_, getStandardSpaceDesignPoint()) > 0.0 ? 1.0 : -1.0) * inverseGradientNorm * (W.computeEigenValues());
219
209
        /* we sort the curvatures with increasing order */
220
210
        std::sort(sortedCurvatures_.begin(), sortedCurvatures_.end());
221
 
      } // end SORM::Result::computeCurvatures
 
211
      } // end SORMResult::computeCurvatures
222
212
 
223
213
      /* SortedCurvatures accessor */
224
 
      SORM::NumericalPoint SORM::Result::getSortedCurvatures() const
 
214
      SORM::NumericalPoint SORMResult::getSortedCurvatures() const
225
215
      {
226
216
        return sortedCurvatures_;
227
217
      }
228
218
 
229
219
      /* The function that actually evaluates the event probability with SORM HohenBichler approximation */
230
 
      void SORM::Result::computeEventProbabilityHohenBichler()
 
220
      void SORMResult::computeEventProbabilityHohenBichler()
231
221
        throw(NotDefinedException)
232
222
      {    
233
223
        /* this formula is valid only in the gaussian case */
257
247
          {
258
248
            eventProbabilityHohenBichler_ = 1.0 - eventProbabilityHohenBichler_;
259
249
          }
260
 
      } // SORM::Result::computeEventProbabilityHohenBichler
 
250
      } // SORMResult::computeEventProbabilityHohenBichler
261
251
 
262
252
        /* EventProbability HohenBichleraccessor */
263
 
      NumericalScalar SORM::Result::getEventProbabilityHohenBichler() const
 
253
      NumericalScalar SORMResult::getEventProbabilityHohenBichler() const
264
254
      { 
265
255
        return eventProbabilityHohenBichler_;
266
256
      }
267
257
 
268
258
      /* The function that actually evaluates the event probability with SORM Tvedtapproximation */
269
 
      void SORM::Result::computeEventProbabilityTvedt()
 
259
      void SORMResult::computeEventProbabilityTvedt()
270
260
        throw(NotDefinedException)
271
261
      {    
272
262
        /* this formula is valid only in the gaussian case */
326
316
          {
327
317
            eventProbabilityTvedt_ = 1.0 - eventProbabilityTvedt_;
328
318
          }
329
 
      } // end SORM::Result::computeEventProbabilityTvedt
 
319
      } // end SORMResult::computeEventProbabilityTvedt
330
320
 
331
321
        /* EventProbability accessor */
332
 
      NumericalScalar SORM::Result::getEventProbabilityTvedt() const
 
322
      NumericalScalar SORMResult::getEventProbabilityTvedt() const
333
323
      { 
334
324
        return eventProbabilityTvedt_;
335
325
      }
336
326
 
337
327
      /* The function that actually evaluates the generalised reliability index with SORM BreitungHB and Tvedt  approximations */
338
 
      void SORM::Result::computeGeneralisedReliabilityIndex()
 
328
      void SORMResult::computeGeneralisedReliabilityIndex()
339
329
      {
340
330
        /* evaluate the GeneralisedReliabilityIndex */
341
331
        //* GeneralisedReliabilityIndex is defined by : - Inverse standard marginal CDF (eventProbability) in usual case or : + Inverse standard marginal CDF (eventProbability) in other case */
361
351
            generalisedReliabilityIndexTvedt_ = sign * standardMarginal_.computeQuantile(eventProbabilityTvedt_)[0];
362
352
          }
363
353
 
364
 
      } // end SORM::Result::computeGeneralisedReliabilityIndex
 
354
      } // end SORMResult::computeGeneralisedReliabilityIndex
365
355
 
366
356
        /* GeneralisedReliabilityIndexBreitung accessor */
367
 
      NumericalScalar SORM::Result::getGeneralisedReliabilityIndexBreitung() const
 
357
      NumericalScalar SORMResult::getGeneralisedReliabilityIndexBreitung() const
368
358
      {
369
359
        return generalisedReliabilityIndexBreitung_;
370
360
      }
371
361
 
372
362
      /* GeneralisedReliabilityIndex accessor */
373
 
      NumericalScalar SORM::Result::getGeneralisedReliabilityIndexHohenBichler() const
 
363
      NumericalScalar SORMResult::getGeneralisedReliabilityIndexHohenBichler() const
374
364
      {
375
365
        return generalisedReliabilityIndexHohenBichler_;
376
366
      }
377
367
 
378
368
      /* GeneralisedReliabilityIndex accessor */
379
 
      NumericalScalar SORM::Result::getGeneralisedReliabilityIndexTvedt() const
 
369
      NumericalScalar SORMResult::getGeneralisedReliabilityIndexTvedt() const
380
370
      {
381
371
        return generalisedReliabilityIndexTvedt_;
382
372
      }
383
373
 
384
374
      /* String converter */ 
385
 
      String SORM::Result::str() const 
 
375
      String SORMResult::str() const 
386
376
      {
387
377
        OSS oss;
388
 
        oss << "class=" << SORM::Result::GetClassName()
389
 
            << " " << Analytical::Result::str()
 
378
        oss << "class=" << SORMResult::GetClassName()
 
379
            << " " << AnalyticalResult::str()
390
380
            << " sortedCurvatures=" << sortedCurvatures_
391
381
            << " eventProbabilityBreitung=" << eventProbabilityBreitung_
392
382
            << " eventProbabilityHohenBichler=" << eventProbabilityHohenBichler_
400
390
      }
401
391
 
402
392
      /* Method save() stores the object through the StorageManager */
403
 
      void SORM::Result::save(const StorageManager::Advocate & adv) const
 
393
      void SORMResult::save(const StorageManager::Advocate & adv) const
404
394
      {
405
 
        Analytical::Result::save(adv);
 
395
        AnalyticalResult::save(adv);
406
396
        adv.writeValue(hessianLimitStateFunction_, StorageManager::MemberNameAttribute, "hessianLimitStateFunction_");
407
397
        adv.writeValue(gradientLimitStateFunction_, StorageManager::MemberNameAttribute, "gradientLimitStateFunction_");
408
398
        adv.writeValue(sortedCurvatures_, StorageManager::MemberNameAttribute, "sortedCurvatures_");
417
407
      }
418
408
 
419
409
      /* Method load() reloads the object from the StorageManager */
420
 
      void SORM::Result::load(const StorageManager::Advocate & adv)
 
410
      void SORMResult::load(const StorageManager::Advocate & adv)
421
411
      {
422
 
        Analytical::Result::load(adv);
 
412
        AnalyticalResult::load(adv);
423
413
        adv.readValue(hessianLimitStateFunction_, StorageManager::MemberNameAttribute, "hessianLimitStateFunction_");
424
414
        adv.readValue(gradientLimitStateFunction_, StorageManager::MemberNameAttribute, "gradientLimitStateFunction_");
425
415
        adv.readValue(sortedCurvatures_, StorageManager::MemberNameAttribute, "sortedCurvatures_");