Пример #1
0
  @Test
  public void testCalculateHardFitness() throws DatabaseException {

    SoftFitnessCalculationImpl fitnessCalculation = new SoftFitnessCalculationImpl();

    fitnessCalculation.calculateSoftFitness(schedule, configuration);
    Assert.assertTrue(schedule.getScore().getSoftFitness() == 1.0);
  }
Пример #2
0
  @Before
  public void initialize() throws DatabaseException {
    Date lecturingStart = Date.valueOf("2010-10-18");
    Date lecturingEnd = Date.valueOf("2011-02-19");

    String weekdays[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday"};

    Building building = relationManager.createBuilding("Takustra�e 9, 14195 Berlin");

    Department deparment = relationManager.createDepartment("Computer Science");

    AcademicTerm academicTerm =
        relationManager.createAcademicTerm(
            "Winter semester 2010/2011",
            Date.valueOf("2010-10-01"),
            Date.valueOf("2011-03-31"),
            lecturingStart,
            lecturingEnd);

    List<Person> personList = new ArrayList<Person>(4);
    personList.add(relationManager.createPerson("Elfriede", "Fehr", "efehr", "123456"));
    personList.add(relationManager.createPerson("Heinz", "Schweppe", "hschweppe", "password"));
    personList.add(relationManager.createPerson("Klaus", "Kriegel", "kkriegel", "12345678"));
    personList.add(relationManager.createPerson("Achinm", "Liers", "aliers", "1234"));

    Program program = relationManager.createProgram(academicTerm, deparment, personList.get(0));

    List<Course> courseList = new ArrayList<Course>(3);
    courseList.add(
        relationManager.createCourse(
            "Algorithmik und Programmierung I : Funktionale Programmierung"));
    courseList.add(
        relationManager.createCourse(
            "Mathematik f�r Informatiker I : Logik und Diskrete Mathematik"));
    courseList.add(
        relationManager.createCourse("Technische Informatik I : Grundlagen der Elektrotechnik"));

    List<CourseInstance> courseInstanceList = new ArrayList<CourseInstance>(3);
    courseInstanceList.add(
        relationManager.createCourseInstance(
            program, courseList.get(0), lecturingStart, lecturingEnd, personList.get(1)));
    courseInstanceList.add(
        relationManager.createCourseInstance(
            program, courseList.get(1), lecturingStart, lecturingEnd, personList.get(2)));
    courseInstanceList.add(
        relationManager.createCourseInstance(
            program, courseList.get(2), lecturingStart, lecturingEnd, personList.get(3)));

    List<CourseElement> courseElementList = new ArrayList<CourseElement>(6);
    courseElementList.add(relationManager.createCourseElement(courseList.get(0), 4));
    courseElementList.add(relationManager.createCourseElement(courseList.get(0), 2));
    courseElementList.add(relationManager.createCourseElement(courseList.get(0), 4));
    courseElementList.add(relationManager.createCourseElement(courseList.get(0), 2));
    courseElementList.add(relationManager.createCourseElement(courseList.get(0), 4));
    courseElementList.add(relationManager.createCourseElement(courseList.get(0), 2));

    List<CourseElementInstance> courseElementInstanceList = new ArrayList<CourseElementInstance>(8);
    courseElementInstanceList.add(
        relationManager.createCourseElementInstance(
            courseInstanceList.get(0), courseElementList.get(0), 2));
    courseElementInstanceList.add(
        relationManager.createCourseElementInstance(
            courseInstanceList.get(0), courseElementList.get(0), 2));
    courseElementInstanceList.add(
        relationManager.createCourseElementInstance(
            courseInstanceList.get(0), courseElementList.get(1), 2));
    courseElementInstanceList.add(
        relationManager.createCourseElementInstance(
            courseInstanceList.get(1), courseElementList.get(2), 2));
    courseElementInstanceList.add(
        relationManager.createCourseElementInstance(
            courseInstanceList.get(1), courseElementList.get(2), 2));
    courseElementInstanceList.add(
        relationManager.createCourseElementInstance(
            courseInstanceList.get(1), courseElementList.get(3), 2));
    courseElementInstanceList.add(
        relationManager.createCourseElementInstance(
            courseInstanceList.get(2), courseElementList.get(4), 2));
    courseElementInstanceList.add(
        relationManager.createCourseElementInstance(
            courseInstanceList.get(2), courseElementList.get(5), 2));

    List<Room> roomList = new ArrayList<Room>(2);
    roomList.add(relationManager.createRoom("HS", building));
    roomList.add(relationManager.createRoom("SR 046", building));

    List<Feature> featureList = new ArrayList<Feature>(0);
    List<ProposedScheduling> proposedSchedulingList = new ArrayList<ProposedScheduling>(0);

    List<Day> dayList = new ArrayList<Day>(5);
    for (int i = 0; i < 5; ++i) {
      dayList.add(relationManager.createDay(weekdays[i]));
    }

    int j = 0;
    int h = 8;
    List<Timeslot> timeSlotList = new ArrayList<Timeslot>(60);
    for (int i = 0; i < 60; ++i) {

      timeSlotList.add(
          relationManager.createTimeslot(
              dayList.get(j),
              Time.valueOf("0".concat(new Integer(h).toString()).concat(":00:00"))));
      ++h;

      if (((i + 1) % 12) == 0) {
        ++j;
        h = 8;
      }
    }

    relationManager.createElementInstancePrefersTimeslot(
        courseElementInstanceList.get(0), timeSlotList.get(2), 90);
    relationManager.createElementInstancePrefersTimeslot(
        courseElementInstanceList.get(0), timeSlotList.get(3), 90);

    List<CourseRecommendedForYear> courseRecommendForYearList =
        new ArrayList<CourseRecommendedForYear>();

    configuration =
        new Configuration(
            roomList,
            personList.subList(1, 3),
            courseElementInstanceList,
            timeSlotList,
            featureList,
            proposedSchedulingList,
            courseRecommendForYearList);

    schedule = new ScheduleImpl(configuration);

    schedule.addCourse(courseElementInstanceList.get(0), 0, 2);
    schedule.addCourse(courseElementInstanceList.get(1), 0, 26);
    schedule.addCourse(courseElementInstanceList.get(2), 1, 16);
    schedule.addCourse(courseElementInstanceList.get(3), 0, 12);
    schedule.addCourse(courseElementInstanceList.get(4), 0, 38);
    schedule.addCourse(courseElementInstanceList.get(5), 1, 0);
    schedule.addCourse(courseElementInstanceList.get(6), 0, 52);
    schedule.addCourse(courseElementInstanceList.get(7), 1, 48);
  }