예제 #1
0
파일: DataSet.java 프로젝트: qazzcl/jssp
  private List<Vector2D> makeBlobs(int centers, double clusterStd, double min, double max) {

    NormalDistribution dist = new NormalDistribution(random, 0.0, clusterStd, 1e-9);

    double range = max - min;
    Vector2D[] centerPoints = new Vector2D[centers];
    for (int i = 0; i < centers; i++) {
      centerPoints[i] =
          new Vector2D(random.nextDouble() * range + min, random.nextDouble() * range + min);
    }

    int[] nSamplesPerCenter = new int[centers];
    int count = samples / centers;
    Arrays.fill(nSamplesPerCenter, count);

    for (int i = 0; i < samples % centers; i++) {
      nSamplesPerCenter[i]++;
    }

    List<Vector2D> points = new ArrayList<>();
    for (int i = 0; i < centers; i++) {
      for (int j = 0; j < nSamplesPerCenter[i]; j++) {
        points.add(new Vector2D(dist.sample(), dist.sample()).add(centerPoints[i]));
      }
    }
    return points;
  }
예제 #2
0
  // ======== per-timeslot activities ========
  @Override
  public void step() {
    // check for end-of-shift
    Shift newShift = shiftSchedule[indexOfShift(getNowInstant())];
    if (newShift != currentShift) {
      log.info(getName() + " start of shift");
      // Take all batteries out of service
      double totalEnergy = getEnergyCharging() + getEnergyInUse();
      setEnergyCharging(getEnergyCharging() + getEnergyInUse());
      setCapacityInUse(0.0);
      setEnergyInUse(0.0);

      // Put the strongest batteries in trucks for the next shift
      if (null != newShift) {
        setCapacityInUse(newShift.getTrucks() * batteryCapacity);
        setEnergyInUse(Math.min(getCapacityInUse(), totalEnergy));
        setEnergyCharging(totalEnergy - getEnergyInUse());
      }
      log.info(
          getName()
              + ": new shift cInUse "
              + capacityInUse
              + ", eInUse "
              + energyInUse
              + ", eCharging "
              + energyCharging);
      currentShift = newShift;
    }

    // discharge batteries on active trucks
    if (null != currentShift) {
      double usage = Math.max(0.0, normal.sample() * truckStd + truckKW * currentShift.getTrucks());
      double deficit = usage - getEnergyInUse();
      log.debug(getName() + ": trucks use " + usage + " kWh");
      if (deficit > 0.0) {
        log.warn(getName() + ": trucks use more energy than available by " + deficit + " kWh");
        addEnergyInUse(deficit);
        addEnergyCharging(-deficit);
      }
      addEnergyInUse(-usage);
    }

    // use energy on chargers, accounting for regulation
    double regulation = getSubscription().getRegulation();
    log.info(getName() + ": regulation " + regulation);
    double energyUsed = useEnergy(regulation);

    // Record energy used
    getSubscription().usePower(energyUsed);
    log.info(
        getName()
            + " cInUse "
            + capacityInUse
            + ", eInUse "
            + energyInUse
            + ", eCharging "
            + energyCharging);
  }
예제 #3
0
    private static SparseRealMatrix initializeMatrix(SparseRealMatrix matrix, double sigma) {
      NormalDistribution normRandom = new NormalDistribution(0.0, sigma);
      int r = matrix.getRowDimension();
      int c = matrix.getColumnDimension();

      for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
          double x = normRandom.sample();
          matrix.setEntry(i, j, x);
        }
      }
      return matrix;
    }
예제 #4
0
파일: DataSet.java 프로젝트: qazzcl/jssp
 private Vector2D generateNoiseVector(NormalDistribution distribution) {
   return new Vector2D(distribution.sample(), distribution.sample());
 }