if (taskLateDate.getTime() < latest) { latest = taskLateDate.getTime();
if (taskBestDate.getTime() > taskLateDate.getTime()) taskBestDate = taskLateDate; if (taskBestDate.getTime() < latest) { latest = taskBestDate.getTime();
  public double execute() {    //boolean finished = false;    double tonsPacked = 0;    if (_gp.getLoggingService().isInfoEnabled())      _gp.getLoggingService().info("Filler.execute - entered.");    int numTasks = 0;    int numParents = 0;    // while there's still ammo to put in milvans    while (_sz.moreTasksInQueue()) {      // initialize the aggregation      ArrayList agglist = new ArrayList();      double amount = 0.0;      double earliest = 0.0;      double latest = java.lang.Double.POSITIVE_INFINITY;      // while our milvan is not yet full and there is more ammo left to pack      while (_ac.getQuantity() - amount > MIN_DELTA && _sz.moreTasksInQueue()) {        // ask the sizer for what an amount that would fill the milvan        Task t = _sz.provide(_ac.getQuantity() - amount, earliest, latest);        if (t == null) { // the next task is outside the earliest->latest window          //	    finished = true;          break;        }        numTasks++;        // if we reach here, t is a Task that provides        // some amount towards our overall amount        double provided = t.getPreferredValue(AspectType.QUANTITY);	if (_gp.getLoggingService().isInfoEnabled()) {	  _gp.getLoggingService().info("Filler.execute - adding " + provided +				       " to agg list vs " + (_ac.getQuantity() - amount) + " amount " +				       amount);	}        Preference endDatePref = t.getPreference(AspectType.END_TIME);        ScoringFunction sf = endDatePref.getScoringFunction();        AspectScorePoint aspStart = sf.getDefinedRange().getRangeStartPoint();        Date taskEarlyDate = new Date((long) aspStart.getValue());        if (taskEarlyDate.getTime() > earliest) {          earliest = taskEarlyDate.getTime();        }        AspectScorePoint aspEnd = sf.getDefinedRange().getRangeEndPoint();        Date taskLateDate = new Date((long) aspEnd.getValue());        if (taskLateDate.getTime() < latest) {          latest = taskLateDate.getTime();        }        amount += provided;        agglist.add(t);      }      if (!agglist.isEmpty()) {        double loadedQuantity = createMPTask(agglist);        numParents += agglist.size();        TRANSPORT_TONS += loadedQuantity;        tonsPacked += loadedQuantity;      }      if (_gp.getLoggingService().isInfoEnabled()) {	_gp.getLoggingService().info("Filler.execute - aggregating together " + agglist.size() + " parents:");	for (Iterator iter = agglist.iterator(); iter.hasNext();) {	  Task task = (Task) iter.next();	  _gp.getLoggingService().info("Filler.execute - " + task.getUID() +				       " end date " + new Date((long) task.getPreferredValue(AspectType.END_TIME)));	}      }    }    if (numTasks != numParents)      _gp.getLoggingService().error("Filler.execute - num tasks created " + numTasks +                                    " != parents of MPTask " + numParents);    if (numParents != _sz.sizedMade)      _gp.getLoggingService().error("Filler.execute - sizer num tasks made " + _sz.sizedMade +                                    " != total parents of MPTask " + numParents);    if (_gp.getLoggingService().isInfoEnabled())      _gp.getLoggingService().info("Packer  - current aggregated requested transport: " +                                   TRANSPORT_TONS + " tons.");    if (_gp.getLoggingService().isInfoEnabled())      _gp.getLoggingService().info("Filler.execute - exited.");    return tonsPacked;  }