Commit 5be16a2b authored by ISWB Prasetya's avatar ISWB Prasetya
Browse files

Optimizing prefixes refinement, to only do that when there is a method-ADT...

Optimizing prefixes refinement, to only do that when there is a method-ADT goal that is put back in the worklist.
parent f374ed4e
......@@ -203,45 +203,51 @@ public class G2 {
int prefixRefinementCount = 0 ;
int prefixStagnationCount = 0 ;
int stagnationLimit = 3 ;
boolean generateMorePrefix = worklist.hasADTtarget() ;
while (!worklist.isEmpty()) {
if (worklist.targets.size() == 0 && worklist.hasADTtarget()) {
// The first time, this will generate the prefixes, upon the next iterations,
// this will refine the prefixes each time the targetlist is emptied.
// Also, only generate prefixes if we have ADT target left.
if (prefixStagnationCount < 3) {
prefixRefinementCount++ ;
Integer K = config.numberOfPrefixes ;
if (K==null) K = 50 ;
if (g2sg.getPrefixes() != null) K = Math.min(K,10) ;
Integer numOfAddedPrefixes = g2sg.incrementallyGeneratePrefixes(K,config.maxPrefixLength,config.maxObjectDepth) ;
if (numOfAddedPrefixes==null) {
// cannot generate prefixes because CUT has no constructor/factory,
// we should now remove all ADT targets because we can't solve them anyway
worklist.removeADTtargets();
t3log.info("Since " + g2sg.scope.CUT.getName() + " can't be instantiated, we now DROP all ADT targets.") ;
// go back to the loop-head again:
continue ;
}
if (generateMorePrefix && prefixStagnationCount < stagnationLimit) {
prefixRefinementCount++ ;
Integer K = config.numberOfPrefixes ;
if (K==null) K = 50 ;
if (g2sg.getPrefixes() != null) K = Math.min(K,10) ;
Integer numOfAddedPrefixes = g2sg.incrementallyGeneratePrefixes(K,config.maxPrefixLength,config.maxObjectDepth) ;
// reset this flag to false:
generateMorePrefix = false ;
if (numOfAddedPrefixes==null) {
// cannot generate prefixes because CUT has no constructor/factory,
// we should now remove all ADT targets because we can't solve them anyway
worklist.removeADTtargets();
t3log.info("Since " + g2sg.scope.CUT.getName() + " can't be instantiated, we now DROP all ADT targets.") ;
// go back to the loop-head again:
continue ;
}
if (numOfAddedPrefixes == 0) prefixStagnationCount++ ;
if (numOfAddedPrefixes == 0) {
prefixStagnationCount++ ;
if (prefixStagnationCount >= stagnationLimit) {
t3log.warning("Prefix generation for " + g2sg.scope.CUT.getName() + " reaches stagnation. NO further prefixes will be generated.");
}
}
t3log.info("=== Generating/refining prefixes of "
t3log.info("=== Generating/refining prefixes of "
+ g2sg.scope.CUT.getName()
+ ", generation: " + prefixRefinementCount
+ ", size: " + g2sg.getPrefixes().suite.size()
+ ". Generation: " + prefixRefinementCount
+ ", adding: " + numOfAddedPrefixes
+ ", tot-size: " + g2sg.getPrefixes().suite.size()
+ ", cov: " + g2sg.currentPrefixes.coverage
+ ", #tobjs: " + g2sg.currentPrefixes.tobjs.size()
);
);
}
else {
t3log.warning("Prefix generation for " + g2sg.scope.CUT.getName() + " reaches stagnation. NO further prefixes will be generated.");
}
}
SingleTarget target = worklist.getNext(remaining/budget) ;
target.refine() ;
worklist.evaluateAndPutBack(target) ;
boolean targetSolved = worklist.evaluateAndPutBack(target) ;
if (!targetSolved && target.isADT && target.target instanceof Method) {
// a method-ADT target cannot be solved. Signal need to generate more prefixes.
// Note that a constructor-target does not need prefix.
generateMorePrefix = true ;
}
target.saveSuite() ;
// save a minimized version of the test suite; however this seem to drop
......
......@@ -14,7 +14,7 @@ public class Test_G2_forTriangle {
config.generateJunitForEachSuite = false ;
config.maxPrefixLength = 6 ;
config.maxSuffixLength = 1 ;
config.numberOfPrefixes = 40 ;
config.numberOfPrefixes = 10 ;
// config.refinementHeuristic="evo" ;
return config ;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment