Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements importance measures and template test systems. (#21)
* Implements importance measures and template test systems. + Adds Criticality Calculator, which calculates the failure and repair criticalities + Adds ABGT, BAGT, BarlowProschan, Birnbaun, Andrews Beeson Birnbaum, RAW, RRW and Vaurio importance measures + Adds customizable test systems for TMR, BridgeSystem and SeriesParallelSystem + Adds example systems for a time consistent, non coherent system a time inconsistent, non coherent system * Modifies DensityFunction to work on all functions, not just ReliabilityFunctions * Adds missing unit tests. + Adds unit tests to cover all BAGT variants * Moves BarlowProschanFunction to its own nested class to improve testability + Adds unit test to cover BarlowProschanFunction - Removes unused class. * Adds missing files from previous commit. * Increases coverage for unit tests on test systems.
- Loading branch information
Showing
36 changed files
with
3,905 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
src/main/java/org/jreliability/importancemeasures/ABGT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/******************************************************************************* | ||
* JReliability is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation, either version 3 of the License, or (at your option) any | ||
* later version. | ||
* | ||
* JReliability 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 Lesser General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with JReliability. If not, see http://www.gnu.org/licenses/. | ||
*******************************************************************************/ | ||
|
||
package org.jreliability.importancemeasures; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.apache.commons.collections15.Transformer; | ||
import org.jreliability.bdd.BDD; | ||
import org.jreliability.bdd.BDDTTRF; | ||
import org.jreliability.function.ReliabilityFunction; | ||
|
||
|
||
/** | ||
* The {@link ABGT} class calculates the ABGT importance for coherent and non-coherent systems | ||
* proposed by [ABGT17]. | ||
* | ||
* [ABGT17] ( https://doi.org/10.1016/j.ress.2016.12.013 ) | ||
* | ||
* @author oehmen | ||
* | ||
* @param <T> | ||
* The type of the variables of the {@link BDD} of the system | ||
*/ | ||
public class ABGT<T> implements TimeDependentImportanceMeasure<T> { | ||
protected final BDD<T> bdd; | ||
protected final Transformer<T, ReliabilityFunction> transformer; | ||
protected final BDDTTRF<T> bddTTRF; | ||
protected final CriticalityCalculator<T> critCalc; | ||
|
||
/** | ||
* Returns a {@link ABGT} calculator for a specific system with its {@link BDD} | ||
* and {@link ReliabilityFunction} {@link Transformer}. | ||
* | ||
* @param bdd | ||
* The {@link BDD} representing the system structure function | ||
* | ||
* @param transformer | ||
* The {@link Transformer} used to get the {@link ReliabilityFunction} of | ||
* variables present in the {@link BDD} | ||
*/ | ||
public ABGT(BDD<T> bdd, Transformer<T, ReliabilityFunction> transformer) { | ||
this.bdd = bdd; | ||
this.transformer = transformer; | ||
bddTTRF = new BDDTTRF<>(bdd.getProvider()); | ||
|
||
critCalc = new CriticalityCalculator<>(bdd, transformer); | ||
} | ||
|
||
/** | ||
* Calculates the ABGT importances for all components at the specified time. | ||
* | ||
* Uses equation 15 and 23 of [ABGT17] to calculate the importance from the failure | ||
* and repair {@link CriticalityBDDs} of the components. | ||
* | ||
* @param time | ||
* Time t at which the ABGT importance of all components is calculated. | ||
* Must be greater than 0, otherwise an IllegalArgumentException is thrown. | ||
* | ||
* @return results | ||
* Map of components and their respective ABGT importance | ||
* at time t. | ||
*/ | ||
public Map<T, Double> calculate(double time) { | ||
Map<T, Double> results = new HashMap<>(); | ||
|
||
if (time <= 0) { | ||
throw new IllegalArgumentException("Importance measure not defined for time <= 0."); | ||
} | ||
|
||
for (T var: bdd.getVariables()) { | ||
CriticalityBDDs<T> critBdds = critCalc.getCriticalityBDDs(var); | ||
|
||
/* Equation 15 of [ABGT17] */ | ||
BDD<T> abgtBdd = critBdds.getFailureCriticalityBDD().or(critBdds.getRepairCriticalityBdd()); | ||
|
||
/* Equation 23 of [ABGT17] */ | ||
double abgt_im = bddTTRF.convert(abgtBdd, transformer).getY(time); | ||
|
||
results.put(var, abgt_im); | ||
} | ||
|
||
return results; | ||
} | ||
} |
126 changes: 126 additions & 0 deletions
126
src/main/java/org/jreliability/importancemeasures/BAGT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/******************************************************************************* | ||
* JReliability is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation, either version 3 of the License, or (at your option) any | ||
* later version. | ||
* | ||
* JReliability 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 Lesser General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with JReliability. If not, see http://www.gnu.org/licenses/. | ||
*******************************************************************************/ | ||
|
||
package org.jreliability.importancemeasures; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.apache.commons.collections15.Transformer; | ||
import org.jreliability.bdd.BDD; | ||
import org.jreliability.bdd.BDDProvider; | ||
import org.jreliability.bdd.BDDTTRF; | ||
import org.jreliability.evaluator.MomentEvaluator; | ||
import org.jreliability.function.ReliabilityFunction; | ||
|
||
|
||
/** | ||
* The {@link BAGT} class calculates the time-independent importance of components | ||
* proposed by [BAGT16]. | ||
* | ||
* [BAGT16] ( https://doi.org/10.1016/j.ejor.2016.03.054 ) | ||
* | ||
* @author oehmen | ||
* | ||
* @param <T> | ||
* The type of the variables of the {@link BDD} of the system | ||
*/ | ||
public class BAGT<T> implements ImportanceMeasure { | ||
protected final BDD<T> bdd; | ||
protected final Transformer<T, ReliabilityFunction> transformer; | ||
protected final BDDProvider<T> provider; | ||
protected final BDDTTRF<T> bddTTRF; | ||
protected final MomentEvaluator moment; | ||
|
||
protected final double mttf; | ||
|
||
public enum Variant { | ||
MINUS, | ||
PLUS, | ||
MINUS_NORMALIZED, | ||
PLUS_NORMALIZED | ||
} | ||
|
||
/** | ||
* Returns a {@link BAGT} calculator for a specific system with its {@link BDD} | ||
* and {@link ReliabilityFunction} {@link Transformer}. | ||
* | ||
* @param bdd | ||
* The {@link BDD} representing the system structure function | ||
* | ||
* @param transformer | ||
* The {@link Transformer} used to get the {@link ReliabilityFunction} of | ||
* variables present in the {@link BDD} | ||
*/ | ||
public BAGT(BDD<T> bdd, Transformer<T, ReliabilityFunction> transformer) { | ||
this.bdd = bdd; | ||
this.transformer = transformer; | ||
provider = bdd.getProvider(); | ||
bddTTRF = new BDDTTRF<>(provider); | ||
moment = new MomentEvaluator(1); | ||
|
||
/* bddTTRF deallocates the bdd parameter -> copy is needed */ | ||
mttf = moment.evaluate(bddTTRF.convert(bdd.copy(), transformer)); | ||
} | ||
|
||
/** | ||
* Calculates one of the BAGT importance measure variants. | ||
* | ||
* Note: This function might have infinite run times for some variants | ||
* using non coherent systems. This is due to the {@link MomentEvaluator} | ||
* having an infinite run time for the restricted reliability functions | ||
* in those cases. | ||
* | ||
* @param variant | ||
* The variant of BAGT to be calculated. | ||
* | ||
* @return results | ||
* Map of components and their respective BAGT importance. | ||
* | ||
*/ | ||
public Map<T, Double> calculate(Variant variant) { | ||
Map<T, Double> results = new HashMap<>(); | ||
BDD<T> restrictedBdd; | ||
double bagt_im; | ||
|
||
for (T var: bdd.getVariables()) { | ||
if (variant == Variant.MINUS || variant == Variant.MINUS_NORMALIZED) { | ||
restrictedBdd = bdd.restrict(provider.get(var).not()); /* Fix var to 0 ie. Component never works */ | ||
} | ||
else { | ||
restrictedBdd = bdd.restrict(provider.get(var)); /* Fix var to 1 ie. Component always works */ | ||
} | ||
|
||
ReliabilityFunction restrictedReliability = bddTTRF.convert(restrictedBdd, transformer); | ||
|
||
/* This will cause infinite run time for some cases (eg. BAGT+ of TCNC component 1 ) */ | ||
double restrictedMttf = moment.evaluate(restrictedReliability); | ||
|
||
if (variant == Variant.MINUS_NORMALIZED || variant == Variant.PLUS_NORMALIZED) { | ||
/* Equation 19 of [BAGT16] */ | ||
bagt_im = Math.abs(mttf - restrictedMttf) / mttf; | ||
} | ||
else { | ||
/* Equation 18 of [BAGT16] */ | ||
bagt_im = Math.abs(mttf - restrictedMttf); | ||
} | ||
|
||
results.put(var, bagt_im); | ||
} | ||
|
||
return results; | ||
|
||
} | ||
} |
Oops, something went wrong.