use of edu.umn.cs.crisys.safety.analysis.faultTree.FTNonLeafNode 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.FTNonLeafNode in project AMASE by loonwerks.
the class IvcToFTGenerator method extractPropertyResult.
private void extractPropertyResult(String compName, AgreeRenaming renaming, PropertyResult propertyResult) {
// get original property name
String origPropertyName = propertyResult.getName();
String lustreName = renaming.getLustreNameFromAgreeVar(origPropertyName);
String propertyName = MHSUtils.updateElemName(compName + "_" + lustreName);
// if it is a guarantee
if (lustreName.startsWith("__GUARANTEE")) {
// if it's a valid guarantee
if (propertyResult.getStatus().equals(jkind.api.results.Status.VALID)) {
// TODO: get user specified property name if exists
String propertyDescription = propertyResult.getName();
ValidProperty property = (ValidProperty) propertyResult.getProperty();
// check if there is timeout in MIVC analysis
if (property.getMivcTimedOut()) {
new SafetyException("MIVC ANALYSIS TIMEOUT FOR " + lustreName + ": " + origPropertyName);
}
// Create mapPropToMCS for hierarchical ft printout
String propName = propertyName + ": " + propertyDescription;
Set<List<String>> mcsList = new HashSet<List<String>>();
// turn MIVC sets to MCS sets
// no limit on mhs set size
Set<List<String>> mcsSets = MHSUtils.computeMHS(property.getIvcSets(), 0, false);
// Create list for prop->MCS mapping
mcsList = createMCSList(mcsSets, renaming);
mapPropertyToMCSs.put(componentName + "__" + lustreName, mcsList);
// create node when mcsSets is not empty
if (!mcsSets.isEmpty()) {
FTNonLeafNode propertyNode;
boolean isNewNode = true;
boolean createOrNode = (mcsSets.size() > 1);
if (!faultTree.intermediateNodes.containsKey(propertyName)) {
if (createOrNode) {
propertyNode = new FTOrNode(propertyName, propertyDescription);
} else {
propertyNode = new FTAndNode(propertyName, propertyDescription);
}
} else {
propertyNode = faultTree.intermediateNodes.get(propertyName);
// if the no child node has been populated for this node yet
if (!(propertyNode instanceof FTOrNode) && !(propertyNode instanceof FTAndNode)) {
if (createOrNode) {
propertyNode = new FTOrNode(propertyName, propertyNode.propertyDescription);
} else {
propertyNode = new FTAndNode(propertyName, propertyNode.propertyDescription);
}
} else {
isNewNode = false;
}
}
if (isNewNode) {
int index = 0;
for (List<String> mcsSet : mcsSets) {
String mcsSetNodeName = propertyName + "_" + Integer.toString(index);
FTAndNode mcsSetNode = new FTAndNode(mcsSetNodeName, propertyDescription);
extractMCSSets(compName, renaming, mcsSetNode, mcsSet);
propertyNode.addChildNode(mcsSetNodeName, mcsSetNode);
// mcsSetNode.addParentNode(propertyNode);
faultTree.addIntermediateNode(mcsSetNodeName, mcsSetNode);
// update intermediate node
faultTree.addIntermediateNode(propertyNode.nodeName, propertyNode);
index++;
}
}
if (!isLowerLevel) {
faultTree.addRootNode(propertyName, propertyNode);
propertyNode.setRoot();
}
faultTree.addIntermediateNode(propertyName, propertyNode);
} else {
FTNonLeafNode propertyNode = new FTNonLeafNode(propertyName, propertyDescription);
if (faultTree.intermediateNodes.containsKey(propertyName)) {
propertyNode = faultTree.intermediateNodes.get(propertyName);
}
propertyNode.resolved = true;
propertyNode.nodeValue = false;
if (!isLowerLevel) {
faultTree.addRootNode(propertyName, propertyNode);
propertyNode.setRoot();
}
faultTree.addIntermediateNode(propertyName, propertyNode);
}
} else if (propertyResult.getStatus().equals(jkind.api.results.Status.CANCELED)) {
throw new SafetyException("One of the properties was canceled in the process of model checking." + " Rerun this analysis to proceed.");
} else if (propertyResult.getStatus().equals(jkind.api.results.Status.INVALID)) {
throw new SafetyException("One of the properties is invalid. The model must be valid using AGREE Verify All Layers.");
} else if (propertyResult.getStatus().equals(jkind.api.results.Status.UNKNOWN)) {
throw new SafetyException("One of the properties is unknown. All properties must be known and valid to generate minimal cut sets" + " Tip: Set solver to Z3 and set analysis properties PDR = 4.");
}
}
}
use of edu.umn.cs.crisys.safety.analysis.faultTree.FTNonLeafNode 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;
}
}
use of edu.umn.cs.crisys.safety.analysis.faultTree.FTNonLeafNode in project AMASE by loonwerks.
the class FTResolveVisitor method resolveAndNode.
private FTNonLeafNode resolveAndNode(FTNonLeafNode node) {
// go through all child nodes that are resolved AND node, and promote the grand child nodes
promoteNode(node);
if ((isANDNodeResolved(node))) {
return node;
}
// for the rest of the child nodes that are resolved OR node, transform the parent node
FTNonLeafNode returnNode = transformNode(node);
// if no new node created from transformNode, return node
if (returnNode == null) {
// set resolved to true
node.resolved = true;
return node;
} else // else return new node created from transformNode
{
returnNode.resolved = true;
return returnNode;
}
}
use of edu.umn.cs.crisys.safety.analysis.faultTree.FTNonLeafNode in project AMASE by loonwerks.
the class FTResolveVisitor method visit.
@Override
public FTNode visit(FTAndNode node) {
FTNonLeafNode returnNode = null;
boolean isRoot = node.isRoot;
// if no child node, return node value false
if (node.childNodes.isEmpty()) {
node.nodeValue = false;
return node;
}
// if not resolved, go visit its child nodes
if (!isANDNodeResolved(node)) {
for (FTNode child : node.childNodes.values()) {
FTNode childReturn = child.accept(this);
// the parent node becomes false
if (childReturn.nodeValue == false) {
node.nodeValue = false;
return node;
} else {
node.replaceChildNode(childReturn.nodeName, childReturn);
}
}
// set it can be removed at the upper level
if (node.childNodes.isEmpty()) {
node.nodeValue = false;
return node;
}
// after visiting, if not resolved, go resolve it
if (!isANDNodeResolved(node)) {
returnNode = resolveAndNode(node);
}
}
// 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