Package org.xilaew.atg.model.testCaseGraphRuntime

Examples of org.xilaew.atg.model.testCaseGraphRuntime.Path


        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);
          currentElement = currentElement.predecessor;
        } while (currentElement!=null);
      }
    }
    return result;
View Full Code Here


    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);
        }
      }
    }
    return result;
  }
View Full Code Here

    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);
          Logging.trace("found test case " + new Date(), this);
          Path newCurrentPath = TestCaseGraphRuntimeFactory.eINSTANCE
              .createPath();
          for (AbstractTCGEdge e : currentPath.getEdges()) {
            newCurrentPath.getEdges().add(e);
          }
          currentPath = newCurrentPath;
          if (monitor != null) {
            monitor.worked(5);
          }
View Full Code Here

              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);
          currentElement = currentElement.predecessor;
        } while (currentElement != null);
        result.add(resultPath);
      }
    }
View Full Code Here

        }
      }
      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);
        if (witness != null) {
          result.put(currentPath, witness);
          System.out.println("found test case " + new Date());
          Path newCurrentPath = TestCaseGraphRuntimeFactory.eINSTANCE
              .createPath();
          for (AbstractTCGEdge e : currentPath.getEdges()) {
            newCurrentPath.getEdges().add(e);
          }
          if (monitor != null){
            monitor.worked(1);
          }
          currentPath = newCurrentPath;
View Full Code Here

import org.xilaew.atg.model.testCaseGraphRuntime.TestCaseGraphRuntimeFactory;

class SearchTree2Path {
 
  static Path searchTree2Path(SearchTree currentElement){
    Path resultPath = TestCaseGraphRuntimeFactory.eINSTANCE
        .createPath();
    do {
      resultPath.getEdges().add(0, currentElement.edge);
      currentElement = currentElement.predecessor;
    } while (currentElement != null);
    return resultPath;
  }
View Full Code Here

    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();
      while (currentEdge.getSecond() != currentPath.getEdges().size()) {
        EList<AbstractTCGEdge> l = currentPath.getEdges();
        AbstractTCGEdge e = l.remove(l.size() - 1);
        // retreat
        currentNode = e.getSource();
      }
      if (!currentNode.equals(currentEdge.getFirst().getSource())) {
        try {
          throw new YouShallNotDoThisException("bullshit");
        } catch (YouShallNotDoThisException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
      ;
      currentNode = currentEdge.getFirst().getTarget();
      currentPath.getEdges().add(currentEdge.getFirst());
      if (currentPath.getEdges().size() <= maxDepth) {
        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
        result.add(currentPath);
        currentPath = TestCaseGraphRuntimeFactory.eINSTANCE
            .createPath();
        for (AbstractTCGEdge e : result.get(result.size() - 1)
            .getEdges()) {
          currentPath.getEdges().add(e);
        }
      }
    }
    return result;
  }
View Full Code Here

TOP

Related Classes of org.xilaew.atg.model.testCaseGraphRuntime.Path

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.