Examples of Assignment


Examples of de.timefinder.data.algo.Assignment

        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

Examples of de.timefinder.data.algo.Assignment

    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

Examples of de.timefinder.data.algo.Assignment

        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

Examples of de.timefinder.data.algo.Assignment

    public void testAssignedLocationAfterRollback() {
        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);

        aManager.forceAssignment(ass1, loc1);

        // try to inject ass2 => assume ass1 is one of the colliding => remove
        Object undoRmData1 = aManager.remove(ass1);
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

        Feature special = newFeature("loc1");
        loc1.addFeature(special);
        aManager = new AssignmentManager(0, allLocations);

        Assignment ass1 = newAssignment("1", 0, 1);
        Assignment ass2 = newAssignment("2", 0, 1);
        EventOrderConstraint oc1 = new EventOrderConstraint(ass1.getEvent());
        EventOrderConstraint oc2 = new EventOrderConstraint(ass2.getEvent());
        oc2.addFollow(newEvent("ev3"));

        ass1.getEvent().putConstraint(oc1);
        ass2.getEvent().putConstraint(oc2);
        ass2.getEvent().addFeature(special);

        Object rollbackAssData = aManager.assign(ass1);
        assertNotNull(rollbackAssData);
        assertEquals(loc1, ass1.getLocation());

        assertNotNull(aManager.assign(ass2));
        assertEquals(loc1, ass2.getLocation());
        assertEquals(loc2, ass1.getLocation());

        Object rollbackRmData = aManager.remove(ass1);
        assertNotNull(rollbackRmData);
        assertNotNull(aManager.remove(ass2));
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

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

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

        ConflictMatrix conflictMatrix = new ConflictMatrix(slotsPerWeek, slotsPerDay);
        conflictMatrix.initFromResources(newResources(Arrays.asList(a), Arrays.asList(b)));
        final Location loc1 = new Location(5);
        final Location loc2 = new Location(10);
        List locations = Arrays.asList(loc1, loc2);

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

        assertTrue(periode.add(a, 0));
        assertTrue(periode.add(b, 0));
        assertNotNull(a.getLocation());
        assertNotNull(b.getLocation());
        assertNotSame(a.getLocation(), b.getLocation());
    }
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

        settings.setTimeslotsPerDay(slotsPerDay);
        settings.setNumberOfDays(slotsPerWeek / slotsPerDay);

        Feature loc1Feature = newFeature("special");

        Assignment ass1 = newAssignment("1", -1, 2);
        ass1.getEvent().addFeature(loc1Feature);
        Assignment ass2 = newAssignment("2", -1, 2);
        Assignment ass3 = newAssignment("3", -1, 1);

        ConflictMatrix conflictMatrix = new ConflictMatrix(slotsPerWeek, slotsPerDay);
        conflictMatrix.initFromResources(newResources(Arrays.asList(ass1), Arrays.asList(ass2), Arrays.asList(ass3)));
        final Location loc1 = new Location(5);
        final Location loc2 = new Location(10);
        loc1.addFeature(loc1Feature);
        List locations = Arrays.asList(loc1, loc2);

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

        assertEquals(true, periode.add(ass3, 2));
        assertEquals(true, periode.add(ass2, 1));
        assertEquals(loc2, ass3.getLocation());
        assertEquals(loc1, ass2.getLocation());

        // event with duration==1 cannot move larger event (ass2)
        assertEquals(false, periode.add(ass1, 0));

        assertNotNull(periode.remove(ass3));
        assertNotNull(periode.remove(ass2));

        ass3.getEvent().addFeature(loc1Feature);
        assertEquals(true, periode.add(ass3, 2));
        assertEquals(true, periode.add(ass2, 1));
        assertEquals(loc1, ass3.getLocation());
        assertEquals(loc2, ass2.getLocation());
    }
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

        Feature special = newFeature("loc1");
        loc1.addFeature(special);

        aManager = new AssignmentManager(0, allLocations);

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

        aManager.assign(ass1);
        assertEquals(loc1, ass1.getLocation());

        Object undoAddData2 = aManager.assign(ass2);
        assertEquals(loc1, ass2.getLocation());
        assertEquals(loc2, ass1.getLocation());

        // rollback move of ass2 should also rollback others location assignments!
        aManager.rollbackAssign(ass2, undoAddData2);
        assertEquals(1, aManager.getAll().size());
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

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

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

        Location loc = aManagerForSlot2.calculateLocation(ass1);
        assertNotNull(loc);

        // force assignment, so that only one matrix entry is possible
View Full Code Here

Examples of de.timefinder.data.algo.Assignment

    }

    @Test
    public void testCorrectOrder() {
        System.out.println("correctOrder");
        Assignment a = newAssignment("A");
        Assignment b = newAssignment("B");
        Assignment c = newAssignment("C");
        Assignment d = newAssignment("D");
        Assignment e = newAssignment("E");
        Assignment f = newAssignment("F");
        Assignment g = newAssignment("G");
        Assignment h = newAssignment("H");
        Assignment i = newAssignment("I");
        Assignment j = newAssignment("J");
        Assignment k = newAssignment("K");
        Assignment l = newAssignment("L");
        Assignment m = newAssignment("M");
        connect(b, a);
        connect(c, b);
        connect(b, d);
        connect(c, d);
        connect(d, e);
View Full Code Here
TOP
Copyright © 2018 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.