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);