use of edu.umn.cs.crisys.safety.analysis.faultTree.FTLeafNode in project AMASE by loonwerks.
the class FTPrettyPrintVisitor method visit.
@Override
public Void visit(FaultTree ft) {
write(ft.includeStr);
newline();
// print leaf nodes
for (FTLeafNode leaf : ft.leafNodes.values()) {
leaf.accept(this);
}
// print non leaf nodes
for (FTNonLeafNode nonLeaf : ft.sortedIntermediateNodes) {
nonLeaf.accept(this);
}
// compute cutsets and probabilities for each root node
for (FTNonLeafNode root : ft.rootNodes.values()) {
String rootName = root.propertyName;
writeln("(* ----- CUTSET WITH PROBABILITIES ----- *)");
writeln("cutsets " + rootName + ";;");
writeln("probErrorCut " + rootName + ";;");
writeln("probErrorCutImp " + rootName + ";;");
writeln("(* ----- FAULT TREE VISUALIZATIONS ----- *)");
// fault tree visualization
write("dot_gen_show_direct_tree_file ~rend:\"pdf\" ");
writeln("\"" + rootName + "_direct_ftree.gv\" " + rootName + " ;;");
write("dot_gen_show_tree_file ~rend:\"pdf\" ");
writeln("\"" + rootName + "_optimized_ftree.gv\" " + rootName + " ;;");
newline();
}
return null;
}
use of edu.umn.cs.crisys.safety.analysis.faultTree.FTLeafNode in project AMASE by loonwerks.
the class IvcToFTGenerator method extractFaultMCSElem.
private void extractFaultMCSElem(String compName, AgreeRenaming renaming, FTAndNode mcsSetNode, String faultName, String faultRefName, String originalFaultName) {
// differentiate same fault definitions activated in subcomponents of different parent components
String updatedFaultName = MHSUtils.updateElemName(compName + "_" + faultName);
// if mcsElem is not yet in leaf nodes
if (!faultTree.leafNodes.containsKey(updatedFaultName)) {
FaultStatementImpl faultStmtImpl = (FaultStatementImpl) renaming.getRefMap().get(faultRefName);
// original fault name specified by the user
String faultUserName = faultStmtImpl.getName();
// original fault explanation specified by the user
String faultUserExplanation = faultStmtImpl.getStr();
// probability string
String probStr = "";
// failure probability
float failureProb = (float) 0.0;
for (FaultSubcomponent faultSub : faultStmtImpl.getFaultDefinitions()) {
if (faultSub instanceof ProbabilityStatementImpl) {
probStr = ((ProbabilityStatementImpl) faultSub).getProbability();
failureProb = Float.parseFloat(probStr);
}
}
// TODO: need to have component specify failure rate and exposure time in the future
// currently treat exposure time and failure rate as (float) 1.0
// and set the failure probability from the fault statement as the failure rate
FTLeafNode ftLeafNode = new FTLeafNode(compName, updatedFaultName, (float) 1.0, (float) 1.0, failureProb, originalFaultName, faultUserName, faultUserExplanation);
faultTree.addLeafNode(updatedFaultName, ftLeafNode);
mcsSetNode.addChildNode(updatedFaultName, ftLeafNode);
// update intermediate node
faultTree.addIntermediateNode(mcsSetNode.nodeName, mcsSetNode);
// ftLeafNode.addParentNode(mcsSetNode);
} else {
FTLeafNode leafNode = faultTree.leafNodes.get(updatedFaultName);
mcsSetNode.addChildNode(updatedFaultName, leafNode);
faultTree.addIntermediateNode(mcsSetNode.nodeName, mcsSetNode);
// leafNode.addParentNode(mcsSetNode);
}
}
use of edu.umn.cs.crisys.safety.analysis.faultTree.FTLeafNode in project AMASE by loonwerks.
the class FTMinCutSetTxtPrintVisitor method visit.
@Override
public Void visit(FTOrNode orNode) {
LinkedList<FTNode> sortedChildren = new LinkedList<FTNode>(orNode.childNodes.values());
sortedChildren.sort(Comparator.comparing(FTNode::getProbability).reversed());
writeln("Total " + orNode.childNodes.size() + " Minimal Cut Sets found for this property");
writeln("Probability of failure for the overall property: " + orNode.getProbability());
writeln("");
int minCutSetNum = 0;
for (FTNode child : sortedChildren) {
minCutSetNum++;
writeln("Minimal Cut Set # " + minCutSetNum);
if (child instanceof FTLeafNode) {
writeln("Cardinality 1");
}
child.accept(this);
newline();
}
return null;
}
use of edu.umn.cs.crisys.safety.analysis.faultTree.FTLeafNode in project AMASE by loonwerks.
the class FTMinCutSetTallyPrintVisitor method visit.
@Override
public Void visit(FTOrNode orNode) {
writeln("Total " + orNode.childNodes.size() + " Minimal Cut Sets");
int minCutSetNum = 0;
for (FTNode child : orNode.childNodes.values()) {
minCutSetNum++;
// writeln("Minimal Cut Set # " + minCutSetNum);
if (child instanceof FTLeafNode) {
// writeln("Cardinality 1");
tally.addToTally(1);
}
child.accept(this);
// newline();
}
return null;
}
use of edu.umn.cs.crisys.safety.analysis.faultTree.FTLeafNode in project AMASE by loonwerks.
the class FTResolveVisitor method isSubset.
private boolean isSubset(FTNonLeafNode node, ArrayList<FaultSetProbability> faultCombinationsAboveThreshold) {
boolean isSubset = false;
HashSet<String> childNodeSet = new HashSet<String>();
for (FTNode childNode : node.childNodes.values()) {
if (!(childNode instanceof FTLeafNode)) {
throw new SafetyException("Trying to prune node " + node.nodeName + " with non leaf child " + childNode.nodeName);
} else {
childNodeSet.add(((FTLeafNode) childNode).lustreFaultName);
}
}
for (FaultSetProbability faultCombination : AddFaultsToNodeVisitor.faultCombinationsAboveThreshold) {
HashSet<String> faultCombinationSet = faultCombination.toStringSet();
if (faultCombinationSet.containsAll(childNodeSet)) {
isSubset = true;
return isSubset;
}
}
return isSubset;
}
Aggregations