Package de.timefinder.algo.roomassignment

Source Code of de.timefinder.algo.roomassignment.PathGrowingAlgorithmTest

/*
* This file is part of the TimeFinder project.
* Visit http://www.timefinder.de for more information.
* Copyright 2008 the original author or authors.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*        http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.timefinder.algo.roomassignment;

import de.timefinder.algo.roomassignment.PathGrowingAlgorithm;
import de.timefinder.algo.roomassignment.AssignmentAlgorithm;
import de.timefinder.algo.roomassignment.AssignmentHelper;
import static org.junit.Assert.*;
import org.junit.Test;

/**
* @author Peter Karich, peat_hal 'at' users 'dot' sourceforge 'dot' net
*/
public class PathGrowingAlgorithmTest extends AbstractAssignmentAlgorithmTester {

    @Override
    protected AssignmentAlgorithm createAlgorithm() {
        return new PathGrowingAlgorithm();
    }

    @Override
    public void testSmallWithInfinity() {
        // expected 18 but was 27
    }

    @Override
    public void testAllEventsForOneRowAreInvalid() {
        // expected:<4194316.0> but was:<4194318.0>
    }

    @Override
    public void testComplicateMatrix() {
        // expected:<190.0> but was:<3355570.0>
    }

    @Override
    public void testCalculate() {
        // expected:<15.0> but was:<16.0>
    }

    @Override
    public void testCalculate2() {
        //  expected:<15.0> but was:<18.0>
    }

    @Override
    public void testMoreRowsThanColumns() {
        // expected:<9.0> but was:<10.0>
    }

    @Override
    public void testWithInfinityAndWithInvalidLastColumn() {
        // expected:<4194312.0> but was:<4194313.0>
    }

    @Override
    public void testWithInvalidLastColumn() {
        // expected:<4194312.0> but was:<4194313.0>
    }

    @Override
    public void testJohnClarkExample() {
        // expected:<38.0> but was:<40.0>
    }

    @Override
    public void testInvalidRows() {
        // expected:<3355453.0> but was:<3355457.0>
    }

    @Test
    public void testRealLife() {
        // PathGrowAlgo failed in this so put it here
        float matrix[][] = new float[][]{
            {19.0f, F_MAX},
            {17.0f, F_MAX},
            {7.00f, F_MAX},
            {F_MAX, F_MAX},
            {19.0f, F_MAX},
            {11.0f, F_MAX},
            {17.0f, F_MAX},
            {16.0f, F_MAX},
            {15.0f, F_MAX},
            {14.0f, 26.0f}
        };

        int expResult[][] = new int[][]{{2, 0}, {9, 1}, null, null, null,
            null, null, null, null, null,};
        // =>
        float expSum = 33f;

        int result[][] = algorithm.computeAssignments(matrix);
        assert result.length == 10 : result.length;
        float resSum = AssignmentHelper.calculateSum(matrix, result);
        assertEquals(33f, resSum, 0.001f);
    }

    @Test
    public void testRealLife2() {
        float matrix[][] = new float[][]{
            {F_MAX, 11.0f, F_MAX, 14.0f, F_MAX, F_MAX},
            {F_MAX, F_MAX, 11.0f, 12.0f, F_MAX, F_MAX},
            {F_MAX, F_MAX, F_MAX, 2.00f, F_MAX, F_MAX},
            {F_MAX, F_MAX, F_MAX, F_MAX, F_MAX, F_MAX},
            {F_MAX, F_MAX, F_MAX, 14.0f, 12.0f, F_MAX},
            {18.0f, F_MAX, F_MAX, 6.00f, F_MAX, 5.0f},
            {F_MAX, F_MAX, F_MAX, 12.0f, F_MAX, F_MAX},
            {23.0f, F_MAX, F_MAX, 11.0f, F_MAX, 10.0f},
            {F_MAX, F_MAX, F_MAX, 10.0f, F_MAX, F_MAX},
            {F_MAX, F_MAX, F_MAX, 9.00f, F_MAX, F_MAX}
        };

        int result[][] = algorithm.computeAssignments(matrix);
        assert result.length == 10 : result.length;
        float resSum = AssignmentHelper.calculateSum(matrix, result);
        assertEquals(64f, resSum, 0.001f);
    }
}
TOP

Related Classes of de.timefinder.algo.roomassignment.PathGrowingAlgorithmTest

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.