/** * Returns the current tariff subscriptions for the first CustomerInfo. * Useful for customer models with a single CustomerInfo. */ public List<TariffSubscription> getCurrentSubscriptions () { return service.getTariffSubscriptionRepo(). findActiveSubscriptionsForCustomer(allCustomerInfos.get(0)); }
/** * Returns the current tariff subscriptions for the first CustomerInfo * with the given PowerType. Useful for customer models with a single * CustomerInfo per PowerType. */ public List<TariffSubscription> getCurrentSubscriptions (PowerType type) { return service.getTariffSubscriptionRepo(). findActiveSubscriptionsForCustomer(customerInfos.get(type).get(0)); }
public void consumePower () { Timeslot ts = service.getTimeslotRepo().currentTimeslot(); int serial; for (CustomerInfo customer: getCustomerInfos()) { List<TariffSubscription> subscriptions = service.getTariffSubscriptionRepo() .findActiveSubscriptionsForCustomer(customer); String temp = officeMapping.get(customer); String type = temp.substring(0, 2); boolean controllable = temp.contains("Controllable"); if (ts == null) { log.error("Current timeslot is null"); serial = 0; } else { log.debug("Timeslot Serial: " + ts.getSerialNumber()); serial = ts.getSerialNumber(); } double load = getConsumptionByTimeslot(serial, type, controllable); log.debug("Consumption Load for Customer " + customer.toString() + ": " + load + " for subscriptions " + subscriptions.toString()); if (subscriptions != null && subscriptions.size() != 0) { subscriptions.get(0).usePower(load); } } }
service.getTariffSubscriptionRepo() .findActiveSubscriptionsForCustomer(customer);
PowerType.INTERRUPTIBLE_CONSUMPTION); TariffSubscription sub = service.getTariffSubscriptionRepo() .findActiveSubscriptionsForCustomer(customer).get(0);
service.getTariffSubscriptionRepo() .findActiveSubscriptionsForCustomer(customer);
/** * In this overloaded implementation of the changing subscription function, * Here we just put the tariff we want to change and the whole population is * moved to another random tariff. NOTE: Used only for testing... * * @param tariff */ public void changeSubscription (Tariff tariff, Tariff newTariff, CustomerInfo customer) { TariffSubscription ts = service.getTariffSubscriptionRepo().getSubscription(customer, tariff); int populationCount = ts.getCustomersCommitted(); unsubscribe(ts, populationCount); subscribe(newTariff, populationCount, customer); }
service.getTariffSubscriptionRepo() .findActiveSubscriptionsForCustomer(customer).get(0);
if (customer.getPowerType() == PowerType.INTERRUPTIBLE_CONSUMPTION) { List<TariffSubscription> subs = service.getTariffSubscriptionRepo() .findActiveSubscriptionsForCustomer(customer);
/** * Runs the model forward one step */ public void step (Timeslot timeslot) { int day = timeslot.getStartTime().getDayOfWeek(); int hour = timeslot.getStartTime().getHourOfDay(); // find the current active subscription TariffSubscription sub = null; List<TariffSubscription> subs = service.getTariffSubscriptionRepo(). findActiveSubscriptionsForCustomer(customerInfo); if (null == subs || subs.size() == 0) { log.error("No subscriptions found for " + name); return; } else { sub = subs.get(0); } driving = false; // Always do handleRegulations first, setRegulation last handleRegulation(day, hour, sub); makeDayPlanning(hour, day); doActivities(day, hour); double[] loads = getLoads(day, hour); consumePower(loads, sub); setRegulation(loads[2], loads[3], sub); }