net.sf.cpsolver.studentsct
Class OnlineSectProof

java.lang.Object
  extended by net.sf.cpsolver.studentsct.OnlineSectProof

public class OnlineSectProof
extends Object

A test class to demonstrate and compare different online sectioning approaches. It assumes only a single course with just one instructional type (subpart) and that we know the correct expected demand in advance.

With the given configuration (e.g., two sections of size 5), it tries all combinations of students how they can be enrolled and compute average and worst case scenarios.

Execution:
    java -cp cpsolver-all-1.1.jar net.sf.cpsolver.studentsct.OnlineSectProof n1 n2 n3 ...
where n1, n2, etc. are the sizes of particular sections, e.g., 10 10 for two sections of size 10.

Version:
StudentSct 1.1 (Student Sectioning)
Copyright (C) 2007 Tomáš Müller
muller@unitime.org
Lazenska 391, 76314 Zlin, Czech Republic

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 2.1 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Nested Class Summary
static class OnlineSectProof.CatCmp
          Comparison of two categories
static class OnlineSectProof.Counter
          Simple integer counter
static class OnlineSectProof.Sequence
          A representation of a long number of given base.
static class OnlineSectProof.StudentSequence
          Extension of OnlineSectProof.Sequence that represents an ordered set of students as they are to be enrolled into a course (given set of sections).
 
Field Summary
static String[] sOnlineAlgs
          Implemented online algorithms (heuristics)
 
Constructor Summary
OnlineSectProof()
           
 
Method Summary
static int checkOnline(OnlineSectProof.StudentSequence sq, boolean computeExpectations, int alg, boolean debug)
          Section given sequence of students into the course and return the number of students that cannot be sectioned.
static void main(String[] args)
          Test given course (set of sections)
static double onlineObjective(double limit, double used, double expected, int alg)
          Implementation of the sectioning algorithms.
static boolean skip(boolean computeExpectations, int alg, boolean allTheSame)
          Return true, if the given heuristics should be skipped (not evaluated).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sOnlineAlgs

public static String[] sOnlineAlgs
Implemented online algorithms (heuristics)

Constructor Detail

OnlineSectProof

public OnlineSectProof()
Method Detail

skip

public static boolean skip(boolean computeExpectations,
                           int alg,
                           boolean allTheSame)
Return true, if the given heuristics should be skipped (not evaluated).

Parameters:
computeExpectations - true, if expected demand should be computed in advance
alg - online algorithm (see sOnlineAlgs)
allTheSame - true, if all the sections are of the same size
Returns:
true if the given heuristics does not need to be computed (e.g., it is the same of some other)

onlineObjective

public static double onlineObjective(double limit,
                                     double used,
                                     double expected,
                                     int alg)
Implementation of the sectioning algorithms.

Parameters:
limit - section limit
used - number of space already used
expected - expected demand for the given section
alg - online algorithm (see sOnlineAlgs)
Returns:
value that is to be minimized (i.e., a section with the lowest number will be picked for the student)

checkOnline

public static int checkOnline(OnlineSectProof.StudentSequence sq,
                              boolean computeExpectations,
                              int alg,
                              boolean debug)
Section given sequence of students into the course and return the number of students that cannot be sectioned.

Parameters:
sq - sequence of studends
computeExpectations - true, if expected demand for each section should be computed in advance (otherwise, it is initially set to zero)
alg - online algorithm (see sOnlineAlgs)
debug - if true, some debug messages are printed
Returns:
number of students that will not be sectioned in such a case

main

public static void main(String[] args)
Test given course (set of sections)

Parameters:
args - set of integers -- limits of each sections