Examples of Assignment


Examples of de.timefinder.data.algo.Assignment

        assertEquals(locForEvent1, event1.getLocation());
    }

    @Test
    public void testGetLocation() {
        Assignment event1 = newAssignment(0, 1);
        assertEquals(loc1, aManager.calculateLocation(event1));
    }
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

    @Test
    public void testRollbackDoMove() {
        System.out.println("testRollback");

        Assignment ev = newAssignment(-1, 1);
        conflictingMatrix.initAssignments(Collections.singletonList(ev));
        assertTrue(periode.add(ev, 0));
        assertEquals(0, periode.getEventMoveStack().size());
        assertTrue(periode.doMove(ev, 1));
        assertEquals(1, periode.getEventMoveStack().size());
        periode.rollback(0);
        assertEquals(0, ev.getStart());
        assertEquals(0, periode.getEventMoveStack().size());
    }
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

    public void testAssignToLocation() {
        Location loc2 = newLocation("loc2", 5);
        allLocations.add(loc2);
        aManager = new AssignmentManager(0, allLocations);

        Assignment event1 = newAssignment(0, 1);
        assertNotNull(aManager.forceAssignment(event1, loc1));
        assertEquals(loc1, event1.getLocation());

        // TODO reassignment not possible at the moment
        Assignment event2 = newAssignment(0, 1);
        assertNull(aManager.forceAssignment(event2, loc1));
        assertEquals(loc1, event1.getLocation());
        assertEquals(null, event2.getLocation());
    }
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

        // the test week is a bit smaller
        int slotsPerWeek = 2;
        int slotsPerDay = 2;

        final Assignment a = newAssignment("a", -1, 1);
        final Assignment b = newAssignment("b", -1, 1);
        final Assignment c = newAssignment("c", -1, 1);

        ConflictMatrix matrix = new ConflictMatrix(slotsPerWeek, slotsPerDay);
        Map<Resource, Set<Assignment>> resources = newResources(Arrays.asList(a, b), Arrays.asList(a, c));

        matrix.initFromResources(resources);
        Location loc1 = new Location(10);
        Location loc2 = new Location(5);
        List locations = Arrays.asList(loc1, loc2);

        periode = newPeriod(slotsPerWeek, locations, matrix);

        assertTrue(periode.add(b, 0));
        assertEquals(loc1, b.getLocation());
        assertTrue(periode.add(c, 1));
        assertEquals(loc1, c.getLocation());
        periode.add(a, -1);

        // no more free slots are available for event A
        assertEquals(-1, matrix.getConflictingRaster(a).getLastFreePlus1(0));
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

        int slotsPerWeek = 3;
        int slotsPerDay = 3;
        settings.setTimeslotsPerDay(slotsPerDay);
        settings.setNumberOfDays(slotsPerWeek / slotsPerDay);

        final Assignment a = newAssignment("a", -1, 1);
        final Assignment b = newAssignment("b", -1, 1);
        final Assignment c = newAssignment("c", -1, 1);
        final Assignment d = newAssignment("d", -1, 1);
        d.getEvent().putConstraint(newForbidden(1, 2));

        final int LIMITING_CAPACITY = 5;

        ConflictMatrix matrix = new ConflictMatrix(slotsPerWeek, slotsPerDay);
        Map<Resource, Set<Assignment>> resources = newResources(Arrays.asList(d, b), Arrays.asList(d, a), Arrays.asList(c));
        matrix.initFromResources(resources);

        // add more visiors => force d into location with 10 seats
        for (int i = 0; i < LIMITING_CAPACITY + 1; i++) {
            b.getEvent().addPerson(new Person(), true);
            c.getEvent().addPerson(new Person(), true);
        }

        List locations = Arrays.asList(new Location(10), new Location(LIMITING_CAPACITY));

        periode = newPeriod(slotsPerWeek, locations, matrix);

        assertTrue(periode.add(b, 0));
        assertTrue(periode.add(a, 0));
        assertTrue(periode.add(c, 1));
        periode.add(d, -1);
        assertEquals(true, d.getStart() < 0);
        int depth = 2;
        int collidingAssignment = 2;

        assertEquals(true, periode.inject(d, depth, collidingAssignment));
        assertEquals(0, d.getStart());
    }
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

    public void testTestAssignToLocation() {
        Location loc2 = newLocation("loc2", 5);
        allLocations.add(loc2);
        aManager = new AssignmentManager(0, allLocations);

        Assignment event1 = newAssignment(0, 1);
        assertEquals(true, aManager.isForcedAssignmentPossible(event1, loc1));
        assertEquals(true, aManager.isForcedAssignmentPossible(event1, loc2));

        // with reassignment
        Assignment event2 = newAssignment(0, 1);
        assertNotNull(aManager.assign(event1));
        assertEquals(true, aManager.isForcedAssignmentPossible(event2, loc1));
        assertEquals(true, aManager.isForcedAssignmentPossible(event2, loc2));
    }
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

        Location loc2 = newLocation("loc2", 5);
        allLocations.add(loc2);
        aManager = new AssignmentManager(0, allLocations);

        // we can only reassign events which will be 'consumed'
        Assignment ass1 = newAssignment(0, 2);
        assertNotNull(aManager.assign(ass1));
        assertEquals(loc1, ass1.getLocation());

        Assignment ass2 = newAssignment(0, 2);
        assertEquals(true, aManager.isForcedAssignmentPossible(ass2, loc2));
        assertEquals(true, aManager.isForcedAssignmentPossible(ass2, loc1));

        // if one assignment exists with end < ass2.end
        ass2.getEvent().setDuration(1);
        assertEquals(true, aManager.isForcedAssignmentPossible(ass2, loc2));
        assertEquals(true, aManager.isForcedAssignmentPossible(ass2, loc1));
    }
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

        int slotsPerWeek = 2;
        int slotsPerDay = 2;
        settings.setTimeslotsPerDay(slotsPerDay);
        settings.setNumberOfDays(slotsPerWeek / slotsPerDay);

        final Assignment a = newAssignment("a", -1, 1);
        final Assignment b = newAssignment("b", -1, 1);
        final Assignment c = newAssignment("c", -1, 1);

        ConflictMatrix matrix = new ConflictMatrix(slotsPerWeek, slotsPerDay);

        matrix.initFromResources(newResources(Arrays.asList(a, b), Arrays.asList(a, c), Arrays.asList(b, c)));
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

        allLocations.add(loc2);
        aManager = new AssignmentManager(0, allLocations);

        Feature special = newFeature("special");
        loc1.addFeature(special);
        Assignment ass1 = newAssignment("1", 0, 1);
        ass1.getEvent().addFeature(special);
        Assignment ass2 = newAssignment("2", 0, 1);
        ass2.getEvent().addFeature(special);

        assertEquals(true, aManager.isForcedAssignmentPossible(ass1, loc1));
        assertEquals(true, aManager.isForcedAssignmentPossible(ass2, loc1));

        assertNotNull(aManager.assign(ass1));
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

        int slotsPerWeek = 2;
        int slotsPerDay = 2;
        settings.setTimeslotsPerDay(slotsPerDay);
        settings.setNumberOfDays(slotsPerWeek / slotsPerDay);

        final Assignment a = newAssignment("a", -1, 1);

        ConflictMatrix matrix = new ConflictMatrix(slotsPerWeek, slotsPerDay);
        matrix.initFromResources(newResources(Arrays.asList(a)));

        Location loc = new Location(5);
        List locations = Arrays.asList(loc);

        periode = newPeriod(slotsPerWeek, locations, matrix);
        periode.setRandom(new Random());

        assertTrue(periode.doMove(a, 0));
        assertEquals(0, a.getStart());
        assertEquals(loc, a.getLocation());

        periode.rollback(0);

        assertEquals(-1, a.getStart());
    }
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.