Examples of PeriodPowerPrice


Examples of org.optaplanner.examples.cheaptime.domain.PeriodPowerPrice

                    } else {
                        if (previousStatus != MachinePeriodStatus.OFF) {
                            if (previousStatus == MachinePeriodStatus.ACTIVE) {
                                lastSpinDown = i - 1;
                            }
                            PeriodPowerPrice periodPowerPrice = periodPowerPriceList.get(i);
                            idleCostMicros += CheapTimeCostCalculator.multiplyTwoMicros(
                                    machine.getPowerConsumptionMicros(), periodPowerPrice.getPowerPriceMicros());
                            if (idleCostMicros > machine.getSpinUpDownCostMicros()) {
                                idleCostMicros = 0L;
                                previousStatus = MachinePeriodStatus.OFF;
                            } else {
                                previousStatus = MachinePeriodStatus.IDLE;
View Full Code Here

Examples of org.optaplanner.examples.cheaptime.domain.PeriodPowerPrice

                List<MachinePeriodPart> machinePeriodList = machinePeriodListMap.get(machine);
                int endPeriod = taskAssignment.getEndPeriod();
                for (int period = startPeriod; period < endPeriod; period++) {
                    MachinePeriodPart machinePeriodPart = machinePeriodList.get(period);
                    machinePeriodPart.addTaskAssignment(taskAssignment);
                    PeriodPowerPrice periodPowerPrice = periodPowerPriceList.get(period);
                    mediumScore -= CheapTimeCostCalculator.multiplyTwoMicros(taskAssignment.getTask().getPowerConsumptionMicros(),
                            periodPowerPrice.getPowerPriceMicros());
                }
                softScore -= startPeriod;
            }
        }
        long hardScore = 0L;
        for (Map.Entry<Machine, List<MachinePeriodPart>> entry : machinePeriodListMap.entrySet()) {
            Machine machine = entry.getKey();
            List<MachinePeriodPart> machinePeriodList = entry.getValue();
            MachinePeriodStatus previousStatus = MachinePeriodStatus.OFF;
            long idleCostMicros = 0L;
            for (int period = 0; period < globalPeriodRangeTo; period++) {
                PeriodPowerPrice periodPowerPrice = periodPowerPriceList.get(period);
                MachinePeriodPart machinePeriodPart = machinePeriodList.get(period);
                boolean active = machinePeriodPart.isActive();
                if (active) {
                    if (previousStatus == MachinePeriodStatus.OFF) {
                        // Spin up
                        mediumScore -= machine.getSpinUpDownCostMicros();
                    } else if (previousStatus == MachinePeriodStatus.IDLE) {
                        // Pay idle cost
                        mediumScore -= idleCostMicros;
                        idleCostMicros = 0L;
                    }
                    hardScore += machinePeriodPart.getHardScore();
                    mediumScore -= CheapTimeCostCalculator.multiplyTwoMicros(machine.getPowerConsumptionMicros(),
                            periodPowerPrice.getPowerPriceMicros());
                    previousStatus = MachinePeriodStatus.ACTIVE;
                } else {
                    if (previousStatus != MachinePeriodStatus.OFF) {
                        idleCostMicros += CheapTimeCostCalculator.multiplyTwoMicros(machine.getPowerConsumptionMicros(),
                                periodPowerPrice.getPowerPriceMicros());
                        if (idleCostMicros > machine.getSpinUpDownCostMicros()) {
                            idleCostMicros = 0L;
                            previousStatus = MachinePeriodStatus.OFF;
                        } else {
                            previousStatus = MachinePeriodStatus.IDLE;
View Full Code Here

Examples of org.optaplanner.examples.cheaptime.domain.PeriodPowerPrice

                        CheapTimeCostCalculator.toMicroCost(1440),
                        CheapTimeCostCalculator.toMicroCost(periodListSize * 60L));
                List<PeriodPowerPrice> periodPowerPriceList = new ArrayList<PeriodPowerPrice>(periodListSize);
                for (int i = 0; i < periodListSize; i++) {
                    String[] lineTokens = splitBySpacesOrTabs(readStringValue(), 2);
                    PeriodPowerPrice periodPowerPrice = new PeriodPowerPrice();
                    int period = Integer.parseInt(lineTokens[0]);
                    if (periodPowerPriceList.size() != period) {
                        throw new IllegalStateException("The forecast period (" + period
                                + ") does not increment normally and gets a different list index ("
                                + periodPowerPriceList.size() + ").");
                    }
                    periodPowerPrice.setId((long) period);
                    periodPowerPrice.setPeriod(period);
                    long hourlyPowerPriceMicros = CheapTimeCostCalculator.parseMicroCost(lineTokens[1]);
                    periodPowerPrice.setPowerPriceMicros(
                            CheapTimeCostCalculator.multiplyTwoMicros(hourlyPowerPriceMicros, periodDurationPerHour));
                    periodPowerPriceList.add(periodPowerPrice);
                }
                solution.setPeriodPowerPriceList(periodPowerPriceList);
                return null; // Hack so the code can reuse read methods from TxtInputBuilder
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.