net.sf.cpsolver.studentsct.constraint
Class SectionLimit

java.lang.Object
  extended by net.sf.cpsolver.ifs.model.Constraint
      extended by net.sf.cpsolver.ifs.model.GlobalConstraint
          extended by net.sf.cpsolver.studentsct.constraint.SectionLimit

public class SectionLimit
extends GlobalConstraint

Section limit constraint. This global constraint ensures that a limit of each section is not exceeded. This means that the total sum of weights of course requests (see Request.getWeight()) enrolled into a section is below the section's limit (see Section.getLimit()).

Sections with negative limit are considered unlimited, and therefore completely ignored by this constraint.

Parameters:

ParameterTypeComment
SectionLimit.PreferDummyStudentsBooleanIf true, requests of dummy (last-like) students are preferred to be selected as conflicting.


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

Field Summary
 
Fields inherited from class net.sf.cpsolver.ifs.model.Constraint
iAssignedVariables, iConstraintListeners, iId
 
Constructor Summary
SectionLimit(DataProperties cfg)
          Constructor
 
Method Summary
 void computeConflicts(Value value, Set conflicts)
          A given enrollment is conflicting, if there is a section which limit (computed by getEnrollmentWeight(Section, Request)) exceeds the section limit.
static double getEnrollmentWeight(Section section, Request request)
          Enrollment weight of a section if the given request is assigned.
 boolean inConflict(Value value)
          A given enrollment is conflicting, if there is a section which limit(computed by getEnrollmentWeight(Section, Request)) exceeds the section limit.
 String toString()
           
 
Methods inherited from class net.sf.cpsolver.ifs.model.GlobalConstraint
addVariable, assigned, assignedVariables, removeVariable, unassigned, variables
 
Methods inherited from class net.sf.cpsolver.ifs.model.Constraint
addConstraintListener, constraintListeners, countAssignedVariables, countVariables, equals, getDescription, getId, getModel, getName, hashCode, isConsistent, isHard, removeConstraintListener, setModel
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SectionLimit

public SectionLimit(DataProperties cfg)
Constructor

Parameters:
cfg - solver configuration
Method Detail

getEnrollmentWeight

public static double getEnrollmentWeight(Section section,
                                         Request request)
Enrollment weight of a section if the given request is assigned. In order to overcome rounding problems with last-like students ( e.g., 5 students are projected to two sections of limit 2 -- each section can have up to 3 of these last-like students), the weight of the request with the highest weight in the section is changed to a small nominal weight.

Parameters:
section - a section that is of concern
request - a request of a student to be assigned containing the given section
Returns:
section's new weight

computeConflicts

public void computeConflicts(Value value,
                             Set conflicts)
A given enrollment is conflicting, if there is a section which limit (computed by getEnrollmentWeight(Section, Request)) exceeds the section limit.
For each of such sections, one or more existing enrollments are (randomly) selected as conflicting until the overall weight is under the limit.

Specified by:
computeConflicts in class Constraint
Parameters:
value - Enrollment that is being considered
conflicts - all computed conflicting requests are added into this set

inConflict

public boolean inConflict(Value value)
A given enrollment is conflicting, if there is a section which limit(computed by getEnrollmentWeight(Section, Request)) exceeds the section limit.

Overrides:
inConflict in class Constraint
Parameters:
value - Enrollment that is being considered
Returns:
true, if there is a section which will exceed its limit when the given enrollment is assigned

toString

public String toString()
Overrides:
toString in class Object