Ejemplo n.º 1
0
  ProfileScheduleSubparticle(PowerProfileInfo ppi) {
    phases = ppi.getEnergyPhases();

    PowerProfileTimeConstraints pptc = ppi.getTimeConstraints();
    long startTime = Math.max(pptc.getStartAfterConstraint(), System.currentTimeMillis());
    profileEarliestStart = CalendarUtil.getSlotOf(startTime);

    profileSlackInterval = CalendarUtil.slotsFromMillis(pptc.getStopBeforeConstraint() - startTime);

    for (int i = phases.length; --i >= 0; profileSlackInterval -= phases[i].getSlotDuration()) ;

    if (profileSlackInterval <= 0)
      throw new IllegalArgumentException("Inconsistent time constraints with profile duration.");

    phasesBestPositions = new float[phases.length];
    phasesCurrentPositions = new float[phases.length];

    randomizePositions();
  }