} else { long taskStartTime = getTaskUtils().getStartTime(withdraw); long taskEndTime = getTaskUtils().getEndTime(withdraw); PrepositionalPhrase pp_rate = withdraw.getPrepositionalPhrase(Constants.Preposition.DEMANDRATE); if (pp_rate != null) { Object indObj = pp_rate.getIndirectObject(); if (indObj instanceof Schedule) { Schedule sched = (Schedule) indObj; Collection rate_elems = sched.getOverlappingScheduleElements(taskStartTime, taskEndTime); int n = (rate_elems == null ? 0 : rate_elems.size()); ArrayList phasedResults = new ArrayList(n); double rollupQty = 0; AspectValue avs[];  avs = new AspectValue[3];   int rollupEnd = thePG.convertTimeToBucket(taskEndTime,true); int rollupStart = thePG.convertTimeToBucket(taskStartTime,false);  avs[0] = AspectValue.newAspectValue(AspectType.END_TIME, taskEndTime); avs[1] = AspectValue.newAspectValue(AspectType.START_TIME, taskStartTime);  for (Iterator iter = rate_elems.iterator(); iter.hasNext(); ) { ObjectScheduleElement ose = (ObjectScheduleElement) iter.next(); int rateStartBucket = thePG.convertTimeToBucket(ose.getStartTime(),false); int rateEndBucket = thePG.convertTimeToBucket(ose.getEndTime(),true); Rate currentRate = (Rate) ose.getObject();   rollupQty = rollupQty + this.getQuantityForDuration(currentRate,(rateEndBucket - rateStartBucket));  if (rateEndBucket > rollupEnd) { rollupEnd = rateEndBucket;}  if (rateStartBucket < rollupStart) { rollupStart = rateStartBucket;} AspectValue thisPhase[] = new AspectValue[3]; thisPhase[0] = AspectValue.newAspectValue(AspectType.END_TIME, thePG.convertBucketToTime(rateEndBucket)); thisPhase[1] = AspectValue.newAspectValue(AspectType.START_TIME, thePG.convertBucketToTime(rateStartBucket)); thisPhase[2] = getDemandRateAV(getQuantityForDuration(currentRate,thePG.getBucketMillis()), thePG.getBucketMillis());  phasedResults.add(thisPhase); } avs[2] = getDemandRateAV(rollupQty, thePG.convertBucketToTime(rollupEnd) - thePG.convertBucketToTime( rollupStart));  estimatedResult = inventoryPlugin.getPlanningFactory(). newPhasedAllocationResult(Constants.Confidence.SCHEDULED, true, avs, (new Vector(phasedResults)).elements());  } } else { estimatedResult = PluginHelper. createEstimatedAllocationResult(withdraw, inventoryPlugin.getPlanningFactory(), Constants.Confidence.SCHEDULED, true); } }
  private void createBestAllocation(Task withdraw, Inventory inv,                                    LogisticsInventoryPG thePG) {    AllocationResult estimatedResult = PluginHelper.            createEstimatedAllocationResult(withdraw, inventoryPlugin.getPlanningFactory(),                                            Constants.Confidence.SCHEDULED, true);    compareResults(estimatedResult, withdraw, inv, thePG);  }