Examples of Assignment


Examples of de.timefinder.data.algo.Assignment

        assertEquals(0, eventRaster.getNextFree(0, 1));
    }

    @Test
    public void testRemoveAndAdd() {
        Assignment event1 = newAssignment(0, 5);
        assertTrue(eventRaster.add(event1));
        assertEquals(5, eventRaster.getNextFree(0, 1));

        assertTrue(eventRaster.remove(event1));
        event1.setStart(1);
        assertTrue(eventRaster.add(event1));
        assertEquals(0, eventRaster.getNextFree(0, 1));
    }
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

        assertEquals(0, eventRaster.getNextFree(0, 1));
    }

    @Test
    public void testRemove() {
        Assignment event1 = newAssignment("1", 0, 5);
        Assignment event2 = newAssignment("2", 0, 5);

        assertTrue(eventRaster.add(event1));
        assertTrue(eventRaster.add(event2));

        assertEquals(2, eventRaster.getConflictingAssignments(0, 1).size());
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

        assertEquals(0, eventRaster.getConflictingAssignments(0, 1).size());
    }

    @Test
    public void testGetConflictingEvents() {
        Assignment rootEvent = newAssignment(10, 1);
        eventRaster.setRoot(rootEvent);

        Assignment event1 = newAssignment(0, 5);
        assertTrue(eventRaster.add(event1));

        Assignment event2 = newAssignment(4, 3);
        assertTrue(eventRaster.add(event2));

        assertEquals(2, eventRaster.getConflictingAssignments(4, 1).size());
        assertEquals(2, eventRaster.getConflictingAssignments(4, 2).size());
        assertEquals(2, eventRaster.getConflictingAssignments(3, 2).size());
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

        assertEquals(2, eventRaster.getConflictingAssignments(9, 2).size());
    }

    @Test
    public void testGetConflictingEventsIndices2() {
        Assignment ev1 = newAssignment(1, 2);
        assertTrue(eventRaster.add(ev1));

        Assignment ev2 = newAssignment(0, 3);
        assertTrue(eventRaster.add(ev2));

        Collection<Assignment> events = eventRaster.getConflictingAssignments(0, 1);
        assertEquals(1, events.size());
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

    @Test
    public void testGetLastFreePlus1() {
        assertEquals(LENGTH, eventRaster.getLastFreePlus1(0));

        Assignment ev1 = newAssignment(1, 1);
        assertTrue(eventRaster.add(ev1));
        assertEquals(1, eventRaster.getLastFreePlus1(0));
        assertEquals(LENGTH, eventRaster.getLastFreePlus1(2));

        // undefined if the starting slot is already assigned
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

    }

    @Override
    public void transformEvents(Map<Event, Assignment> map) {
        for (Event ev : events) {
            Assignment as = map.get(ev);
            if (as == null)
                throw new NullPointerException("Cannot find assignment for:" + ev);

            assignments.add(as);
        }
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

        this.raster = raster;
    }

    @Override
    public int getViolations(Object obj) {
        Assignment ass = (Assignment) obj;
        if (ass.getStart() < 0)
            return 0;

        int counter = 0;
        Event ev = ass.getEvent();
        BitRaster refRaster = getRaster().getForbidden();
        int end = ass.getStart() + ev.getDuration();
        for (int i = ass.getStart(); i < end; i++) {
            if (refRaster.isAssigned(i))
                counter++;
        }
        return counter;
    }
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

            if (person.getEvents().size() == 0)
                continue;

            Set<Assignment> set = FastSet.newInstance();
            for (Event event : person.getEvents()) {
                Assignment ass = eventToAss.get(event);
                if (ass == null) {
                    ass = new Assignment(event);
                    eventToAss.put(event, ass);
                }
                set.add(ass);
            }
            personToAssignments.put(person, set);
        }
        for (Person person : persons) {
            for (Constraint c : person.getConstraints()) {
                c.transformEvents(eventToAss);
            }
        }

        conflictMatrix = new ConflictMatrix(dataPoolSettings.getTimeslotsPerWeek(), dataPoolSettings.getTimeslotsPerDay());

        // TODO LATER: use only as many assignment as it should (e.g. if a course is splitted into several sections)      
        List<Assignment> allAssignments = new ArrayList<Assignment>(conflictMatrix.initFromResources(personToAssignments));

        doIntegrityChecks(allAssignments, allLocations);

        logger.info("Start Algorithm - number of slots per week:" + dataPoolSettings.getTimeslotsPerWeek()
                + "; number of slots per day:" + dataPoolSettings.getTimeslotsPerDay()
                + "; events:" + allAssignments.size()
                + "; persons:" + personToAssignments.size()
                + "; locations:" + allLocations.size());

        Map<Assignment, Set<Assignment>> followers = FastMap.newInstance();
        Map<Assignment, Set<Assignment>> befores = FastMap.newInstance();
        for (Assignment ass : allAssignments) {
            if (ass.getEvent().getPersons().size() == 0)
                logger.fatal("relationship events to persons has to be bidirectional!" + ass);

            // TODO put this 'calculation' into OrderConstraint class
            befores.put(ass, createBeforesAssignments(ass, allAssignments));
            followers.put(ass, createFollowsAssignments(ass, allAssignments));

            for (Constraint constr : ass.getEvent().getConstraints()) {
                if (constr instanceof DifferentDayConstraint
                        || constr instanceof MinGapsConstraint) {
                    constr.transformEvents(eventToAss);
                }
            }
        }

        Period currentWeek = new Period(dataPoolSettings.getTimeslotsPerWeek(),
                allAssignments, befores, followers,
                allLocations, personToAssignments, conflictMatrix);
        currentWeek.setRandom(random);

        if (initialize) {
            for (Assignment ass : allAssignments) {
                if (ass.getStart() >= 0) {
                    if (!currentWeek.add(ass, ass.getStart())) {
                        currentWeek.add(ass, -1);
                    }
                } else
                    currentWeek.add(ass, -1);
            }
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

        return events;
    }

    @Override
    public int getViolations(Object obj) {
        Assignment assToCalc = (Assignment) obj;
        int slotsPerDay = settings.getTimeslotsPerDay();
        int day = assToCalc.getStart() / slotsPerDay;

        int counter = 0;
        for (Assignment ass : assignments) {
            if (ass.getEvent() == assToCalc.getEvent())
                continue;

            if (ass.getStart() / slotsPerDay == day)
                counter += ass.getEvent().getDuration();
        }
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

    @Override
    public void transformEvents(Map<Event, Assignment> map) {
        assignments = new ArrayList<Assignment>(events.size());
        for (Event ev : events) {
            Assignment as = map.get(ev);
            if (as == null)
                throw new NullPointerException("Cannot find assignment for:" + ev);
            assignments.add(as);
        }
    }
View Full Code Here
TOP
Copyright © 2015 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.