示例#1
0
        public void CalculateProbabilityWorksWithPassingElement()
        {
            var hydraulicConditions = new[]
            {
                new HydraulicCondition(2.3, (Probability)3.33E-02, double.NaN, double.NaN),
                new HydraulicCondition(2.6, (Probability)1.00E-02, double.NaN, double.NaN),
                new HydraulicCondition(2.9, (Probability)3.33E-03, double.NaN, double.NaN),
                new HydraulicCondition(3.2, (Probability)1.00E-03, double.NaN, double.NaN),
                new HydraulicCondition(3.5, (Probability)3.33E-04, double.NaN, double.NaN),
                new HydraulicCondition(3.8, (Probability)1.00E-04, double.NaN, double.NaN),
            };

            var criticalPathElements = new[]
            {
                new CriticalPathElement(new TreeEvent(),
                                        new FragilityCurve
                {
                    new FragilityCurveElement(2.3, (Probability)0.001),
                    new FragilityCurveElement(2.6, (Probability)0.001),
                    new FragilityCurveElement(2.9, (Probability)0.001),
                    new FragilityCurveElement(3.2, (Probability)0.0028),
                    new FragilityCurveElement(3.5, (Probability)0.0226),
                    new FragilityCurveElement(3.8, (Probability)0.0406),
                }, false)
            };

            var probability =
                ClassEstimationFragilityCurveCalculator.CalculateProbability(hydraulicConditions, criticalPathElements);

            Assert.AreEqual(0.0332517, probability, 1e-6);
        }
示例#2
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (ExtractInput(values, out var hydraulics, out var curves, out var criticalPath))
            {
                return(values);
            }

            return(!hydraulics.Any() || !curves.Any()
                ? "NaN"
                : string.Format("1/{0}",
                                (int)(1.0 / ClassEstimationFragilityCurveCalculator.CalculateProbability(hydraulics, curves))));
        }