net.sf.cpsolver.coursett.constraint
Class JenrlConstraint

java.lang.Object
  extended by net.sf.cpsolver.ifs.model.Constraint
      extended by net.sf.cpsolver.ifs.model.BinaryConstraint
          extended by net.sf.cpsolver.coursett.constraint.JenrlConstraint

public class JenrlConstraint
extends BinaryConstraint

Join student enrollment constraint.
This constraint is placed between all pairs of classes where there is at least one student attending both classes. It represents a number of student conflicts (number of joined enrollments), if the given two classes overlap in time.
Also, it dynamically maintains the counter of all student conflicts. It is a soft constraint.

Version:
CourseTT 1.1 (University Course Timetabling)
Copyright (C) 2006 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
JenrlConstraint()
          Constructor
 
Method Summary
 boolean areStudentConflictsDistance()
           
 boolean areStudentConflictsDistance(Value value)
           
 boolean areStudentConflictsHard()
           
 void assigned(long iteration, Value value)
          Given value is to be assigned to its varable.
 void computeConflicts(Value value, Set conflicts)
          The only method which has to be implemented by any constraint.
 void decJenrl(Student student)
          Decrement the number of joined enrollments (during student final sectioning)
 long getJenrl()
          Number of joined enrollments (during student final sectioning)
 double getJenrlWeight(Student student)
           
 int getNrStudents()
           
 void incJenrl(Student student)
          Increment the number of joined enrollments (during student final sectioning)
 boolean inConflict(Value value)
          Returns true if the given assignment is inconsistent with the existing assignments respecting this constraint.
 boolean isConsistent(Value value1, Value value2)
          Returns true if the given assignments are consistent respecting this constraint.
 boolean isHard()
          Returns true if the constraint is hard.
 boolean isInConflict()
          True if the given two lectures overlap in time
static boolean isInConflict(Placement p1, Placement p2)
          Returns true if the given placements are overlapping or they are back-to-back and too far for students.
static boolean isInConflict(Placement p1, Placement p2, boolean useDistances)
           
 boolean isInConflictPrecise()
          True if the given two lectures overlap in time
 boolean isOfTheSameProblem()
           
 long jenrl(Variable variable, Value value)
          Number of joined enrollments if the given value is assigned to the given variable
 String toString()
           
 void unassigned(long iteration, Value value)
          Given value is unassigned from its varable.
 
Methods inherited from class net.sf.cpsolver.ifs.model.BinaryConstraint
addVariable, another, first, isFirst, second
 
Methods inherited from class net.sf.cpsolver.ifs.model.Constraint
addConstraintListener, assignedVariables, constraintListeners, countAssignedVariables, countVariables, equals, getDescription, getId, getModel, getName, hashCode, removeConstraintListener, removeVariable, setModel, variables
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JenrlConstraint

public JenrlConstraint()
Constructor

Method Detail

computeConflicts

public void computeConflicts(Value value,
                             Set conflicts)
Description copied from class: Constraint
The only method which has to be implemented by any constraint. It returns the values which needs to be unassigned in order to make this constraint consistent with the given value if it is assigned to its variable. The computed list of conflicting values is added to the given set of conflicts.

Specified by:
computeConflicts in class Constraint
Parameters:
value - value to be assigned to its varaible
conflicts - resultant set of conflicting values

inConflict

public boolean inConflict(Value value)
Description copied from class: Constraint
Returns true if the given assignment is inconsistent with the existing assignments respecting this constraint. This method is used by MAC (see MacPropagation).

Overrides:
inConflict in class Constraint

isConsistent

public boolean isConsistent(Value value1,
                            Value value2)
Description copied from class: Constraint
Returns true if the given assignments are consistent respecting this constraint. This method is used by MAC (see MacPropagation).

Overrides:
isConsistent in class Constraint

unassigned

public void unassigned(long iteration,
                       Value value)
Description copied from class: Constraint
Given value is unassigned from its varable.

Overrides:
unassigned in class Constraint

isInConflict

public static boolean isInConflict(Placement p1,
                                   Placement p2)
Returns true if the given placements are overlapping or they are back-to-back and too far for students.


isInConflict

public static boolean isInConflict(Placement p1,
                                   Placement p2,
                                   boolean useDistances)

assigned

public void assigned(long iteration,
                     Value value)
Description copied from class: Constraint
Given value is to be assigned to its varable. In this method, the constraint should unassigns all varaibles which are in conflict with the given assignment because of this constraint.

Overrides:
assigned in class Constraint

jenrl

public long jenrl(Variable variable,
                  Value value)
Number of joined enrollments if the given value is assigned to the given variable


isInConflict

public boolean isInConflict()
True if the given two lectures overlap in time


isInConflictPrecise

public boolean isInConflictPrecise()
True if the given two lectures overlap in time


incJenrl

public void incJenrl(Student student)
Increment the number of joined enrollments (during student final sectioning)


getJenrlWeight

public double getJenrlWeight(Student student)

decJenrl

public void decJenrl(Student student)
Decrement the number of joined enrollments (during student final sectioning)


getJenrl

public long getJenrl()
Number of joined enrollments (during student final sectioning)


getNrStudents

public int getNrStudents()

isHard

public boolean isHard()
Description copied from class: Constraint
Returns true if the constraint is hard. Only hard constraints are allowed to unassign a variable when there is a conflict with a value that is being assigned

Overrides:
isHard in class Constraint

toString

public String toString()
Overrides:
toString in class Object

areStudentConflictsHard

public boolean areStudentConflictsHard()

areStudentConflictsDistance

public boolean areStudentConflictsDistance()

areStudentConflictsDistance

public boolean areStudentConflictsDistance(Value value)

isOfTheSameProblem

public boolean isOfTheSameProblem()