Package de.timefinder.data.algo

Examples of de.timefinder.data.algo.Assignment


    public Map<Event, Assignment> createTransformerMap(Collection<Event> input) {
        Map map = FastMap.newInstance();

        for (Event ev : input) {
            map.put(ev, new Assignment(ev, ev.getStart()));
        }
        return map;
    }
View Full Code Here


        // replace the colum of the event with specified loc
        int assIndex = 0;
        float prevAssColumn[] = null;
        for (; assIndex < allAssignments.size(); assIndex++) {
            Assignment ass = allAssignments.get(assIndex);
            if (ass.getLocation() == loc) {
                prevAssColumn = origMatrix.getColumn(assIndex);
                break;
            }
        }
View Full Code Here

    public Object remove(Assignment ass) {
        int index = allAssignments.indexOf(ass);
        if (index < 0)
            throw new IllegalStateException("Couldn't find assignment to remove it! " + ass);

        Assignment rmAss = allAssignments.remove(index);
        assert rmAss != null : index + " Cannot remove assignment:" + ass;
        assert index >= 0 : index + " Cannot remove assignment:" + ass;

        float[] oldColumn = origMatrix.getColumn(index);
        Set oldAvailableLocs = FastSet.newInstance();
View Full Code Here

            int index = allLocations.indexOf(ass.getLocation());
            if (origMatrix.getColumn(column)[index] == Float.MAX_VALUE)
                throw new IllegalStateException("Wrong data of location or assignment-matrix:" + ass + "\n" + origMatrix);

            column++;
            Assignment old = usedLocs.put(ass.getLocation(), ass);
            if (old != null)
                throw new IllegalStateException("one location is several times assigned! ass1: "
                        + ass + " ass2: " + old + " matrix:\n" + origMatrix);
        }
View Full Code Here

    @Test
    public void testAdd() {
        System.out.println("add");

        final Assignment ev1 = newAssignment(0, 5);
        RasterConstraint constr = newRasterConstraint();
        constr.getRaster().set(8, RasterEnum.FORBIDDEN);
        ev1.getEvent().putConstraint(constr);

        final Assignment ev2 = newAssignment(10, 1);

        matrix.initFromResources(newResources(Arrays.asList(ev1, ev2)));

        matrix.add(ev1);
        matrix.add(ev2);
View Full Code Here

    }

    @Test
    public void testSpreadEventAndCompress() {
        System.out.println("testSpreadEvent_Compres");
        Assignment ev1 = newAssignment("1", 2, 1);
        Assignment ev2 = newAssignment("2", 0, 1);
        Assignment ev3 = newAssignment("3", 0, 1);

        matrix.initFromResources(newResources(Arrays.asList(ev1, ev2, ev3)));

        // *** spread events ***

 
View Full Code Here

        assertEquals(4, aManager.countValid(ass));
    }

    @Test
    public void testAssignEvents() {
        Assignment event1 = newAssignment(0, 1);
        assertNotNull(aManager.assign(event1));
        assertEquals(loc1, event1.getLocation());
        assertEquals(1, aManager.getAll().size());

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

        Location locForEvent1 = newLocation("loc2", 5);
        allLocations.add(locForEvent1);
        aManager = new AssignmentManager(0, allLocations);
        aManager.setAlgorithm(new HungarianAlgorithm());
        Assignment event2 = newAssignment(0, 1);
        event2.getEvent().addFeature(loc1Feature);

        assertNotNull(aManager.assign(event1));
        assertEquals(1, aManager.getAll().size());
        assertEquals(loc1, event1.getLocation());

        assertNotNull(aManager.assign(event2));
        assertEquals(2, aManager.getAll().size());
        assertEquals(loc1, event2.getLocation());
        assertEquals(locForEvent1, event1.getLocation());
    }
View Full Code Here

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

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

    @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

    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

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.