當前位置: 首頁>>代碼示例>>Java>>正文


Java ArrayRealVector.add方法代碼示例

本文整理匯總了Java中org.apache.commons.math3.linear.ArrayRealVector.add方法的典型用法代碼示例。如果您正苦於以下問題:Java ArrayRealVector.add方法的具體用法?Java ArrayRealVector.add怎麽用?Java ArrayRealVector.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.math3.linear.ArrayRealVector的用法示例。


在下文中一共展示了ArrayRealVector.add方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPredictedEnergy

import org.apache.commons.math3.linear.ArrayRealVector; //導入方法依賴的package包/類
/**
 * sum all originator's (scaled) energies (since I believe the broker sees the
 * sum of them only). 
 * @param currentTimeslot 
 * @throws Exception 
 * @throws DimensionMismatchException 
 */
@Override
public ArrayRealVector getPredictedEnergy(
    TariffSubscription subscription,
    int recordLength, 
    int currentTimeslot) throws DimensionMismatchException, Exception {
  ArrayRealVector result = new ArrayRealVector(recordLength);
  
  // sum all originator's energies 
  for (CapacityOriginator originator : capacityOriginators) {
    ArrayRealVector originatorPredictedEnergy = originator.getPredictedEnergy(subscription, recordLength, currentTimeslot);
    //log.info("originatorPredictedEnergy " + Arrays.toString(originatorPredictedEnergy.toArray()));
    result = result.add(originatorPredictedEnergy);
    //log.info("bundleresult " + Arrays.toString(result.toArray()));
  }
  
  // normalize to 1 population member
  result.mapDivideToSelf(customerInfo.getPopulation());
  //log.info("bundleresultnormalized " + Arrays.toString(result.toArray()));
  
  // all predictions are positive and are adjusted in the server in
  // DefaultUtilityOptimizer.usePower() therefore we adjust the sign here,
  // the last point before returning to our shifting predictor
  double usageSign = getPowerType().isConsumption()? +1: -1;
  result.mapMultiplyToSelf(usageSign);
  
  return result;
}
 
開發者ID:LARG,項目名稱:TacTex,代碼行數:35,代碼來源:DefaultCapacityBundle.java

示例2: sumTotalEnergy

import org.apache.commons.math3.linear.ArrayRealVector; //導入方法依賴的package包/類
private TotalEnergyRecords sumTotalEnergy(
    HashMap<CustomerInfo, ArrayRealVector> customer2estimatedEnergy,
    HashMap<TariffSpecification, HashMap<CustomerInfo, Integer>> tariffSubscriptions, 
    int currentTimeslot) {
  
  List<TariffSpecification> allSpecs = new ArrayList<TariffSpecification>();
  allSpecs.addAll(tariffSubscriptions.keySet());
  HashMap<CustomerInfo, HashMap<TariffSpecification, ShiftedEnergyData>> 
      customer2ShiftedEnergy = 
          estimateShiftedPredictions(customer2estimatedEnergy, allSpecs, currentTimeslot);
  
  int predictionRecordLength = customer2estimatedEnergy.values().iterator().next().getDimension();
  ArrayRealVector predictedMyCustomersEnergy = new ArrayRealVector(predictionRecordLength);
  
  // we currently predict cost by total amount of energy
  //
  for (Entry<TariffSpecification, HashMap<CustomerInfo, Integer>> entry  : tariffSubscriptions.entrySet()) {
    TariffSpecification spec = entry.getKey();
    for (Entry<CustomerInfo, Integer> e : entry.getValue().entrySet()) {
      CustomerInfo customer = e.getKey();
      int subs = e.getValue();
      RealVector customerEnergy = customer2ShiftedEnergy.get(customer).get(spec).getShiftedEnergy().mapMultiply(subs);
      predictedMyCustomersEnergy = predictedMyCustomersEnergy.add(customerEnergy);
    }
  }
  // competitor energy prediction
  ArrayRealVector predictedCompetitorsEnergyRecord = new ArrayRealVector(predictionRecordLength);
  HashMap<CustomerInfo, HashMap<TariffSpecification, Integer>> predictedCustomerSubscriptions = BrokerUtils.revertKeyMapping(tariffSubscriptions);
  for (CustomerInfo cust : predictedCustomerSubscriptions.keySet()) {
    double subsToOthers = cust.getPopulation() - BrokerUtils.sumMapValues(predictedCustomerSubscriptions.get(cust));
    RealVector customerNonShiftedEnergy = customer2estimatedEnergy.get(cust).mapMultiply(subsToOthers);
    predictedCompetitorsEnergyRecord = predictedCompetitorsEnergyRecord.add(customerNonShiftedEnergy);
  }
  
  log.debug("predictedMyCustomersEnergy =" + predictedMyCustomersEnergy.toString());
  log.debug("predictedCompetitorsEnergyRecord =" + predictedCompetitorsEnergyRecord.toString());
  return new TotalEnergyRecords(predictedMyCustomersEnergy, predictedCompetitorsEnergyRecord);
}
 
開發者ID:LARG,項目名稱:TacTex,代碼行數:39,代碼來源:TariffOptimizierTOUFixedMargin.java


注:本文中的org.apache.commons.math3.linear.ArrayRealVector.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。