/** * Initializes the instance. Called after configuration, and after * a call to setServices(). * TODO -- do we really want this here? */ public void initialize () { rs1 = service.getRandomSeedRepo().getRandomSeed(name, 0, "TariffChooser"); }
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); } } }
int serial = service.getTimeslotRepo().currentSerialNumber(); int day = (int) (serial / OfficeComplexConstants.HOURS_OF_DAY) + 1; service.getCustomerRepo() .findByNameAndPowerType(name + " " + type + " Controllable", PowerType.INTERRUPTIBLE_CONSUMPTION); service.getTariffSubscriptionRepo() .findActiveSubscriptionsForCustomer(customer).get(0);
@Override public void step () { for (EvCustomer customer : evCustomers) { customer.step(service.getTimeslotRepo().currentTimeslot()); } }
int days = Integer.parseInt(conf.getProperty("PublicVacationDuration")); gen = service.getRandomSeedRepo() .getRandomSeed(toString(), seed, "OfficeComplex Model" + seed); service.getCustomerRepo().findByName(name + " " + type + " Base"); customer = service.getCustomerRepo() .findByName(name + " " + type + " Controllable");
/** * 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)); }
/** * Hooks up data structures, creates EvCustomers and corresponding * CustomerInfo instances. */ @Override public void initialize() { super.initialize(); log.info("Initialize " + name); Map<String, Collection<?>> beans; generator = service.getRandomSeedRepo(). getRandomSeed("EvSocialClass-" + name, 1, "initialize"); Config.recycle(); config = Config.getInstance(); config.configure(service.getServerConfiguration()); beans = config.getBeans(); unpackBeans(beans); // Create and set up the customer instances evCustomers = new ArrayList<EvCustomer>(); if (null == customerAttributeList) { // boot session - dynamic configuration configureForBoot(beans); } else { // sim session - restore from boot record configureForSim(beans); } }
/** * This function is utilized in order to check the weather at each time tick * of the competition clock and reschedule the appliances that are weather * sensitive to work. */ void weatherCheck (int day, int hour, Instant now) { int dayTemp = day % (OfficeComplexConstants.DAYS_OF_BOOTSTRAP + OfficeComplexConstants.DAYS_OF_COMPETITION); WeatherReport wr = service.getWeatherReportRepo().currentWeatherReport(); if (wr != null) { double temperature = wr.getTemperature(); // log.debug("Temperature: " + temperature); Vector<Office> offices = getOffices(); for (Office office: offices) { office.weatherCheck(dayTemp, hour, now, temperature); } for (String type: numberOfOffices.keySet()) { updateAggDailyWeatherSensitiveLoad(type, day); if (dayTemp + 1 < OfficeComplexConstants.DAYS_OF_COMPETITION) { updateAggDailyWeatherSensitiveLoad(type, dayTemp + 1); } } } }
private EvCustomer instantiateCustomer (Map<String, Collection<?>> beans, SocialGroup thisGroup, String gender, CarType car, String customerName) { EvCustomer customer = new EvCustomer(customerName); log.info("Adding EvCustomer " + customerName); evCustomers.add(customer); CustomerInfo info = customer.initialize(thisGroup, gender, activities, getGroupActivities(beans, thisGroup), car, service, config); addCustomerInfo(info); service.getCustomerRepo().add(info); return customer; }
/** * Saves state of EvCustomer instances */ @Override public void saveBootstrapState () { service.getServerConfiguration().saveBootstrapState(evCustomers); }
private Instant getNowInstant () { return service.getTimeslotRepo().currentTimeslot().getStartInstant(); }
int days = Integer.parseInt(conf.getProperty("PublicVacationDuration")); gen = service.getRandomSeedRepo() .getRandomSeed(toString(), seed, "Village Model" + seed); service.getCustomerRepo().findByName(name + " " + type + " Base"); customer = service.getCustomerRepo() .findByName(name + " " + type + " Controllable");
/** * 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)); }
/** * This function is utilized in order to check the weather at each time tick * of the competition clock and reschedule the appliances that are weather * sensitive to work. */ void weatherCheck (int day, int hour, Instant now) { int dayTemp = day % (VillageConstants.DAYS_OF_BOOTSTRAP + VillageConstants.DAYS_OF_COMPETITION); WeatherReport wr = null; wr = service.getWeatherReportRepo().currentWeatherReport(); if (wr != null) { double temperature = wr.getTemperature(); // log.debug("Temperature: " + temperature); Vector<Household> houses = getHouses(); for (Household house: houses) { house.weatherCheck(dayTemp, hour, now, temperature); } for (String type: numberOfHouses.keySet()) { updateAggDailyWeatherSensitiveLoad(type, day); if (dayTemp + 1 < VillageConstants.DAYS_OF_COMPETITION) { updateAggDailyWeatherSensitiveLoad(type, dayTemp + 1); } } } }
private void configureForSim (Map<String, Collection<?>> beans) { population = customerAttributeList.size(); int index = 0; for (String description : customerAttributeList) { String[] attributes = description.split("\\."); SocialGroup thisGroup = groups.get(Integer.parseInt(attributes[0])); String gender = attributes[1]; CarType car = carTypes.get(attributes[2]); instantiateCustomer(beans, thisGroup, gender, car, this.name + "_" + index++); } service.getServerConfiguration().configureNamedInstances(evCustomers); }
public void consumePower () Timeslot ts = service.getTimeslotRepo().currentTimeslot(); int serial; service.getTariffSubscriptionRepo() .findActiveSubscriptionsForCustomer(customer);
@Override public CapacityProfile getCapacityProfile (Tariff tariff) { Instant start = service.getTimeslotRepo().currentTimeslot().getStartInstant(); double drain = capacityKWh * (1.0 - chargeEfficiency) / 2.0; double[] profile = new double[24]; Arrays.fill(profile, drain); return new CapacityProfile (profile, start); } }
int serial = service.getTimeslotRepo().currentSerialNumber(); int day = (int) (serial / VillageConstants.HOURS_OF_DAY) + 1; CustomerInfo customer = service.getCustomerRepo() .findByNameAndPowerType(name + " " + type + " Controllable", PowerType.INTERRUPTIBLE_CONSUMPTION); TariffSubscription sub = service.getTariffSubscriptionRepo() .findActiveSubscriptionsForCustomer(customer).get(0);
private void ensureSeeds () { if (null == evalSeed) { evalSeed = service.getRandomSeedRepo() .getRandomSeed(Battery.class.getName() + "-" + name, 0, "eval"); } }
/** * 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); }