Package net.sf.cpsolver.tt

Source Code of net.sf.cpsolver.tt.UniTimeOptimizationTest

/*
*  Copyright 2009 Peter Karich, peat_hal 'at' users 'dot' sourceforge 'dot' net.
*
*  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.
*  under the License.
*/
package net.sf.cpsolver.tt;

import de.timefinder.algo.AlgorithmConditionTime;
import de.timefinder.algo.ConsoleStatusBar;
import de.timefinder.algo.util.TimeFinder2Tester;
import de.timefinder.data.Event;
import de.timefinder.data.Location;
import de.timefinder.data.Person;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;

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

    private UniTimeOptimization unitimer;

    @Override
    @Before
    public void setUp() {
        super.setUp();
    }

    @Test
    public void testSimpleStart() throws Exception {
        settings.setNumberOfDays(1);
        settings.setTimeslotsPerDay(4);

        Event ev1 = new Event(3, 1);
        eDao.attach(ev1);
        Event ev2 = new Event(2, 1);
        eDao.attach(ev2);

        Location loc1 = new Location("loc1", 10);
        lDao.attach(loc1);

        unitimer = new UniTimeOptimization();
        unitimer.setCondition(new AlgorithmConditionTime(1));
        unitimer.setInitialAssignment(true);
        unitimer.setStatusBar(new ConsoleStatusBar());
        unitimer.setDataPool(dataPool);
        unitimer.setDataPoolSettings(settings);
        unitimer.start();

        assertTrue("start was:" + ev1.getStart(), ev1.getStart() < 2);
        assertTrue("start was:" + ev2.getStart(), ev2.getStart() < 2);
    }

    @Test
    public void testSimpleStart2() throws Exception {
        settings.setNumberOfDays(1);
        settings.setTimeslotsPerDay(2);

        Person p1 = new Person("p1");
        pDao.attach(p1);
        Event ev1 = new Event(2, 1);
        ev1.addPerson(p1, true);
        eDao.attach(ev1);
       
        Event ev2 = new Event(1, 1);
        eDao.attach(ev2);

        Location loc1 = new Location("loc1", 10);
        lDao.attach(loc1);

        unitimer = new UniTimeOptimization();
        unitimer.setCondition(new AlgorithmConditionTime(1));
        unitimer.setInitialAssignment(true);
        unitimer.setStatusBar(new ConsoleStatusBar());
        unitimer.setDataPool(dataPool);
        unitimer.setDataPoolSettings(settings);
        unitimer.start();

        assertTrue("start was:" + ev1.getStart(), ev1.getStart() == 0);
        assertTrue("start was:" + ev2.getStart(), ev2.getStart() == 1);
    }
}
TOP

Related Classes of net.sf.cpsolver.tt.UniTimeOptimizationTest

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.