Examples of MrMachine


Examples of org.drools.planner.examples.machinereassignment.domain.MrMachine

            long machineCapacityId = 0L;
            List<MrMachineMoveCost> machineMoveCostList = new ArrayList<MrMachineMoveCost>(machineListSize * machineListSize);
            long machineMoveCostId = 0L;
            // 2 phases because service dependencies are not in low to high order
            for (int i = 0; i < machineListSize; i++) {
                MrMachine machine = new MrMachine();
                machine.setId(machineId);
                machineList.add(machine);
                machineId++;
            }
            for (int i = 0; i < machineListSize; i++) {
                MrMachine machine = machineList.get(i);
                String line = readStringValue();
                int moveCostOffset = 2 + (resourceListSize * 2);
                String[] lineTokens = splitBySpace(line, moveCostOffset + machineListSize);
                long neighborhoodId = Long.parseLong(lineTokens[0]);
                MrNeighborhood neighborhood = idToNeighborhoodMap.get(neighborhoodId);
                if (neighborhood == null) {
                    neighborhood = new MrNeighborhood();
                    neighborhood.setId(neighborhoodId);
                    neighborhoodList.add(neighborhood);
                    idToNeighborhoodMap.put(neighborhoodId, neighborhood);
                }
                machine.setNeighborhood(neighborhood);
                long locationId = Long.parseLong(lineTokens[1]);
                MrLocation location = idToLocationMap.get(locationId);
                if (location == null) {
                    location = new MrLocation();
                    location.setId(locationId);
                    locationList.add(location);
                    idToLocationMap.put(locationId, location);
                }
                machine.setLocation(location);
                List<MrMachineCapacity> machineCapacityListOfMachine
                        = new ArrayList<MrMachineCapacity>(resourceListSize);
                for (int j = 0; j < resourceListSize; j++) {
                    MrMachineCapacity machineCapacity = new MrMachineCapacity();
                    machineCapacity.setId(machineCapacityId);
                    machineCapacity.setMachine(machine);
                    machineCapacity.setResource(resourceList.get(j));
                    machineCapacity.setMaximumCapacity(Integer.parseInt(lineTokens[2 + j]));
                    machineCapacity.setSafetyCapacity(Integer.parseInt(lineTokens[2 + resourceListSize + j]));
                    machineCapacityList.add(machineCapacity);
                    machineCapacityListOfMachine.add(machineCapacity);
                    machineCapacityId++;
                }
                machine.setMachineCapacityList(machineCapacityListOfMachine);
                Map<MrMachine, MrMachineMoveCost> machineMoveCostMap
                        = new LinkedHashMap<MrMachine, MrMachineMoveCost>(machineListSize);
                for (int j = 0; j < machineListSize; j++) {
                    MrMachineMoveCost machineMoveCost = new MrMachineMoveCost();
                    machineMoveCost.setId(machineMoveCostId);
                    machineMoveCost.setFromMachine(machine);
                    MrMachine toMachine = machineList.get(j);
                    machineMoveCost.setToMachine(toMachine);
                    machineMoveCost.setMoveCost(Integer.parseInt(lineTokens[moveCostOffset + j]));
                    machineMoveCostList.add(machineMoveCost);
                    machineMoveCostMap.put(toMachine, machineMoveCost);
                    machineMoveCostId++;
View Full Code Here

Examples of org.drools.planner.examples.machinereassignment.domain.MrMachine

        Set<MrProcessAssignment> deadProcessAssignmentSet = new LinkedHashSet<MrProcessAssignment>(
                processAssignmentToPanelMap.keySet());
        for (MrProcessAssignment processAssignment : machineReassignment.getProcessAssignmentList()) {
            deadProcessAssignmentSet.remove(processAssignment);
            MrMachinePanel machinePanel = processAssignmentToPanelMap.get(processAssignment);
            MrMachine machine = processAssignment.getMachine();
            if (machinePanel != null
                    && !ObjectUtils.equals(machinePanel.getMachine(), machine)) {
                processAssignmentToPanelMap.remove(processAssignment);
                machinePanel.removeMrProcessAssignment(processAssignment);
                machinePanel = null;
View Full Code Here

Examples of org.drools.planner.examples.machinereassignment.domain.MrMachine

                        scoreDirector.afterEntityRemoved(processAssignment);
                    }
                }
                // Next remove it the planning fact itself
                for (Iterator<MrMachine> it = machineReassignment.getMachineList().iterator(); it.hasNext(); ) {
                    MrMachine workingMachine = it.next();
                    if (ObjectUtils.equals(workingMachine, machine)) {
                        scoreDirector.beforeProblemFactRemoved(workingMachine);
                        it.remove(); // remove from list
                        scoreDirector.beforeProblemFactRemoved(workingMachine);
                        break;
View Full Code Here

Examples of org.drools.planner.examples.machinereassignment.domain.MrMachine

            Set<MrProcessAssignment> deadProcessAssignmentSet = new LinkedHashSet<MrProcessAssignment>(
                    processAssignmentToPanelMap.keySet());
            for (MrProcessAssignment processAssignment : machineReassignment.getProcessAssignmentList()) {
                deadProcessAssignmentSet.remove(processAssignment);
                MrMachinePanel machinePanel = processAssignmentToPanelMap.get(processAssignment);
                MrMachine machine = processAssignment.getMachine();
                if (machinePanel != null
                        && !ObjectUtils.equals(machinePanel.getMachine(), machine)) {
                    processAssignmentToPanelMap.remove(processAssignment);
                    machinePanel.removeMrProcessAssignment(processAssignment);
                    machinePanel = null;
View Full Code Here

Examples of org.drools.planner.examples.machinereassignment.domain.MrMachine

                        scoreDirector.afterEntityRemoved(processAssignment);
                    }
                }
                // Next remove it the planning fact itself
                for (Iterator<MrMachine> it = machineReassignment.getMachineList().iterator(); it.hasNext(); ) {
                    MrMachine workingMachine = it.next();
                    if (ObjectUtils.equals(workingMachine, machine)) {
                        scoreDirector.beforeProblemFactRemoved(workingMachine);
                        it.remove(); // remove from list
                        scoreDirector.beforeProblemFactRemoved(workingMachine);
                        break;
View Full Code Here

Examples of org.drools.planner.examples.machinereassignment.domain.MrMachine

            long machineId = 0L;
            List<MrMachineCapacity> machineCapacityList = new ArrayList<MrMachineCapacity>(machineListSize * resourceListSize);
            long machineCapacityId = 0L;
            // 2 phases because service dependencies are not in low to high order
            for (int i = 0; i < machineListSize; i++) {
                MrMachine machine = new MrMachine();
                machine.setId(machineId);
                machineList.add(machine);
                machineId++;
            }
            for (int i = 0; i < machineListSize; i++) {
                MrMachine machine = machineList.get(i);
                String line = readStringValue();
                int moveCostOffset = 2 + (resourceListSize * 2);
                String[] lineTokens = splitBySpace(line, moveCostOffset + machineListSize);
                long neighborhoodId = Long.parseLong(lineTokens[0]);
                MrNeighborhood neighborhood = idToNeighborhoodMap.get(neighborhoodId);
                if (neighborhood == null) {
                    neighborhood = new MrNeighborhood();
                    neighborhood.setId(neighborhoodId);
                    neighborhoodList.add(neighborhood);
                    idToNeighborhoodMap.put(neighborhoodId, neighborhood);
                }
                machine.setNeighborhood(neighborhood);
                long locationId = Long.parseLong(lineTokens[1]);
                MrLocation location = idToLocationMap.get(locationId);
                if (location == null) {
                    location = new MrLocation();
                    location.setId(locationId);
                    locationList.add(location);
                    idToLocationMap.put(locationId, location);
                }
                machine.setLocation(location);
                List<MrMachineCapacity> machineCapacityListOfMachine
                        = new ArrayList<MrMachineCapacity>(resourceListSize);
                for (int j = 0; j < resourceListSize; j++) {
                    MrMachineCapacity machineCapacity = new MrMachineCapacity();
                    machineCapacity.setId(machineCapacityId);
                    machineCapacity.setMachine(machine);
                    machineCapacity.setResource(resourceList.get(j));
                    machineCapacity.setMaximumCapacity(Long.parseLong(lineTokens[2 + j]));
                    machineCapacity.setSafetyCapacity(Long.parseLong(lineTokens[2 + resourceListSize + j]));
                    machineCapacityList.add(machineCapacity);
                    machineCapacityListOfMachine.add(machineCapacity);
                    machineCapacityId++;
                }
                machine.setMachineCapacityList(machineCapacityListOfMachine);
                Map<MrMachine, Integer> machineMoveCostMap = new HashMap<MrMachine, Integer>(machineListSize);
                for (int j = 0; j < machineListSize; j++) {
                    MrMachine toMachine = machineList.get(j);
                    int moveCost = Integer.parseInt(lineTokens[moveCostOffset + j]);
                    machineMoveCostMap.put(toMachine, moveCost);
                }
                machine.setMachineMoveCostMap(machineMoveCostMap);
            }
View Full Code Here

Examples of org.drools.planner.examples.machinereassignment.domain.MrMachine

public class MrMachineProbabilityWeightFactory implements SelectionProbabilityWeightFactory<MrProcessAssignment> {

    public double createProbabilityWeight(ScoreDirector scoreDirector, MrProcessAssignment processAssignment) {
        MachineReassignment machineReassignment = (MachineReassignment) scoreDirector.getWorkingSolution();
        MrMachine machine = processAssignment.getMachine();
        // TODO reuse usage calculated by of the ScoreCalculator which is a delta
        long[] usage = new long[machineReassignment.getResourceList().size()];
        for (MrProcessAssignment someProcessAssignment : machineReassignment.getProcessAssignmentList()) {
            if (someProcessAssignment.getMachine() == machine) {
                MrProcess process = someProcessAssignment.getProcess();
                for (MrResource resource : machineReassignment.getResourceList()) {
                    usage[resource.getIndex()] += process.getUsage(resource);
                }
            }
        }
        double sum = 0.0;
        for (MrResource resource : machineReassignment.getResourceList()) {
            double available = (double)
                    (machine.getMachineCapacity(resource).getSafetyCapacity() - usage[resource.getIndex()]);
            sum += (available * available);
        }
        return sum + 1.0;
    }
View Full Code Here

Examples of org.drools.planner.examples.machinereassignment.domain.MrMachine

        machineScorePartMap = new HashMap<MrMachine, MrMachineScorePart>(machineList.size());
        for (MrMachine machine : machineList) {
            machineScorePartMap.put(machine, new MrMachineScorePart(machine));
        }
        for (MrProcessAssignment processAssignment : machineReassignment.getProcessAssignmentList()) {
            MrMachine originalMachine = processAssignment.getOriginalMachine();
            if (originalMachine != null) {
                machineScorePartMap.get(originalMachine).initOriginalProcessAssignment(processAssignment);
            }
        }
        for (MrProcessAssignment processAssignment : machineReassignment.getProcessAssignmentList()) {
View Full Code Here

Examples of org.drools.planner.examples.machinereassignment.domain.MrMachine

        // Do nothing
        // TODO the maps should probably be adjusted
    }

    private void insert(MrProcessAssignment processAssignment) {
        MrMachine machine = processAssignment.getMachine();
        if (machine != null) {
            MrServiceScorePart serviceScorePart = serviceScorePartMap.get(processAssignment.getService());
            serviceScorePart.addProcessAssignment(processAssignment);
            MrMachineScorePart machineScorePart = machineScorePartMap.get(machine);
            machineScorePart.addProcessAssignment(processAssignment);
View Full Code Here

Examples of org.drools.planner.examples.machinereassignment.domain.MrMachine

            machineScorePart.addProcessAssignment(processAssignment);
        }
    }

    private void retract(MrProcessAssignment processAssignment) {
        MrMachine machine = processAssignment.getMachine();
        if (machine != null) {
            MrServiceScorePart serviceScorePart = serviceScorePartMap.get(processAssignment.getService());
            serviceScorePart.removeProcessAssignment(processAssignment);
            MrMachineScorePart machineScorePart = machineScorePartMap.get(machine);
            machineScorePart.removeProcessAssignment(processAssignment);
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.