Package de.timefinder.data.algo

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


        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

        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

        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

        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

        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

    }

    @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

        ncpInstance.correctOrderWithBubbleSort(canister);
        check(canister);
    }

    private void check(List<Assignment> list) {
        Assignment subj;
        for (int i = 0; i < list.size(); i++) {
            subj = list.get(i);

            //only check followers
            for (Event f : subj.getEvent().getConstraint(EventOrderConstraint.class).getFollows()) {
                assertTrue("i:" + i + " \tcurrent:" + subj + " \tfollower:" + f
                        + " \tlist:" + list, indexOfEvent(list, f) > i);
            }
        }
    }
View Full Code Here

        oc2.addBefore(prev.getEvent());
    }

    @Override
    protected Assignment newAssignment(String str) {
        Assignment ass = super.newAssignment(str, 1, 1);
        ass.getEvent().putConstraint(new EventOrderConstraint(ass.getEvent()));
        return ass;
    }
View Full Code Here

        super.setUp();
    }

    @Test
    public void testGetStart() {
        assertEquals(-1, new Assignment(new Event(1, 2)).getStart());
        Assignment ass = newAssignment("test", 1, 2);
        assertEquals(1, ass.getStart());
        assertEquals(2, ass.getEvent().getDuration());
        assertEquals("test", ass.getEvent().getName());
    }
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.