org.cpsolver.coursett.sectioning

## Class StudentSwapSectioning

- java.lang.Object
- - org.cpsolver.coursett.model.DefaultStudentSectioning
  - - org.cpsolver.coursett.sectioning.StudentSwapSectioning

- All Implemented Interfaces:
    StudentSectioning, InfoProvider<Lecture,Placement>

      public class StudentSwapSectioning
      extends DefaultStudentSectioning
      implements InfoProvider<Lecture,Placement>

  Student sectioning implementation based on local search. A student swap is generated in each iteration using Hill Climbing and Great Deluge algorithms.
  Version:
    CourseTT 1.3 (University Course Timetabling)
    Copyright (C) 2017 Tomáš Müller
    muller@unitime.org
    http://muller.unitime.org
    This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
    This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    You should have received a copy of the GNU Lesser General Public License along with this library; if not see http://www.gnu.org/licenses/.
  Author:
    Tomáš Müller

- - ### Field Summary

    - ### Fields inherited from class org.cpsolver.coursett.model.DefaultStudentSectioning

      `iFinalSectioning, iModel, sDF2`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StudentSwapSectioning(TimetableModel model)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected List<StudentConflict>` | `getStudentConflictCriteria()`
    `static double` | `gp(Solution<Lecture,Placement> solution)` Student group percentage of a solution
    `static double` | `gp(TimetableModel model)` Student group percentage of a solution
    `static double` | `gp(TimetableModel model, Collection<Lecture> variables)` Student group percentage of a solution subset
    `protected double` | `group(Neighbour<Lecture,Placement> n, Assignment<Lecture,Placement> assignment)` Student group weight change of a student swap
    `static double` | `group(TimetableModel model)` Student group weight of a solution
    `boolean` | `hasFinalSectioning()` Return true if final student sectioning is implemented.
    `protected boolean` | `hasStudentGroups(Collection<Student> students)`
    `protected double` | `objective(Neighbour<Lecture,Placement> n, Assignment<Lecture,Placement> assignment)` Student conflict weight change of a student swap
    `protected double` | `objective(Solution<Lecture,Placement> solution)` Student conflict weight of a solution
    `void` | `resection(Assignment<Lecture,Placement> assignment, Lecture lecture, boolean recursive, boolean configAsWell)` Perform sectioning on the given lecture
    `protected InitialSectioning.Group[]` | `studentsToConfigurations(Long offeringId, Collection<Student> students, Collection<Configuration> configurations)` Section students into configurations.
    `protected InitialSectioning.Group[]` | `studentsToLectures(Long offeringId, Collection<Student> students, Collection<Lecture> lectures)` Section students into lectures.
    `void` | `switchStudents(Solution<Lecture,Placement> solution, TerminationCondition<Lecture,Placement> termination)` Run student final sectioning (switching students between sections of the same class in order to minimize overall number of student conflicts).
    `protected double` | `value(Neighbour<Lecture,Placement> n, Assignment<Lecture,Placement> assignment)` Combined weight change of a student swap
    `protected double` | `value(Solution<Lecture,Placement> solution)` Combined weight of a solution

    - ### Methods inherited from class org.cpsolver.coursett.model.DefaultStudentSectioning

      `getClassLabel, getInfo, getInfo, getProgress, initialSectioning, initialSectioningLectures`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.cpsolver.ifs.model.InfoProvider

      `getInfo, getInfo`

- - ### Constructor Detail

    - #### StudentSwapSectioning

          public StudentSwapSectioning(TimetableModel model)

  - ### Method Detail

    - #### getStudentConflictCriteria

          protected List<StudentConflict> getStudentConflictCriteria()

    - #### hasFinalSectioning

          public boolean hasFinalSectioning()

      Description copied from class: `DefaultStudentSectioning`
      Return true if final student sectioning is implemented.
      Specified by:
        `hasFinalSectioning` in interface `StudentSectioning`
      Overrides:
        `hasFinalSectioning` in class `DefaultStudentSectioning`
      Returns:
        true if final student sectioning is implemented

    - #### objective

          protected double objective(Neighbour<Lecture,Placement> n,
                                     Assignment<Lecture,Placement> assignment)

      Student conflict weight change of a student swap

    - #### group

          protected double group(Neighbour<Lecture,Placement> n,
                                 Assignment<Lecture,Placement> assignment)

      Student group weight change of a student swap

    - #### value

          protected double value(Neighbour<Lecture,Placement> n,
                                 Assignment<Lecture,Placement> assignment)

      Combined weight change of a student swap

    - #### objective

          protected double objective(Solution<Lecture,Placement> solution)

      Student conflict weight of a solution

    - #### group

          public static double group(TimetableModel model)

      Student group weight of a solution

    - #### gp

          public static double gp(TimetableModel model,
                                  Collection<Lecture> variables)

      Student group percentage of a solution subset

    - #### gp

          public static double gp(TimetableModel model)

      Student group percentage of a solution

    - #### gp

          public static double gp(Solution<Lecture,Placement> solution)

      Student group percentage of a solution

    - #### value

          protected double value(Solution<Lecture,Placement> solution)

      Combined weight of a solution

    - #### switchStudents

          public void switchStudents(Solution<Lecture,Placement> solution,
                                     TerminationCondition<Lecture,Placement> termination)

      Description copied from class: `DefaultStudentSectioning`
      Run student final sectioning (switching students between sections of the same class in order to minimize overall number of student conflicts).
      Specified by:
        `switchStudents` in interface `StudentSectioning`
      Overrides:
        `switchStudents` in class `DefaultStudentSectioning`
      Parameters:
        `solution` - current solution
        `termination` - termination condition (optional)

    - #### resection

          public void resection(Assignment<Lecture,Placement> assignment,
                                Lecture lecture,
                                boolean recursive,
                                boolean configAsWell)

      Description copied from class: `DefaultStudentSectioning`
      Perform sectioning on the given lecture
      Specified by:
        `resection` in interface `StudentSectioning`
      Overrides:
        `resection` in class `DefaultStudentSectioning`
      Parameters:
        `assignment` - current assignment
        `lecture` - given lecture
        `recursive` - recursively resection lectures affected by a student swap
        `configAsWell` - resection students between configurations as well

    - #### hasStudentGroups

          protected boolean hasStudentGroups(Collection<Student> students)

    - #### studentsToConfigurations

          protected InitialSectioning.Group[] studentsToConfigurations(Long offeringId,
                                                                       Collection<Student> students,
                                                                       Collection<Configuration> configurations)

      Description copied from class: `DefaultStudentSectioning`
      Section students into configurations. This method calls the actual initial sectioning `InitialSectioning.getGroups()`.
      Overrides:
        `studentsToConfigurations` in class `DefaultStudentSectioning`
      Parameters:
        `offeringId` - instructional offering id
        `students` - list of students to be sectioned
        `configurations` - list of configurations the students are to be sectioned into
      Returns:
        list of `InitialSectioning.Group`

    - #### studentsToLectures

          protected InitialSectioning.Group[] studentsToLectures(Long offeringId,
                                                                 Collection<Student> students,
                                                                 Collection<Lecture> lectures)

      Description copied from class: `DefaultStudentSectioning`
      Section students into lectures. This method calls the actual initial sectioning `InitialSectioning.getGroups()`.
      Overrides:
        `studentsToLectures` in class `DefaultStudentSectioning`
      Parameters:
        `offeringId` - instructional offering id
        `students` - list of students to be sectioned
        `lectures` - list of lectures the students are to be sectioned into
      Returns:
        list of `InitialSectioning.Group`