Index: Ringtoets/Common/src/Ringtoets.Common.Data/Probability/ProbabilityAssessmentOutputFactory.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Data/Probability/ProbabilityAssessmentOutputFactory.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Probability/ProbabilityAssessmentOutputFactory.cs (revision 9e351540e19d1f727608501b55006ef9250fe8ad)
@@ -0,0 +1,64 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using Core.Common.Util;
+
+namespace Ringtoets.Common.Data.Probability
+{
+ ///
+ /// Factory for creating .
+ ///
+ public static class ProbabilityAssessmentOutputFactory
+ {
+ ///
+ /// Creates based on the provided parameters.
+ ///
+ /// The norm to assess for.
+ /// The contribution of the failure mechanism as a percentage (0-100)
+ /// to the total of the failure probability of the assessment section.
+ /// The 'N' parameter used to factor in the 'length effect'.
+ /// The reliability to use for the calculation.
+ /// The calculated .
+ public static ProbabilityAssessmentOutput Create(double norm, double contribution, double lengthEffectN, double reliability)
+ {
+ double requiredProbability = GetRequiredProbability(contribution / 100.0, norm, lengthEffectN);
+ double probability = StatisticsConverter.ReliabilityToProbability(reliability);
+ double requiredReliability = StatisticsConverter.ProbabilityToReliability(requiredProbability);
+ double factorOfSafety = GetFactorOfSafety(reliability, requiredReliability);
+
+ return new ProbabilityAssessmentOutput(requiredProbability,
+ requiredReliability,
+ probability,
+ reliability,
+ factorOfSafety);
+ }
+
+ private static double GetRequiredProbability(double contribution, double norm, double lengthEffectN)
+ {
+ return contribution * norm / lengthEffectN;
+ }
+
+ private static double GetFactorOfSafety(double reliability, double requiredReliability)
+ {
+ return reliability / requiredReliability;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj
===================================================================
diff -u -r3b1be2b494c30728564f41d6d8d14fc6a762957d -r9e351540e19d1f727608501b55006ef9250fe8ad
--- Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision 3b1be2b494c30728564f41d6d8d14fc6a762957d)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision 9e351540e19d1f727608501b55006ef9250fe8ad)
@@ -114,6 +114,7 @@
+
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probability/ProbabilityAssessmentOutputFactoryTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probability/ProbabilityAssessmentOutputFactoryTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Probability/ProbabilityAssessmentOutputFactoryTest.cs (revision 9e351540e19d1f727608501b55006ef9250fe8ad)
@@ -0,0 +1,147 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using NUnit.Framework;
+using Ringtoets.Common.Data.Probability;
+using Ringtoets.Common.Data.TestUtil;
+
+namespace Ringtoets.Common.Data.Test.Probability
+{
+ [TestFixture]
+ public class ProbabilityAssessmentOutputFactoryTest
+ {
+ [Test]
+ [TestCase(30000, 100, 2, 0.00001666667)]
+ [TestCase(30000, 100, 1, 0.00003333333)]
+ [TestCase(30000, 24, 2, 0.00000400000)]
+ [TestCase(30000, 24, 1, 0.00000800000)]
+ [TestCase(20000, 100, 2, 0.00002500000)]
+ [TestCase(20000, 100, 1, 0.00005000000)]
+ [TestCase(20000, 24, 2, 0.00000600000)]
+ [TestCase(20000, 24, 1, 0.00001200000)]
+ public void RequiredProbability_DifferentInputs_ReturnsExpectedValue(int returnPeriod,
+ double contribution,
+ int lengthEffectN,
+ double expectedResult)
+ {
+ // Setup
+ double norm = 1.0 / returnPeriod;
+
+ // Call
+ ProbabilityAssessmentOutput probabilityAssessmentOutput = ProbabilityAssessmentOutputFactory.Create(
+ norm,
+ contribution,
+ lengthEffectN,
+ double.NaN);
+
+ // Assert
+ Assert.AreEqual(expectedResult, probabilityAssessmentOutput.RequiredProbability, 1e-6);
+ }
+
+ [Test]
+ [TestCase(30000, 100, 2, 4.149409984)]
+ [TestCase(30000, 100, 1, 3.987878937)]
+ [TestCase(30000, 24, 2, 4.465183916)]
+ [TestCase(30000, 24, 1, 4.314451022)]
+ [TestCase(20000, 100, 2, 4.055626981)]
+ [TestCase(20000, 100, 1, 3.890591886)]
+ [TestCase(20000, 24, 2, 4.377587847)]
+ [TestCase(20000, 24, 1, 4.2240038)]
+ public void RequiredReliability_DifferentInputs_ReturnsExpectedValue(int returnPeriod,
+ double contribution,
+ int lengthEffectN,
+ double expectedResult)
+ {
+ // Setup
+ double norm = 1.0 / returnPeriod;
+
+ // Call
+ ProbabilityAssessmentOutput probabilityAssessmentOutput = ProbabilityAssessmentOutputFactory.Create(
+ norm,
+ contribution,
+ lengthEffectN,
+ double.NaN);
+
+ // Assert
+ Assert.AreEqual(expectedResult, probabilityAssessmentOutput.RequiredReliability,
+ probabilityAssessmentOutput.RequiredReliability.GetAccuracy());
+ }
+
+ [Test]
+ [TestCase(1.23456, 1.23456)]
+ [TestCase(789.123, 789.123)]
+ public void Reliability_DifferentInputs_ReturnsExpectedValue(double reliability, double expectedResult)
+ {
+ // Call
+ ProbabilityAssessmentOutput probabilityAssessmentOutput = ProbabilityAssessmentOutputFactory.Create(
+ int.MinValue,
+ double.NaN,
+ double.NaN,
+ reliability);
+
+ // Assert
+ Assert.AreEqual(expectedResult, probabilityAssessmentOutput.Reliability, probabilityAssessmentOutput.Reliability.GetAccuracy());
+ }
+
+ [Test]
+ [TestCase(4, 0.00003167124)]
+ [TestCase(5, 0.00000028665)]
+ public void Probability_DifferentInputs_ReturnsExpectedValue(double reliability, double expectedResult)
+ {
+ // Call
+ ProbabilityAssessmentOutput probabilityAssessmentOutput = ProbabilityAssessmentOutputFactory.Create(
+ int.MinValue,
+ double.NaN,
+ double.NaN,
+ reliability);
+
+ // Assert
+ Assert.AreEqual(expectedResult, probabilityAssessmentOutput.Probability, 1e-6);
+ }
+
+ [Test]
+ [TestCase(30000, 100, 2, 4.107479655, 0.989894869)]
+ [TestCase(30000, 100, 2, 4.149409984, 1)]
+ [TestCase(30000, 24, 2, 4.107479655, 0.919890363)]
+ [TestCase(30000, 24, 2, 4.149409984, 0.929280868)]
+ [TestCase(20000, 100, 2, 4.107479655, 1.012785366)]
+ [TestCase(20000, 100, 2, 4.149409984, 1.023124169)]
+ [TestCase(20000, 24, 2, 4.107479655, 0.938297482)]
+ [TestCase(20000, 24, 2, 4.149409984, 0.947875892)]
+ public void FactorOfSafety_DifferentInputs_ReturnsExpectedValue(int returnPeriod, double contribution,
+ int lengthEffectN, double reliability,
+ double expectedResult)
+ {
+ // Setup
+ double norm = 1.0 / returnPeriod;
+
+ // Call
+ ProbabilityAssessmentOutput probabilityAssessmentOutput = ProbabilityAssessmentOutputFactory.Create(
+ norm,
+ contribution,
+ lengthEffectN,
+ reliability);
+
+ // Assert
+ Assert.AreEqual(expectedResult, probabilityAssessmentOutput.FactorOfSafety, probabilityAssessmentOutput.FactorOfSafety.GetAccuracy());
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj
===================================================================
diff -u -r3b1be2b494c30728564f41d6d8d14fc6a762957d -r9e351540e19d1f727608501b55006ef9250fe8ad
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision 3b1be2b494c30728564f41d6d8d14fc6a762957d)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision 9e351540e19d1f727608501b55006ef9250fe8ad)
@@ -86,6 +86,7 @@
+