private double calculateUseFitnessForDefinitionPos(ExecutionTrace targetTrace,Integer objectId,int goalDefinitionPos) throws UnexpectedFitnessException {
  int previousDefId=DefUseExecutionTraceAnalyzer.getPreviousDefinitionId(goalDefinition.getVariableName(),targetTrace,goalDefinitionPos,objectId);
  if (previousDefId == goalDefinition.getDefId())   return 1.0;
  int overwritingDefPos=DefUseExecutionTraceAnalyzer.getNextOverwritingDefinitionPosition(goalDefinition,targetTrace,goalDefinitionPos,objectId);
  try {
    return calculateFitnessForDURange(targetTrace,objectId,goalUseFitness,goalUse,true,goalDefinitionPos,overwritingDefPos,true);
  }
 catch (  UnexpectedFitnessException e) {
    return 1.0;
  }
}

private double calculateUseFitnessForDefinitionPos ( ExecutionTrace targetTrace , Integer objectId , int goalDefinitionPos ) throws UnexpectedFitnessException { int previousDefId = DefUseExecutionTraceAnalyzer . getPreviousDefinitionId ( goalDefinition . getVariableName ( ) , targetTrace , goalDefinitionPos , objectId ) ; if ( previousDefId == goalDefinition . getDefId ( ) ) return 1.0 ; int overwritingDefPos = DefUseExecutionTraceAnalyzer . getNextOverwritingDefinitionPosition ( goalDefinition , targetTrace , goalDefinitionPos , objectId ) ; try { return calculateFitnessForDURange ( targetTrace , objectId , goalUseFitness , goalUse , true , goalDefinitionPos , overwritingDefPos , true ) ; } catch ( UnexpectedFitnessException e ) { return 1.0 ; } }
calculates the goalusefitness for the given goaldefinitionpos as follows : for every goaldefinitionposition in the objecttrace for the given objectid this method gets called by getdistance ( ) to determine the fitness of the goalusebranch considering only information traced between the goaldefinitionposition and the occurrence of the next overwriting definition in order to do that the executiontrace is filtered using calculatefitnessfordurange ( ) to avoid making unnecessary calculations only calculate the fitness if the definition coming before goaldefinitionpos was not the goaldefinition . if it was , 1 is returned .
