/** * @param customerName * @return Customer associated by the given name, or null if the customer cannot be found. */ public Customer findCustomerByNameAndType(String customerName, PowerType type) { for (Entry<CustomerInfo, Customer> entry : customerMap.entrySet()) { CustomerInfo key = entry.getKey(); Customer value = entry.getValue(); if (key.getName().equals(customerName) && (key.getPowerType() == type)) { return value; } } return null; }
/** Creates and adds a customer object into the map. Map key will be a given customerInfo. */ public void addCustomers(List<CustomerInfo> customerInfos) { for (CustomerInfo customerInfo : customerInfos) { Customer customer = new Customer(customerInfo); customerMap.put(customerInfo, customer); PowerType genericType = customerInfo.getPowerType().getGenericType(); if (genericType == PowerType.CONSUMPTION) { consumers.add(customer); } else if (genericType == PowerType.PRODUCTION) { producers.add(customer); } else if (genericType == PowerType.STORAGE) { storages.add(customer); } } // build list: customerList = new ArrayList<Customer>(customerMap.values()); log.info( "Customers added: List size:" + customerList.size() + " Map size:" + customerMap.size()); }
/** * Initialization must provide accessor to Customer instance and time. We assume configuration has * already happened. We also start with no active trucks, and the weakest batteries on * availableChargers. Trucks will not be active (in bootstrap mode) until the first shift change. */ @Override public void initialize() { super.initialize(); log.info("Initialize " + name); // fill out CustomerInfo. We label this model as thermal storage // because we don't allow battery discharge powerType = PowerType.THERMAL_STORAGE_CONSUMPTION; CustomerInfo info = new CustomerInfo(name, 1); // conservative interruptible capacity double interruptible = Math.min(nChargers * maxChargeKW, nBatteries * maxChargeKW / 3.0); info.withPowerType(powerType) .withCustomerClass(CustomerClass.LARGE) .withControllableKW(-interruptible) .withStorageCapacity(nBatteries * maxChargeKW / 3.0) .withUpRegulationKW(-nChargers * maxChargeKW) .withDownRegulationKW(nChargers * maxChargeKW); // optimistic, perhaps addCustomerInfo(info); ensureSeeds(); // use default values when not configured ensureShifts(); // make sure we have enough batteries and availableChargers validateBatteries(); validateChargers(); // all batteries are charging // energyCharging = getStateOfCharge() * getBatteryCapacity(); // capacityInUse = 0.0; // energyInUse = 0.0; // set up the tariff evaluator. We are wide-open to variable pricing. tariffEvaluator = new TariffEvaluator(this); tariffEvaluator.withInertia(0.7).withPreferredContractDuration(14); tariffEvaluator.initializeInconvenienceFactors(0.0, 0.01, 0.0, 0.0); tariffEvaluator.initializeRegulationFactors( -nChargers * maxChargeKW * 0.05, 0.0, nChargers * maxChargeKW * 0.04); }
public CustomerInfo createCustomerInfo(String name, int population) { CustomerInfo result = new CustomerInfo(name, population); customers.put(result.getId(), result); return result; }