Search in sources :

Example 1 with FTLeafNode

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;
}
Also used : FTNonLeafNode(edu.umn.cs.crisys.safety.analysis.faultTree.FTNonLeafNode) FTLeafNode(edu.umn.cs.crisys.safety.analysis.faultTree.FTLeafNode)

Example 2 with FTLeafNode

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);
    }
}
Also used : FaultSubcomponent(edu.umn.cs.crisys.safety.safety.FaultSubcomponent) FaultStatementImpl(edu.umn.cs.crisys.safety.safety.impl.FaultStatementImpl) FTLeafNode(edu.umn.cs.crisys.safety.analysis.faultTree.FTLeafNode) ProbabilityStatementImpl(edu.umn.cs.crisys.safety.safety.impl.ProbabilityStatementImpl)

Example 3 with FTLeafNode

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;
}
Also used : FTNode(edu.umn.cs.crisys.safety.analysis.faultTree.FTNode) LinkedList(java.util.LinkedList) FTLeafNode(edu.umn.cs.crisys.safety.analysis.faultTree.FTLeafNode)

Example 4 with FTLeafNode

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;
}
Also used : FTNode(edu.umn.cs.crisys.safety.analysis.faultTree.FTNode) FTLeafNode(edu.umn.cs.crisys.safety.analysis.faultTree.FTLeafNode)

Example 5 with FTLeafNode

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;
}
Also used : FTNode(edu.umn.cs.crisys.safety.analysis.faultTree.FTNode) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException) FTLeafNode(edu.umn.cs.crisys.safety.analysis.faultTree.FTLeafNode) FaultSetProbability(edu.umn.cs.crisys.safety.analysis.ast.visitors.AddFaultsToNodeVisitor.FaultSetProbability) HashSet(java.util.HashSet)

Aggregations

FTLeafNode (edu.umn.cs.crisys.safety.analysis.faultTree.FTLeafNode)6 FTNode (edu.umn.cs.crisys.safety.analysis.faultTree.FTNode)4 SafetyException (edu.umn.cs.crisys.safety.analysis.SafetyException)2 FTNonLeafNode (edu.umn.cs.crisys.safety.analysis.faultTree.FTNonLeafNode)2 HashSet (java.util.HashSet)2 FaultSetProbability (edu.umn.cs.crisys.safety.analysis.ast.visitors.AddFaultsToNodeVisitor.FaultSetProbability)1 FTAndNode (edu.umn.cs.crisys.safety.analysis.faultTree.FTAndNode)1 FTOrNode (edu.umn.cs.crisys.safety.analysis.faultTree.FTOrNode)1 FaultSubcomponent (edu.umn.cs.crisys.safety.safety.FaultSubcomponent)1 FaultStatementImpl (edu.umn.cs.crisys.safety.safety.impl.FaultStatementImpl)1 ProbabilityStatementImpl (edu.umn.cs.crisys.safety.safety.impl.ProbabilityStatementImpl)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1