Package de.timefinder.data.algo

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


        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

    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

        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

        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

        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

        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

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

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

        ConflictMatrix matrix = new ConflictMatrix(slotsPerWeek, slotsPerDay);

        matrix.initFromResources(newResources(Arrays.asList(a, b), Arrays.asList(a, c), Arrays.asList(b, c)));

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

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

        assertTrue(periode.add(b, 0));
        assertFalse(periode.add(c, 1));
        assertTrue(periode.add(c, 2));
        periode.add(a, -1);

        assertEquals(-1, a.getStart());
        assertEquals(0, b.getStart());
        assertEquals(2, c.getStart());

        int depth = 3;
        int collidingAssignment = 3;

        assertFalse(periode.inject(a, depth, collidingAssignment));
View Full Code Here

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

        Assignment ass1 = newAssignment("1", 0, 1);
        Assignment ass2 = newAssignment("2", 0, 1);

        Object undoAddData1 = aManager.forceAssignment(ass1, loc1);
        assertEquals(1, aManager.getAvailableLocations().size());
        assertNotNull(undoAddData1);

        // try to inject ass2 => ass1 is one of the colliding => remove
        Object undoRmData1 = aManager.remove(ass1);
        assertEquals(2, aManager.getAvailableLocations().size());
        assertNotNull(undoRmData1);
        assertNull(ass2.getLocation());
        Object undoAddData2 = aManager.forceAssignment(ass2, loc1);
        assertEquals(loc1, ass2.getLocation());
        assertEquals(1, aManager.getAvailableLocations().size());
        assertNotNull(undoAddData2);

        // inject fails => rollback move of ass2 and ass1       
        aManager.rollbackAssign(ass2, undoAddData2);
View Full Code Here

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

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

        ConflictMatrix conflictMatrix = new ConflictMatrix(slotsPerWeek, slotsPerDay);
        conflictMatrix.initFromResources(newResources(Arrays.asList(a, b), Arrays.asList(a, c), Arrays.asList(b, c)));

        List locations = Arrays.asList(new Location(5));
View Full Code Here

TOP

Related Classes of de.timefinder.data.algo.Assignment

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.