public TariffEvaluationWrapper (String type, CustomerInfo customer) { this.type = type; customerInfo = customer; day = gen.nextInt(VillageConstants.DAYS_OF_BOOTSTRAP + VillageConstants.DAYS_OF_COMPETITION); }
/** * This function selects the shift of the worker. There three different * shifts: 00:00 - 08:00 08:00 - 16:00 and 16:00 - 24:00. * * @param gen * @return */ int createWorkingStartHour () { int x = gen.nextInt(VillageConstants.NUMBER_OF_SHIFTS); return (x * VillageConstants.HOURS_OF_SHIFT_WORK * VillageConstants.QUARTERS_OF_HOUR); }
public TariffEvaluationWrapper (String type, CustomerInfo customer) { this.type = type; customerInfo = customer; day = gen.nextInt(OfficeComplexConstants.DAYS_OF_BOOTSTRAP + OfficeComplexConstants.DAYS_OF_COMPETITION); }
/** * This function fills out the vector that contains the days that the * appliance is functioning. * * @param times * @return */ void fillDays () { lastWeek = new int[VillageConstants.DAYS_OF_WEEK]; for (int i = 0; i < times; i++) { int temp = gen.nextInt(VillageConstants.DAYS_OF_WEEK); if (lastWeek[temp] < VillageConstants.OPERATION_DAILY_TIMES_LIMIT) lastWeek[temp]++; else i--; } for (int i = 0; i < VillageConstants.DAYS_OF_WEEK; i++) { days.add(lastWeek[i]); } }
/** * This function fills out the leisure days' vector of the person by choosing * randomly days of the week, while the amount of days is different for each * person type. * * @param counter * @param gen * @return leisure days' vector */ Vector<Integer> createLeisureVector (int counter) { // Create auxiliary variable Vector<Integer> v = new Vector<Integer>(); // Loop for the amount of days for (int i = 0; i < counter; i++) { int day = gen.nextInt(VillageConstants.DAYS_OF_WEEK); v.add(day); } java.util.Collections.sort(v); return v; }
@Override public void fillDailyOperation (int weekday) { // Initializing Variables loadVector = new Vector<Integer>(); dailyOperation = new Vector<Boolean>(); int k = gen.nextInt(cycleDuration); for (int i = 0; i < OfficeComplexConstants.QUARTERS_OF_DAY; i++) { if (i % cycleDuration == k) { loadVector.add(power); dailyOperation.add(true); } else { loadVector.add(0); dailyOperation.add(false); } } weeklyLoadVector.add(loadVector); weeklyOperation.add(dailyOperation); }
@Override public void fillDailyOperation (int weekday) { // Initializing Variables loadVector = new Vector<Integer>(); dailyOperation = new Vector<Boolean>(); int k = gen.nextInt(cycleDuration); for (int i = 0; i < VillageConstants.QUARTERS_OF_DAY; i++) { if (i % cycleDuration == k) { loadVector.add(power); dailyOperation.add(true); } else { loadVector.add(0); dailyOperation.add(false); } } weeklyLoadVector.add(loadVector); weeklyOperation.add(dailyOperation); }
@Override public void fillDailyOperation (int weekday) { // Initializing Variables loadVector = new Vector<Integer>(); dailyOperation = new Vector<Boolean>(); int k = gen.nextInt(cycleDuration); for (int i = 0; i < VillageConstants.QUARTERS_OF_DAY; i++) { if (i % cycleDuration == k) { loadVector.add(power); dailyOperation.add(true); } else { loadVector.add(0); dailyOperation.add(false); } } weeklyLoadVector.add(loadVector); weeklyOperation.add(dailyOperation); }
@Override public void fillDailyOperation (int weekday) { // Initializing Variables loadVector = new Vector<Integer>(); dailyOperation = new Vector<Boolean>(); int k = gen.nextInt(cycleDuration); for (int i = 0; i < OfficeComplexConstants.QUARTERS_OF_DAY; i++) { if (i % cycleDuration == k) { loadVector.add(power); dailyOperation.add(true); } else { loadVector.add(0); dailyOperation.add(false); } } weeklyLoadVector.add(loadVector); weeklyOperation.add(dailyOperation); }
@Override void addLeisureWorking (int weekday) { // Create auxiliary variables ListIterator<Integer> iter = leisureVector.listIterator(); Status st; // Check each day on leisure vector while (iter.hasNext()) { if (iter.next() == weekday) { int start = workingStartHour + workingDuration; int startq = gen.nextInt(Math.max(1, VillageConstants.LEISURE_END_WINDOW - start)) + start; for (int i = startq; i < startq + leisureDuration; i++) { st = Status.Leisure; dailyRoutine.set(i, st); if (i == VillageConstants.QUARTERS_OF_DAY - 1) break; } } } }
int rand = gen.nextInt(temp.size()); int quarter = temp.get(rand);
@Override public void fillDailyOperation (int weekday) { // Initializing Variables loadVector = new Vector<Integer>(); dailyOperation = new Vector<Boolean>(); int k = gen.nextInt(cycleDuration); for (int i = 0; i < OfficeComplexConstants.QUARTERS_OF_DAY; i++) { loadVector.add(0); dailyOperation.add(false); } if (applianceOf.isWorkingDayOfWeek(weekday)) { for (int i = OfficeComplexConstants.COFFEE_MACHINE_START_OPERATION; i < OfficeComplexConstants.COFFEE_MACHINE_STOP_OPERATION; i++) { if (i % cycleDuration == k) { loadVector.set(i, power); dailyOperation.set(i, true); } else { loadVector.set(i, standByPower); dailyOperation.set(i, true); } } } weeklyLoadVector.add(loadVector); weeklyOperation.add(dailyOperation); }
/** * This function fills out the daily routine with the leisure activity of the * day, if there is one for the person in question for the certain weekday. * * @param weekday * @param gen */ void addLeisure (int weekday) { // Create auxiliary variables ListIterator<Integer> iter = leisureVector.listIterator(); Status st; while (iter.hasNext()) { if (iter.next() == weekday) { int start = VillageConstants.START_OF_LEISURE + gen.nextInt(VillageConstants.LEISURE_WINDOW); for (int i = start; i < start + leisureDuration; i++) { st = Status.Leisure; dailyRoutine.set(i, st); if (i == VillageConstants.QUARTERS_OF_DAY - 1) break; } } } }
@Override public void fillDailyOperation (int weekday) { // Initializing and Creating auxiliary variables loadVector = new Vector<Integer>(); dailyOperation = new Vector<Boolean>(); for (int i = 0; i < OfficeComplexConstants.QUARTERS_OF_DAY; i++) { dailyOperation.add(false); loadVector.add(0); } Vector<Integer> temp = new Vector<Integer>(); for (int i = 0; i < OfficeComplexConstants.QUARTERS_OF_DAY; i++) { int count = applianceOf.employeeNumber(weekday, i); for (int j = 0; j < count; j++) { temp.add(i); } } if (temp.size() > 0) { for (int i = 0; i < times; i++) { int rand = gen.nextInt(temp.size()); int quarter = temp.get(rand); dailyOperation.set(quarter, true); loadVector.set(quarter, (loadVector.get(quarter) + power)); temp.remove(rand); } } weeklyLoadVector.add(loadVector); weeklyOperation.add(dailyOperation); }
/** * This function is creating a certain number of RandomSeed days that will be * public vacation for the people living in the environment. * * @param days * @param gen * @return */ Vector<Integer> createPublicVacationVector (int days) { // Creating auxiliary variables Vector<Integer> v = new Vector<Integer>(days); for (int i = 0; i < days; i++) { int x = gen.nextInt(VillageConstants.DAYS_OF_COMPETITION + VillageConstants.DAYS_OF_BOOTSTRAP); ListIterator<Integer> iter = v.listIterator(); while (iter.hasNext()) { int temp = (int) iter.next(); if (x == temp) { x = x + 1; iter = v.listIterator(); } } v.add(x); } java.util.Collections.sort(v); return v; }
/** * This function is creating a certain number of random days that will be * public vacation for the people living in the environment. * * @param days * @param gen * @return */ Vector<Integer> createPublicVacationVector (int days) { // Creating auxiliary variables Vector<Integer> v = new Vector<Integer>(days); for (int i = 0; i < days; i++) { int x = gen.nextInt(OfficeComplexConstants.DAYS_OF_COMPETITION + OfficeComplexConstants.DAYS_OF_BOOTSTRAP); ListIterator<Integer> iter = v.listIterator(); while (iter.hasNext()) { int temp = (int) iter.next(); if (x == temp) { x = x + 1; iter = v.listIterator(); } } v.add(x); } java.util.Collections.sort(v); return v; }
/** * This function fills out the vector containing the days that the person is * going to be sick. When a person is sick he stays in bed. * * @param mean * @param dev * @return vector with sick days */ Vector<Integer> createSicknessVector (double mean, double dev) { // Create auxiliary variables int days = (int) (dev * gen.nextGaussian() + mean); Vector<Integer> v = new Vector<Integer>(days); for (int i = 0; i < days; i++) { int x = gen.nextInt(OfficeComplexConstants.DAYS_OF_COMPETITION + OfficeComplexConstants.DAYS_OF_BOOTSTRAP) + 1; ListIterator<Integer> iter = v.listIterator(); while (iter.hasNext()) { int temp = (int) iter.next(); if (x == temp) { x = x + 1; iter = v.listIterator(); } } v.add(x); } java.util.Collections.sort(v); return v; }
/** * This function is using the appliance's saturation in order to make a * possibility check and install or not the appliance in the current * household. * * @param app * @param gen * @return */ void checkProbability (Appliance app) { // Creating auxiliary variables int x = gen.nextInt(VillageConstants.PERCENTAGE); int threshold = (int) (app.getSaturation() * VillageConstants.PERCENTAGE); if (x < threshold) { app.fillWeeklyOperation(); app.createWeeklyPossibilityOperationVector(); } else this.appliances.remove(app); }
/** * This function is using the appliance's saturation in order to make a * possibility check and install or not the appliance in the current office. * * @param app */ void checkProbability (Appliance app) { // Creating auxiliary variables int x = gen.nextInt(OfficeComplexConstants.PERCENTAGE); int threshold = (int) (app.getSaturation() * OfficeComplexConstants.PERCENTAGE); if (x < threshold) { app.fillWeeklyOperation(); app.createWeeklyPossibilityOperationVector(); } else this.appliances.remove(app); }
private TariffEvaluator createTariffEvaluator () { TariffEvaluationWrapper wrapper = new TariffEvaluationWrapper(); TariffEvaluator te = new TariffEvaluator(wrapper); te.initializeInconvenienceFactors(config.getTouFactor(), config.getTieredRateFactor(), config.getVariablePricingFactor(), config.getInterruptibilityFactor()); double weight = generator.nextDouble() * config.getWeightInconvenience(); double expDuration = config.getMinDefaultDuration() + generator.nextInt(config.getMaxDefaultDuration() - config.getMinDefaultDuration()); te.withInconvenienceWeight(weight) .withInertia(config.getNsInertia()) .withPreferredContractDuration(expDuration) .withRationality(config.getRationalityFactor()) .withTariffEvalDepth(config.getTariffCount()) .withTariffSwitchFactor(config.getBrokerSwitchFactor()); te.initializeRegulationFactors(car.getHomeChargeKW() * car.getCurtailmentFactor(), car.getHomeChargeKW() * car.getDischargeFactor(), car.getHomeChargeKW() * car.getDownRegFactor()); return te; }