Package org.drools.planner.examples.pas.domain

Examples of org.drools.planner.examples.pas.domain.PatientAdmissionSchedule


import org.drools.planner.examples.pas.solver.move.BedDesignationSwapMove;

public class BedDesignationSwapMoveFactory extends CachedMoveFactory {

    public List<Move> createCachedMoveList(Solution solution) {
        PatientAdmissionSchedule patientAdmissionSchedule = (PatientAdmissionSchedule) solution;
        List<BedDesignation> bedDesignationList = patientAdmissionSchedule.getBedDesignationList();
        List<Move> moveList = new ArrayList<Move>();
        for (ListIterator<BedDesignation> leftIt = bedDesignationList.listIterator(); leftIt.hasNext();) {
            BedDesignation leftBedDesignation = leftIt.next();
            for (ListIterator<BedDesignation> rightIt = bedDesignationList.listIterator(leftIt.nextIndex());
                    rightIt.hasNext();) {
View Full Code Here


import org.apache.commons.lang.builder.CompareToBuilder;

public class BedDesignationPillarPartSwapMoveFactory extends AbstractMoveFactory {

    public List<Move> createMoveList(Solution solution) {
        PatientAdmissionSchedule patientAdmissionSchedule = (PatientAdmissionSchedule) solution;

        Map<Bed, List<BedDesignation>> bedToBedDesignationList = new HashMap<Bed, List<BedDesignation>>(
                patientAdmissionSchedule.getBedList().size());
        for (BedDesignation bedDesignation : patientAdmissionSchedule.getBedDesignationList()) {
            List<BedDesignation> bedDesignationListPerBed = bedToBedDesignationList.get(bedDesignation.getBed());
            if (bedDesignationListPerBed == null) {
                // Note: the initialCapacity is probably to high,
                // which is bad for memory, but the opposite is bad for performance (which is worse)
                bedDesignationListPerBed = new ArrayList<BedDesignation>(
                        patientAdmissionSchedule.getNightList().size());
                bedToBedDesignationList.put(bedDesignation.getBed(), bedDesignationListPerBed);
            }
            bedDesignationListPerBed.add(bedDesignation);
        }
        for (List<BedDesignation> bedDesignationListPerBed : bedToBedDesignationList.values()) {
            Collections.sort(bedDesignationListPerBed, new Comparator<BedDesignation>() {
                public int compare(BedDesignation a, BedDesignation b) {
                    // This comparison is sameBedInSameNight safe.
                    return new CompareToBuilder()
                            .append(a.getAdmissionPart().getFirstNight(), b.getAdmissionPart().getFirstNight())
                            .append(a.getAdmissionPart().getLastNight(), b.getAdmissionPart().getLastNight())
                            .append(a.getAdmissionPart(), b.getAdmissionPart())
                            .toComparison();
                }
            });
        }

        List<Bed> bedList = patientAdmissionSchedule.getBedList();
        List<Move> moveList = new ArrayList<Move>();

        // For every 2 distinct beds
        for (ListIterator<Bed> leftBedIt = bedList.listIterator(); leftBedIt.hasNext();) {
            Bed leftBed = leftBedIt.next();
View Full Code Here

import org.drools.planner.examples.pas.solver.move.BedChangeMove;

public class BedChangeMoveFactory extends CachedMoveFactory {

    public List<Move> createCachedMoveList(Solution solution) {
        PatientAdmissionSchedule patientAdmissionSchedule = (PatientAdmissionSchedule) solution;
        List<Bed> bedList = patientAdmissionSchedule.getBedList();
        List<Move> moveList = new ArrayList<Move>();
        for (BedDesignation bedDesignation : patientAdmissionSchedule.getBedDesignationList()) {
            for (Bed bed : bedList) {
                moveList.add(new BedChangeMove(bedDesignation, bed));
            }
        }
        return moveList;
View Full Code Here

        return (PatientAdmissionSchedule) solutionBusiness.getSolution();
    }

    public void resetPanel(Solution solution) {
        removeAll();
        PatientAdmissionSchedule patientAdmissionSchedule = (PatientAdmissionSchedule) solution;
        gridLayout.setColumns(patientAdmissionSchedule.getNightList().size() + 1);
        JLabel headerCornerLabel = new JLabel("Department_Room_Bed  \\  Night");
        headerCornerLabel.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createLineBorder(Color.DARK_GRAY),
                BorderFactory.createEmptyBorder(2, 2, 2, 2)));
        headerCornerLabel.setBackground(HEADER_COLOR);
        headerCornerLabel.setOpaque(true);
        add(headerCornerLabel);
        for (Night night : patientAdmissionSchedule.getNightList()) {
            JLabel nightLabel = new JLabel(night.toString());
            nightLabel.setBorder(BorderFactory.createCompoundBorder(
                    BorderFactory.createLineBorder(Color.DARK_GRAY),
                    BorderFactory.createEmptyBorder(2, 2, 2, 2)));
            nightLabel.setBackground(HEADER_COLOR);
            nightLabel.setOpaque(true);
            add(nightLabel);
        }
        Map<Bed, Map<Night, BedNightPanel>> bedNightPanelMap = new HashMap<Bed, Map<Night, BedNightPanel>>();
        for (Bed bed : patientAdmissionSchedule.getBedList()) {
            createBedLine(patientAdmissionSchedule, bedNightPanelMap, bed);
        }
        createBedLine(patientAdmissionSchedule, bedNightPanelMap, null);
        for (BedDesignation bedDesignation : patientAdmissionSchedule.getBedDesignationList()) {
            for (Night night : patientAdmissionSchedule.getNightList()) {
                if (bedDesignation.getAdmissionPart().getFirstNight().getIndex() <= night.getIndex()
                        && night.getIndex() <= bedDesignation.getAdmissionPart().getLastNight().getIndex()) {
                    BedNightPanel bedNightPanel = bedNightPanelMap.get(bedDesignation.getBed()).get(night);
                    bedNightPanel.addBedDesignation(bedDesignation);
                }
View Full Code Here

import org.apache.commons.lang.builder.CompareToBuilder;

public class BedDesignationPillarPartSwitchMoveFactory extends AbstractMoveFactory {

    public List<Move> createMoveList(Solution solution) {
        PatientAdmissionSchedule patientAdmissionSchedule = (PatientAdmissionSchedule) solution;

        Map<Bed, List<BedDesignation>> bedToBedDesignationList = new HashMap<Bed, List<BedDesignation>>(
                patientAdmissionSchedule.getBedList().size());
        for (BedDesignation bedDesignation : patientAdmissionSchedule.getBedDesignationList()) {
            List<BedDesignation> bedDesignationListPerBed = bedToBedDesignationList.get(bedDesignation.getBed());
            if (bedDesignationListPerBed == null) {
                // Note: the initialCapacity is probably to high,
                // which is bad for memory, but the opposite is bad for performance (which is worse)
                bedDesignationListPerBed = new ArrayList<BedDesignation>(
                        patientAdmissionSchedule.getNightList().size());
                bedToBedDesignationList.put(bedDesignation.getBed(), bedDesignationListPerBed);
            }
            bedDesignationListPerBed.add(bedDesignation);
        }
        for (List<BedDesignation> bedDesignationListPerBed : bedToBedDesignationList.values()) {
            Collections.sort(bedDesignationListPerBed, new Comparator<BedDesignation>() {
                public int compare(BedDesignation a, BedDesignation b) {
                    // This comparison is sameBedInSameNight safe.
                    return new CompareToBuilder()
                            .append(a.getAdmissionPart().getFirstNight(), b.getAdmissionPart().getFirstNight())
                            .append(a.getAdmissionPart().getLastNight(), b.getAdmissionPart().getLastNight())
                            .append(a.getAdmissionPart(), b.getAdmissionPart())
                            .toComparison();
                }
            });
        }

        List<Bed> bedList = patientAdmissionSchedule.getBedList();
        List<Move> moveList = new ArrayList<Move>();

        // For every 2 distinct beds
        for (ListIterator<Bed> leftBedIt = bedList.listIterator(); leftBedIt.hasNext();) {
            Bed leftBed = leftBedIt.next();
View Full Code Here

        return (PatientAdmissionSchedule) solutionBusiness.getSolution();
    }

    public void resetPanel() {
        removeAll();
        PatientAdmissionSchedule patientAdmissionSchedule = getPatientAdmissionSchedule();
        gridLayout.setColumns(patientAdmissionSchedule.getNightList().size() + 1);
        JLabel headerCornerLabel = new JLabel("Department_Room_Bed  \\  Night");
        headerCornerLabel.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createLineBorder(Color.DARK_GRAY),
                BorderFactory.createEmptyBorder(2, 2, 2, 2)));
        headerCornerLabel.setBackground(HEADER_COLOR);
        headerCornerLabel.setOpaque(true);
        add(headerCornerLabel);
        for (Night night : patientAdmissionSchedule.getNightList()) {
            JLabel nightLabel = new JLabel(night.toString());
            nightLabel.setBorder(BorderFactory.createCompoundBorder(
                    BorderFactory.createLineBorder(Color.DARK_GRAY),
                    BorderFactory.createEmptyBorder(2, 2, 2, 2)));
            nightLabel.setBackground(HEADER_COLOR);
            nightLabel.setOpaque(true);
            add(nightLabel);
        }
        Map<Bed, Map<Night, BedNightPanel>> bedNightPanelMap = new HashMap<Bed, Map<Night, BedNightPanel>>();
        for (Bed bed : patientAdmissionSchedule.getBedList()) {
            JLabel bedLabel = new JLabel(bed.toString());
            bedLabel.setBorder(BorderFactory.createCompoundBorder(
                    BorderFactory.createLineBorder(Color.DARK_GRAY),
                    BorderFactory.createEmptyBorder(2, 2, 2, 2)));
            bedLabel.setBackground(HEADER_COLOR);
            bedLabel.setOpaque(true);
            add(bedLabel);
            Map<Night, BedNightPanel> nightPanelMap = new HashMap<Night, BedNightPanel>();
            bedNightPanelMap.put(bed, nightPanelMap);
            for (Night night : patientAdmissionSchedule.getNightList()) {
                BedNightPanel bedNightPanel = new BedNightPanel();
                add(bedNightPanel);
                nightPanelMap.put(night, bedNightPanel);
            }
        }
        if (patientAdmissionSchedule.isInitialized()) {
            for (BedDesignation bedDesignation : patientAdmissionSchedule.getBedDesignationList()) {
                for (Night night : patientAdmissionSchedule.getNightList()) {
                    if (bedDesignation.getAdmissionPart().getFirstNight().getIndex() <= night.getIndex()
                            && night.getIndex() <= bedDesignation.getAdmissionPart().getLastNight().getIndex()) {
                        BedNightPanel bedNightPanel = bedNightPanelMap.get(bedDesignation.getBed()).get(night);
                        bedNightPanel.addBedDesignation(bedDesignation);
                    }
View Full Code Here

    private boolean checkSameBedInSameNight = true;

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

        PatientAdmissionSchedule patientAdmissionSchedule = (PatientAdmissionSchedule) abstractSolverScope.getWorkingSolution();
        return patientAdmissionSchedule.isInitialized();
    }

    public void initializeSolution(AbstractSolverScope abstractSolverScope) {
        PatientAdmissionSchedule patientAdmissionSchedule = (PatientAdmissionSchedule)
                abstractSolverScope.getWorkingSolution();
        initializeBedDesignationList(abstractSolverScope, patientAdmissionSchedule);
    }
View Full Code Here

import org.drools.planner.examples.pas.solver.move.BedDesignationSwitchMove;

public class BedDesignationSwitchMoveFactory extends CachedMoveFactory {

    public List<Move> createCachedMoveList(Solution solution) {
        PatientAdmissionSchedule patientAdmissionSchedule = (PatientAdmissionSchedule) solution;
        List<BedDesignation> bedDesignationList = patientAdmissionSchedule.getBedDesignationList();
        List<Move> moveList = new ArrayList<Move>();
        for (ListIterator<BedDesignation> leftIt = bedDesignationList.listIterator(); leftIt.hasNext();) {
            BedDesignation leftBedDesignation = leftIt.next();
            for (ListIterator<BedDesignation> rightIt = bedDesignationList.listIterator(leftIt.nextIndex());
                    rightIt.hasNext();) {
View Full Code Here

        private Map<Integer, Equipment> indexToEquipmentMap = null;
        private Map<Long, Room> idToRoomMap = null;
        private Map<Integer, Night> indexToNightMap = null;

        public Solution readSolution() throws IOException {
            patientAdmissionSchedule = new PatientAdmissionSchedule();
            patientAdmissionSchedule.setId(0L);
            readSizes();
            readEmptyLine();
            readEmptyLine();
            readSpecialismList();
View Full Code Here

TOP

Related Classes of org.drools.planner.examples.pas.domain.PatientAdmissionSchedule

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.