use of edu.umn.cs.crisys.safety.analysis.faultTree.FTNode in project AMASE by loonwerks.
the class FTPrettyPrintVisitor method printNonLeafNode.
private void printNonLeafNode(String nodeOpStr, FTNonLeafNode nonLeaf) {
writeln("let " + nonLeaf.propertyName + " = ");
writeln(nodeOpStr + " [");
boolean multipleElem = false;
for (FTNode node : nonLeaf.childNodes.values()) {
if (multipleElem) {
writeln(";");
}
write(node.nodeName);
multipleElem = true;
}
writeln(" ];;");
}
use of edu.umn.cs.crisys.safety.analysis.faultTree.FTNode in project AMASE by loonwerks.
the class FTMinCutSetPrintVisitor method visit.
@Override
public Void visit(FaultTree ft) {
write(ft.includeStr);
newline();
// walk through the tree and print from bottom to top
for (FTNode root : ft.resolvedRootNodes) {
String rootName = root.nodeName;
if (root.nodeValue == true) {
root.accept(this);
printRootNode(rootName);
} else {
printNoTreeRootNode(rootName);
}
}
return null;
}
use of edu.umn.cs.crisys.safety.analysis.faultTree.FTNode 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.FTNode in project AMASE by loonwerks.
the class FTResolveVisitor method promoteNode.
// replace a node with its child nodes in its parent node's child nodes
private void promoteNode(FTNonLeafNode node) {
List<FTNode> childNodesToAdd = new ArrayList<FTNode>();
List<FTNode> childNodesToRemove = new ArrayList<FTNode>();
for (FTNode childNode : node.childNodes.values()) {
// if child node not yet resolved, throw exception
if (!childNode.resolved) {
throw new SafetyException("Unresolved child node " + childNode.nodeName + " for parent node " + node.nodeName);
} else {
if ((childNode.childNodes.size() == 1) || childNode.getClass().equals(node.getClass())) {
for (FTNode grandChild : childNode.childNodes.values()) {
childNodesToAdd.add(grandChild);
}
childNodesToRemove.add(childNode);
}
}
}
node.addChildNodes(childNodesToAdd);
node.removeChildNodes(childNodesToRemove);
}
use of edu.umn.cs.crisys.safety.analysis.faultTree.FTNode in project AMASE by loonwerks.
the class FTResolveVisitor method visit.
@Override
public FTNonLeafNode visit(FTOrNode node) {
FTNonLeafNode returnNode = null;
boolean isRoot = node.isRoot;
List<FTNode> childNodesToRemove = new ArrayList<FTNode>();
// if no child node, return nodeValue false
if (node.childNodes.isEmpty()) {
node.nodeValue = false;
return node;
}
// if not resolved, go visit its child nodes
if (!isORNodeResolved(node, isRoot)) {
for (FTNode child : node.childNodes.values()) {
FTNode childReturn = child.accept(this);
// remove that child node
if (childReturn.nodeValue == false) {
childNodesToRemove.add(child);
} else {
node.replaceChildNode(childReturn.nodeName, childReturn);
}
}
node.removeChildNodes(childNodesToRemove);
// set it to false so it can be handled at the upper level
if (node.childNodes.isEmpty()) {
node.nodeValue = false;
return node;
}
// after visiting, if not resolved, go resolve it
if (!isORNodeResolved(node, isRoot)) {
returnNode = resolveOrNode(node, isRoot);
}
}
// so it can be eliminated when returned to the upper level
if (node.nodeValue) {
if (returnNode != null) {
return prune(returnNode);
} else {
return prune(node);
}
} else {
return node;
}
}
Aggregations