本文整理匯總了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;
}
示例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);
}