org.cpsolver.studentsct

## Class Test

- java.lang.Object
- - org.cpsolver.studentsct.Test

-     public class Test
      extends Object

  A main class for running of the student sectioning solver from command line.
  Usage:
  java -Xmx1024m -jar studentsct-1.1.jar config.properties [input_file] [output_folder] [batch|online|simple]
  Modes:
  batch ... batch sectioning mode (default mode -- IFS solver with `StudentSctNeighbourSelection` is used)
  online ... online sectioning mode (students are sectioned one by one, sectioning info (expected/held space) is used)
  simple ... simple sectioning mode (students are sectioned one by one, sectioning info is not used)
  See http://www.unitime.org for example configuration files and benchmark data sets.
  The test does the following steps:
  - Provided property file is loaded (see `DataProperties`).
  - Output folder is created (General.Output property) and logging is setup (using log4j).
  - Input data are loaded from the given XML file (calling `StudentSectioningXMLLoader.load()`).
  - Solver is executed (see `Solver`).
  - Resultant solution is saved to an XML file (calling `StudentSectioningXMLSaver.save()`.
  Also, a log and some reports (e.g., `CourseConflictTable` and `DistanceConflictTable`) are created in the output folder.
  Parameters:

  Parameter | Type | Comment
  --- | --- | ---
  Test.LastLikeCourseDemands | `String` | Load last-like course demands from the given XML file (in the format that is being used for last like course demand table in the timetabling application)
  Test.StudentInfos | `String` | Load last-like course demands from the given XML file (in the format that is being used for last like course demand table in the timetabling application)
  Test.CrsReq | `String` | Load student requests from the given semi-colon separated list files (in the format that is being used by the old MSF system)
  Test.EtrChk | `String` | Load student information (academic area, classification, major, minor) from the given semi-colon separated list files (in the format that is being used by the old MSF system)
  Sectioning.UseStudentPreferencePenalties | `Boolean` | If true, `StudentPreferencePenalties` are used (applicable only for online sectioning)
  Test.StudentOrder | `String` | A class that is used for ordering of students (must be an interface of `StudentOrder`, default is `StudentRandomOrder`, not applicable only for batch sectioning)
  Test.CombineStudents | `File` | If provided, students are combined from the input file (last-like students) and the provided file (real students). Real non-freshmen students are taken from real data, last-like data are loaded on top of the real data (all students, but weighted to occupy only the remaining space).
  Test.CombineStudentsLastLike | `File` | If provided (together with Test.CombineStudents), students are combined from the this file (last-like students) and Test.CombineStudents file (real students). Real non-freshmen students are taken from real data, last-like data are loaded on top of the real data (all students, but weighted to occupy only the remaining space).
  Test.CombineAcceptProb | `Double` | Used in combining students, probability of a non-freshmen real student to be taken into the combined file (default is 1.0 -- all real non-freshmen students are taken).
  Test.FixPriorities | `Boolean` | If true, course/free time request priorities are corrected (to go from zero, without holes or duplicates).
  Test.ExtraStudents | `File` | If provided, students are loaded from the given file on top of the students loaded from the ordinary input file (students with the same id are skipped).

  Version:
    StudentSct 1.3 (Student Sectioning)
    Copyright (C) 2007 - 2014 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/.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Test.ExtraStudentFilter`
    `static class` | `Test.TestSolutionListener`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Test()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Solution<Request,Enrollment>` | `batchSectioning(DataProperties cfg)` Batch sectioning test
    `static Solution<Request,Enrollment>` | `combineStudents(DataProperties cfg, File lastLikeStudentData, File realStudentData)` Combine students from the provided two files
    `static void` | `fixPriorities(StudentSectioningModel model)`
    `static double` | `getLastLikeStudentWeight(Course course, int real, int lastLike)` Compute last-like student weight for the given course
    `static double[]` | `getMinMaxAvailableEnrollmentPenalty(Assignment<Request,Enrollment> assignment, CourseRequest request)` Minimum and maximum available enrollment penalty, i.e., `Enrollment.getPenalty()` of all available enrollments
    `static double[]` | `getMinMaxEnrollmentPenalty(CourseRequest request)` Minimum and maximum enrollment penalty, i.e., `Enrollment.getPenalty()` of all enrollments
    `static String` | `getPerc(double value, double min, double max)` Compute percentage
    `static Solution<Request,Enrollment>` | `load(DataProperties cfg)` Load student sectioning model
    `static void` | `loadCrsReqFiles(StudentSectioningModel model, String files)` Load course request from the given files (in the format being used by the old MSF system)
    `static void` | `loadLastLikeCourseDemandsXml(StudentSectioningModel model, File xml)` Load last-like students from an XML file (the one that is used to load last like course demands table in the timetabling application)
    `static void` | `main(String[] args)` Main
    `static Solution<Request,Enrollment>` | `onlineSectioning(DataProperties cfg)` Online sectioning test
    `static void` | `printInfo(Solution<Request,Enrollment> solution, boolean computeTables, boolean computeSectInfos, boolean runChecks)` Print some information about the solution
    `static void` | `saveInfoToXML(Solution<Request,Enrollment> solution, Map<String,String> extra, File file)` Save solution info as XML
    `static void` | `setupLogging(File logFile)` Setup log4j logging
    `static Solution<Request,Enrollment>` | `solve(Solution<Request,Enrollment> solution, DataProperties cfg)` Solve the student sectioning problem using IFS solver

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

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

- - ### Constructor Detail

    - #### Test

          public Test()

  - ### Method Detail

    - #### load

          public static Solution<Request,Enrollment> load(DataProperties cfg)

      Load student sectioning model
      Parameters:
        `cfg` - solver configuration
      Returns:
        loaded solution

    - #### batchSectioning

          public static Solution<Request,Enrollment> batchSectioning(DataProperties cfg)

      Batch sectioning test
      Parameters:
        `cfg` - solver configuration
      Returns:
        resultant solution

    - #### onlineSectioning

          public static Solution<Request,Enrollment> onlineSectioning(DataProperties cfg)
                                                               throws Exception

      Online sectioning test
      Parameters:
        `cfg` - solver configuration
      Returns:
        resultant solution
      Throws:
        `Exception` - thrown when the sectioning fails

    - #### getMinMaxEnrollmentPenalty

          public static double[] getMinMaxEnrollmentPenalty(CourseRequest request)

      Minimum and maximum enrollment penalty, i.e., `Enrollment.getPenalty()` of all enrollments
      Parameters:
        `request` - a course request
      Returns:
        minimum and maximum of the enrollment penalty

    - #### getMinMaxAvailableEnrollmentPenalty

          public static double[] getMinMaxAvailableEnrollmentPenalty(Assignment<Request,Enrollment> assignment,
                                                                     CourseRequest request)

      Minimum and maximum available enrollment penalty, i.e., `Enrollment.getPenalty()` of all available enrollments
      Parameters:
        `assignment` - current assignment
        `request` - a course request
      Returns:
        minimum and maximum of the available enrollment penalty

    - #### getPerc

          public static String getPerc(double value,
                                       double min,
                                       double max)

      Compute percentage
      Parameters:
        `value` - current value
        `min` - minimal bound
        `max` - maximal bound
      Returns:
        (value-min)/(max-min)

    - #### printInfo

          public static void printInfo(Solution<Request,Enrollment> solution,
                                       boolean computeTables,
                                       boolean computeSectInfos,
                                       boolean runChecks)

      Print some information about the solution
      Parameters:
        `solution` - given solution
        `computeTables` - true, if reports `CourseConflictTable` and `DistanceConflictTable` are to be computed as well
        `computeSectInfos` - true, if online sectioning infou is to be computed as well (see `StudentSectioningModel.computeOnlineSectioningInfos(Assignment)`)
        `runChecks` - true, if checks `OverlapCheck` and `SectionLimitCheck` are to be performed as well

    - #### solve

          public static Solution<Request,Enrollment> solve(Solution<Request,Enrollment> solution,
                                                           DataProperties cfg)

      Solve the student sectioning problem using IFS solver
      Parameters:
        `solution` - current solution
        `cfg` - solver configuration
      Returns:
        resultant solution

    - #### getLastLikeStudentWeight

          public static double getLastLikeStudentWeight(Course course,
                                                        int real,
                                                        int lastLike)

      Compute last-like student weight for the given course
      Parameters:
        `course` - given course
        `real` - number of real students for the course
        `lastLike` - number of last-like students for the course
      Returns:
        weight of a student request for the given course

    - #### loadLastLikeCourseDemandsXml

          public static void loadLastLikeCourseDemandsXml(StudentSectioningModel model,
                                                          File xml)

      Load last-like students from an XML file (the one that is used to load last like course demands table in the timetabling application)
      Parameters:
        `model` - problem model
        `xml` - an XML file

    - #### loadCrsReqFiles

          public static void loadCrsReqFiles(StudentSectioningModel model,
                                             String files)

      Load course request from the given files (in the format being used by the old MSF system)
      Parameters:
        `model` - student sectioning model (with offerings loaded)
        `files` - semi-colon separated list of files to be loaded

    - #### fixPriorities

          public static void fixPriorities(StudentSectioningModel model)

    - #### saveInfoToXML

          public static void saveInfoToXML(Solution<Request,Enrollment> solution,
                                           Map<String,String> extra,
                                           File file)

      Save solution info as XML
      Parameters:
        `solution` - current solution
        `extra` - solution extra info
        `file` - file to write

    - #### combineStudents

          public static Solution<Request,Enrollment> combineStudents(DataProperties cfg,
                                                                     File lastLikeStudentData,
                                                                     File realStudentData)

      Combine students from the provided two files
      Parameters:
        `cfg` - solver configuration
        `lastLikeStudentData` - a file containing last-like student data
        `realStudentData` - a file containing real student data
      Returns:
        combined solution

    - #### setupLogging

          public static void setupLogging(File logFile)

      Setup log4j logging
      Parameters:
        `logFile` - log file

    - #### main

          public static void main(String[] args)

      Main
      Parameters:
        `args` - program arguments