Package org.xilaew.atg.model.abstractTestCaseGraph

Examples of org.xilaew.atg.model.abstractTestCaseGraph.AbstractTCGNode


   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetSource(AbstractTCGNode newSource, NotificationChain msgs) {
    AbstractTCGNode oldSource = source;
    source = newSource;
    if (eNotificationRequired()) {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AbstractTestCaseGraphPackage.ABSTRACT_TCG_EDGE__SOURCE, oldSource, newSource);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
View Full Code Here


   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetTarget(AbstractTCGNode newTarget, NotificationChain msgs) {
    AbstractTCGNode oldTarget = target;
    target = newTarget;
    if (eNotificationRequired()) {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AbstractTestCaseGraphPackage.ABSTRACT_TCG_EDGE__TARGET, oldTarget, newTarget);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
View Full Code Here

   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setInitialNode(AbstractTCGNode newInitialNode) {
    AbstractTCGNode oldInitialNode = initialNode;
    initialNode = newInitialNode;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AbstractTestCaseGraphPackage.ABSTRACT_TCG_CONTAINER__INITIAL_NODE, oldInitialNode, initialNode));
  }
View Full Code Here

          places = new HashSet<Integer>();
        places.add(new Integer(i));
        amplPath.put(edge, places);
      }

      AbstractTCGNode node;
      if ((node = edge.getTarget()) instanceof AbstractTCGRealNode) {
        i++;
        Set<Integer> places = null;
        if (amplPath.containsKey(node))
          places = amplPath.get(node);
View Full Code Here

      TCGActivity tcgActivity) {
    tcgActivity.setName(umlActivity.getName());
    this.tcgActivity = tcgActivity;
    // Convert (UML)ActivityNodes to TCGActivityNodes
    for (ActivityNode umlActivityNode : umlActivity.getOwnedNodes()) {
      AbstractTCGNode tcgNode = (AbstractTCGNode) transformElement(umlActivityNode);
      if (tcgNode != null) {
        tcgActivity.getNodes().add(tcgNode);
      }
    }
    // convert (UML) ActivityEdges to TCGEdges
View Full Code Here

    EList<Path> result = new BasicEList<Path>();
    Deque<SearchTree> stack = new ArrayDeque<SearchTree>();
    for (AbstractTCGEdge e : atcg.getInitialNode().getOutgoing()) {
      stack.addLast(new SearchTree(e, null, 0));
    }
    AbstractTCGNode currentNode = atcg.getInitialNode();
    AbstractTCGEdge currentEdge;
    SearchTree currentElement;
    while (!stack.isEmpty()) {
      currentElement = stack.removeFirst();
      currentEdge = currentElement.edge;
      currentNode = currentEdge.getTarget();

      for (AbstractTCGEdge outgoing : currentNode.getOutgoing()) {
        stack.addLast(new SearchTree(outgoing, currentElement,
            currentElement.depth + 1));
      }
      if (currentNode.getOutgoing().size() == 0) {
        // found final node -> Add path to result
        Path resultPath = TestCaseGraphRuntimeFactory.eINSTANCE
            .createPath();
        do {
          resultPath.getEdges().add(0, currentElement.edge);
View Full Code Here

  public EList<Path> findAllPaths(AbstractTCGContainer atcg){
    EList<Path> result = new BasicEList<Path>();
    Deque<AbstractTCGEdge> stack = new ArrayDeque<AbstractTCGEdge>();
   
    stack.addAll(atcg.getInitialNode().getOutgoing());
    AbstractTCGNode currentNode = atcg.getInitialNode();
    AbstractTCGEdge currentEdge ;
    Path currentPath = TestCaseGraphRuntimeFactory.eINSTANCE.createPath();
    while(!stack.isEmpty()){
      currentEdge = stack.removeFirst();
      while(!currentEdge.getSource().equals(currentNode)){
        //retreat
        currentNode = currentPath.getEdges().remove(currentPath.getEdges().size()-1).getSource();
      }
      currentNode = currentEdge.getTarget();
      currentPath.getEdges().add(currentEdge);
      for(AbstractTCGEdge outgoing:currentNode.getOutgoing()){
        stack.addFirst(outgoing);
      }
      if(currentNode.getOutgoing().size()==0){
        //found final node -> Add path to result
        result.add(currentPath);
        currentPath = TestCaseGraphRuntimeFactory.eINSTANCE.createPath();
        for(AbstractTCGEdge e:result.get(result.size()-1).getEdges()){
          currentPath.getEdges().add(e);
View Full Code Here

    ampl.loadModel(ActTCG2AMPLModel.transform(atcg));
    int passedDecisions = 0;
    for (AbstractTCGEdge edge : atcg.getInitialNode().getOutgoing()) {
      stack.add(new Pair(edge, new Integer(0)));
    }
    AbstractTCGNode currentNode = atcg.getInitialNode();
    Pair currentEdge;
    Path currentPath = TestCaseGraphRuntimeFactory.eINSTANCE.createPath();
    while (!stack.isEmpty()
        && (result.size() <= maxNoPaths || maxNoPaths == -1)) {
      currentEdge = stack.removeFirst();
      // backtrack
      while (currentEdge.getSecond() != currentPath.getEdges().size()) {
        // System.out.println("BACKTRACK");
        EList<AbstractTCGEdge> l = currentPath.getEdges();
        AbstractTCGEdge e = l.remove(l.size() - 1);
        currentNode = e.getSource();
        if (currentNode.getOutgoing().size() >= 2) {
          passedDecisions--;
        }
      }
      passedDecisions = (passedDecisions < 0 ? 0 : passedDecisions);
      currentNode = currentEdge.getFirst().getTarget();
      currentPath.getEdges().add(currentEdge.getFirst());

      if (currentPath.getEdges().size() <= maxDepth || maxDepth == -1) {
        // check every 3 or 4 decisions whether the path is still
        // feasible
        if (currentNode.getOutgoing().size() >= 2) {
          passedDecisions++;
          if (passedDecisions > uncheckedSteps) {
            passedDecisions = 0;
            ampl.loadData(Path2AMPLData.transform(currentPath));
            SolveResult solved = SolveResult.Solved;
            try {
              solved = ampl.solve();
            } catch (IOException e) {
              ampl = new JamplBuilder().solver(solver)
                  .model(ActTCG2AMPLModel.transform(atcg))
                  .data(Path2AMPLData.transform(currentPath))
                  .build();
              System.out.println("RESET!!!");
              try {
                solved = ampl.solve();
              } catch (IOException e1) {
                e1.printStackTrace();
                break;
              }
            }
            totalSolves++;
            if (solved == SolveResult.Solved) {
              System.out.print(",");
            }
            if (solved == SolveResult.Infeasible) {
              infeasibleSolves++;
              System.out.print(".");
              continue;
            }
            if (solved == SolveResult.Failure) {
              System.out.println("FAILURE!!!!!!!");
              infeasibleSolves++;
              continue;
            }
          }
        } // System.out.println("Adding Next STEP");
          // add child nodes to Stack
        for (AbstractTCGEdge outgoing : currentNode.getOutgoing()) {
          stack.addFirst(new Pair(outgoing, new Integer(currentPath
              .getEdges().size())));
        }
      }
      if (currentNode.getOutgoing().size() == 0) {
        // found final node -> Add path to result
        // fill witness with data.
        Witness witness = generateWitness(currentPath, atcg);
        if (witness != null) {
          result.put(currentPath, witness);
View Full Code Here

    EList<Path> result = new BasicEList<Path>();
    Deque<SearchTree> stack = new ArrayDeque<SearchTree>();
    for (AbstractTCGEdge e : atcg.getInitialNode().getOutgoing()) {
      stack.addLast(new SearchTree(e, null, 0));
    }
    AbstractTCGNode currentNode = atcg.getInitialNode();
    AbstractTCGEdge currentEdge;
    SearchTree currentElement;
    while (!stack.isEmpty() && (result.size() <= maxNoPaths || maxNoPaths==-1)) {
      currentElement = stack.removeFirst();
      currentEdge = currentElement.edge;
      currentNode = currentEdge.getTarget();

      if (currentElement.depth < maxDepth || maxDepth==-1) {
        for (AbstractTCGEdge outgoing : currentNode.getOutgoing()) {
          stack.addLast(new SearchTree(outgoing, currentElement,
              currentElement.depth + 1));
        }
      }
      if (currentNode.getOutgoing().size() == 0) {
        // found final node -> Add path to result
        Path resultPath = TestCaseGraphRuntimeFactory.eINSTANCE
            .createPath();
        do {
          resultPath.getEdges().add(0, currentElement.edge);
View Full Code Here

  public EMap<Path, Witness> findAllSatisfiableActivityPaths(TCGActivity atcg, IProgressMonitor monitor) {
    EMap<Path, Witness> result = new BasicEMap<Path, Witness>();
    Deque<SearchTree> stack = new ArrayDeque<SearchTree>();
    ampl.setSolver(solver);
    ampl.loadModel(ActTCG2AMPLModel.transform(atcg));
    AbstractTCGNode currentNode = atcg.getInitialNode();
    AbstractTCGEdge currentEdge;
    SearchTree currentElement;
    // Add Initial Search Tree Nodes
    int pDInc = (currentNode.getOutgoing().size() >= 2 ? 1 : 0); // passed
                                    // Decissions
                                    // Increment
                                    // (set
                                    // to 1
                                    // whenever
                                    // the
                                    // current
                                    // node
                                    // has
                                    // multiple
                                    // outgoing
                                    // edges)
    for (AbstractTCGEdge e : atcg.getInitialNode().getOutgoing()) {
      stack.addLast(new SearchTree(e, null, 0, pDInc));
    }
    // Perform Breadth First Search
    while (!stack.isEmpty()
        && (result.size() < maxNoPaths || maxNoPaths == -1)) {
      pDInc = 0;
      currentElement = stack.removeFirst();
      currentEdge = currentElement.edge;
      currentNode = currentEdge.getTarget();

      if (currentElement.depth <= maxDepth || maxDepth == -1) {
        pDInc = (currentNode.getOutgoing().size() >= 2 ? 1 : 0);
        // Eliminate Infeasible Paths
        if (pDInc == 1
            && currentElement.passedDecissions % uncheckedSteps == 0) {
          ampl.loadData(Path2AMPLData.transform(SearchTree2Path
              .searchTree2Path(currentElement)));
          SolveResult solved = SolveResult.Solved;
          try {
            solved = ampl.solve();
          } catch (IOException e) {
            ampl = new JamplBuilder().solver(solver)
                .model(ActTCG2AMPLModel.transform(atcg))
                .data(Path2AMPLData.transform(SearchTree2Path
                    .searchTree2Path(currentElement)))
                .build();
            System.out.println("RESET!!!");
            try {
              solved = ampl.solve();
            } catch (IOException e1) {
              Logging.error(Messages.SolverBFS_FATAL_AMPL_ERROR, e1);
              e1.printStackTrace();
              break;
            }
          }
          totalSolves++;
          if (solved == SolveResult.Solved) {
            System.out.print(",");
          }
          if (solved == SolveResult.Infeasible) {
            infeasibleSolves++;
            System.out.print(".");
            continue;
          }
          if (solved == SolveResult.Failure) {
            System.out.println("FAILURE!!!!!!!");
            infeasibleSolves++;
            continue;
          }
        }
        // add child nodes to Stack
        for (AbstractTCGEdge outgoing : currentNode.getOutgoing()) {
          stack.addLast(new SearchTree(outgoing, currentElement,
              currentElement.depth + 1,
              currentElement.passedDecissions + pDInc));
        }
      }
      if (currentNode.getOutgoing().size() == 0) {
        // found final node -> Add path to result
        // fill witness with data.
        Path currentPath = SearchTree2Path
            .searchTree2Path(currentElement);
        Witness witness = generateWitness(currentPath, atcg);
View Full Code Here

TOP

Related Classes of org.xilaew.atg.model.abstractTestCaseGraph.AbstractTCGNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.