Package org.drools.planner.examples.cloudbalancing.domain

Examples of org.drools.planner.examples.cloudbalancing.domain.CloudBalance


import org.drools.planner.examples.cloudbalancing.solver.move.CloudProcessSwapMove;

public class CloudProcessSwapMoveFactory extends CachedMoveFactory {

    public List<Move> createCachedMoveList(Solution solution) {
        CloudBalance cloudBalance = (CloudBalance) solution;
        List<CloudProcess> cloudProcessList = cloudBalance.getProcessList();
        List<Move> moveList = new ArrayList<Move>();
        for (ListIterator<CloudProcess> leftIt = cloudProcessList.listIterator(); leftIt.hasNext();) {
            CloudProcess leftCloudProcess = leftIt.next();
            for (ListIterator<CloudProcess> rightIt = cloudProcessList.listIterator(leftIt.nextIndex()); rightIt.hasNext();) {
                CloudProcess rightCloudProcess = rightIt.next();
View Full Code Here


import org.drools.planner.examples.cloudbalancing.solver.move.CloudComputerChangeMove;

public class CloudComputerChangeMoveFactory extends CachedMoveFactory {

    public List<Move> createCachedMoveList(Solution solution) {
        CloudBalance cloudBalance = (CloudBalance) solution;
        List<Move> moveList = new ArrayList<Move>();
        List<CloudComputer> cloudComputerList = cloudBalance.getComputerList();
        for (CloudProcess cloudProcess : cloudBalance.getProcessList()) {
            for (CloudComputer cloudComputer : cloudComputerList) {
                moveList.add(new CloudComputerChangeMove(cloudProcess, cloudComputer));
            }
        }
        return moveList;
View Full Code Here

        updatePanel(solution);
    }

    @Override
    public void updatePanel(Solution solution) {
        CloudBalance cloudBalance = (CloudBalance) solution;
        Set<CloudComputer> deadCloudComputerSet = new LinkedHashSet<CloudComputer>(computerToPanelMap.keySet());
        deadCloudComputerSet.remove(null);
        for (CloudComputer computer : cloudBalance.getComputerList()) {
            deadCloudComputerSet.remove(computer);
            CloudComputerPanel computerPanel = computerToPanelMap.get(computer);
            if (computerPanel == null) {
                computerPanel = new CloudComputerPanel(this, computer);
                computersPanel.add(computerPanel);
                computerToPanelMap.put(computer, computerPanel);
            }
        }
        Set<CloudProcess> deadCloudProcessSet = new LinkedHashSet<CloudProcess>(
                processToPanelMap.keySet());
        for (CloudProcess process : cloudBalance.getProcessList()) {
            deadCloudProcessSet.remove(process);
            CloudComputerPanel computerPanel = processToPanelMap.get(process);
            CloudComputer computer = process.getComputer();
            if (computerPanel != null
                    && !ObjectUtils.equals(computerPanel.getComputer(), computer)) {
View Full Code Here

    public void deleteComputer(final CloudComputer computer) {
        logger.info("Scheduling delete of computer ({}).", computer);
        solutionBusiness.doProblemFactChange(new ProblemFactChange() {
            public void doChange(ScoreDirector scoreDirector) {
                CloudBalance cloudBalance = (CloudBalance) scoreDirector.getWorkingSolution();
                // First remove the planning fact from all planning entities that use it
                for (CloudProcess process : cloudBalance.getProcessList()) {
                    if (ObjectUtils.equals(process.getComputer(), computer)) {
                        // TODO HACK we are removing it because it becomes uninitialized,
                        // which means it has to be retracted
                        // This is nonsense from a ProblemFactChange point of view, FIXME!
                        scoreDirector.beforeEntityRemoved(process);
                        process.setComputer(null);
                        scoreDirector.afterEntityRemoved(process);
                    }
                }
                // Next remove it the planning fact itself
                for (Iterator<CloudComputer> it = cloudBalance.getComputerList().iterator(); it.hasNext(); ) {
                    CloudComputer workingComputer = it.next();
                    if (ObjectUtils.equals(workingComputer, computer)) {
                        scoreDirector.beforeProblemFactRemoved(workingComputer);
                        it.remove(); // remove from list
                        scoreDirector.beforeProblemFactRemoved(workingComputer);
View Full Code Here

    }

    private void writeCloudBalance(int cloudComputerListSize, int cloudProcessListSize) {
        String outputFileName = "unsolvedCloudBalance" + cloudComputerListSize + "-" + cloudProcessListSize + ".xml";
        File outputFile = new File(outputDir, outputFileName);
        CloudBalance cloudBalance = createCloudBalance(cloudComputerListSize, cloudProcessListSize);
        solutionDao.writeSolution(cloudBalance, outputFile);
    }
View Full Code Here

        solutionDao.writeSolution(cloudBalance, outputFile);
    }

    private CloudBalance createCloudBalance(int cloudComputerListSize, int cloudProcessListSize) {
        random = new Random(37);
        CloudBalance cloudBalance = new CloudBalance();
        cloudBalance.setId(0L);
        cloudBalance.setCloudComputerList(createCloudComputerList(cloudComputerListSize));
        cloudBalance.setCloudProcessList(createCloudProcessList(cloudProcessListSize));
        return cloudBalance;
    }
View Full Code Here

public class CloudBalancingStartingSolutionInitializer extends AbstractStartingSolutionInitializer {

    @Override
    public boolean isSolutionInitialized(AbstractSolverScope abstractSolverScope) {
        CloudBalance cloudBalance = (CloudBalance) abstractSolverScope.getWorkingSolution();
        return cloudBalance.isInitialized();
    }
View Full Code Here

        CloudBalance cloudBalance = (CloudBalance) abstractSolverScope.getWorkingSolution();
        return cloudBalance.isInitialized();
    }

    public void initializeSolution(AbstractSolverScope abstractSolverScope) {
        CloudBalance cloudBalance = (CloudBalance) abstractSolverScope.getWorkingSolution();
        initializeCloudAssignmentList(abstractSolverScope, cloudBalance);
    }
View Full Code Here

import org.drools.planner.examples.cloudbalancing.solver.move.CloudAssignmentSwitchMove;

public class CloudAssignmentSwitchMoveFactory extends CachedMoveFactory {

    public List<Move> createCachedMoveList(Solution solution) {
        CloudBalance cloudBalance = (CloudBalance) solution;
        List<CloudAssignment> cloudAssignmentList = cloudBalance.getCloudAssignmentList();
        List<Move> moveList = new ArrayList<Move>();
        for (ListIterator<CloudAssignment> leftIt = cloudAssignmentList.listIterator(); leftIt.hasNext();) {
            CloudAssignment leftCloudAssignment = leftIt.next();
            for (ListIterator<CloudAssignment> rightIt = cloudAssignmentList.listIterator(leftIt.nextIndex()); rightIt.hasNext();) {
                CloudAssignment rightCloudAssignment = rightIt.next();
View Full Code Here

import org.drools.planner.examples.cloudbalancing.solver.move.CloudComputerChangeMove;

public class CloudComputerChangeMoveFactory extends CachedMoveFactory {

    public List<Move> createCachedMoveList(Solution solution) {
        CloudBalance cloudBalance = (CloudBalance) solution;
        List<Move> moveList = new ArrayList<Move>();
        List<CloudComputer> cloudComputerList = cloudBalance.getCloudComputerList();
        for (CloudAssignment cloudAssignment : cloudBalance.getCloudAssignmentList()) {
            for (CloudComputer cloudComputer : cloudComputerList) {
                moveList.add(new CloudComputerChangeMove(cloudAssignment, cloudComputer));
            }
        }
        return moveList;
View Full Code Here

TOP

Related Classes of org.drools.planner.examples.cloudbalancing.domain.CloudBalance

Copyright © 2018 www.massapicom. 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.