net.sf.cpsolver.exam.model
Class ExamStudent

java.lang.Object
  extended by net.sf.cpsolver.ifs.model.Constraint<Exam,ExamPlacement>
      extended by net.sf.cpsolver.exam.model.ExamStudent
All Implemented Interfaces:
Comparable<Constraint<Exam,ExamPlacement>>

public class ExamStudent
extends Constraint<Exam,ExamPlacement>

A student.

Version:
ExamTT 1.2 (Examination Timetabling)
Copyright (C) 2008 - 2010 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/.

Field Summary
 
Fields inherited from class net.sf.cpsolver.ifs.model.Constraint
iAssignedVariables, iConstraintListeners, iId
 
Constructor Summary
ExamStudent(ExamModel model, long id)
          Constructor
 
Method Summary
 void afterAssigned(long iteration, ExamPlacement value)
          An exam was assigned, update student assignment table
 void afterUnassigned(long iteration, ExamPlacement value)
          An exam was unassigned, update student assignment table
 boolean canConflict(Exam ex1, Exam ex2)
          True if the given two exams can have a direct student conflict with this student, i.e., they can be placed at the same period.
 int compareTo(Constraint<Exam,ExamPlacement> o)
          Compare two students (by student ids)
 void computeConflicts(ExamPlacement p, Set<ExamPlacement> conflicts)
          Compute conflicts between the given assignment of an exam and all the current assignments (of this student).
 boolean equals(Object o)
          Compare two student for equality
 Set<Exam> getExams(ExamPeriod period)
          Exam(s) enrolled by the student that are scheduled in the given period
 Set<Exam> getExamsADay(ExamPeriod period)
          Exam(s) enrolled by the student that are scheduled in the given day
 Set<Exam> getExamsADay(int day)
          Exam(s) enrolled by the student that are scheduled in the given day
 List<ExamOwner> getOwners()
          Courses and/or sections that this student is enrolled to
 int hashCode()
          Hash code
 boolean inConflict(ExamPlacement p)
          Check whether there is a conflict between the given assignment of an exam and all the current assignments (of this student).
 boolean isAllowDirectConflicts()
          True if direct student conflicts are allowed for this student
 boolean isAvailable(ExamPeriod period)
          True if the student is available (for examination timetabling) during the given period
 boolean isConsistent(ExamPlacement p1, ExamPlacement p2)
          True if the given exams can conflict (see canConflict(Exam, Exam)), or if they are placed at different periods.
 boolean isHard()
          Constraint is hard if isAllowDirectConflicts() is false.
 void setAllowDirectConflicts(boolean allowDirectConflicts)
          Set whether direct student conflicts are allowed for this student
 void setAvailable(int period, boolean available)
          Set whether the student is available (for examination timetabling) during the given period
 String toString()
          Student unique id
 
Methods inherited from class net.sf.cpsolver.ifs.model.Constraint
addConstraintListener, addVariable, assigned, assignedVariables, constraintListeners, countAssignedVariables, countVariables, getDescription, getId, getModel, getName, removeConstraintListener, removeVariable, setModel, unassigned, variables
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExamStudent

public ExamStudent(ExamModel model,
                   long id)
Constructor

Parameters:
model - examination timetabling model
id - student unique id
Method Detail

isAllowDirectConflicts

public boolean isAllowDirectConflicts()
True if direct student conflicts are allowed for this student


setAllowDirectConflicts

public void setAllowDirectConflicts(boolean allowDirectConflicts)
Set whether direct student conflicts are allowed for this student


canConflict

public boolean canConflict(Exam ex1,
                           Exam ex2)
True if the given two exams can have a direct student conflict with this student, i.e., they can be placed at the same period.

Parameters:
ex1 - an exam
ex2 - an exam
Returns:
isAllowDirectConflicts() and Exam.isAllowDirectConflicts() for both exams

getExams

public Set<Exam> getExams(ExamPeriod period)
Exam(s) enrolled by the student that are scheduled in the given period


getExamsADay

public Set<Exam> getExamsADay(ExamPeriod period)
Exam(s) enrolled by the student that are scheduled in the given day


getExamsADay

public Set<Exam> getExamsADay(int day)
Exam(s) enrolled by the student that are scheduled in the given day


computeConflicts

public void computeConflicts(ExamPlacement p,
                             Set<ExamPlacement> conflicts)
Compute conflicts between the given assignment of an exam and all the current assignments (of this student). Only not-allowed conflicts (see canConflict(Exam, Exam) are considered.

Specified by:
computeConflicts in class Constraint<Exam,ExamPlacement>
Parameters:
p - value to be assigned to its varaible
conflicts - resultant set of conflicting values

inConflict

public boolean inConflict(ExamPlacement p)
Check whether there is a conflict between the given assignment of an exam and all the current assignments (of this student). Only not-allowed conflicts (see canConflict(Exam, Exam) are considered.

Overrides:
inConflict in class Constraint<Exam,ExamPlacement>

isConsistent

public boolean isConsistent(ExamPlacement p1,
                            ExamPlacement p2)
True if the given exams can conflict (see canConflict(Exam, Exam)), or if they are placed at different periods.

Overrides:
isConsistent in class Constraint<Exam,ExamPlacement>

afterAssigned

public void afterAssigned(long iteration,
                          ExamPlacement value)
An exam was assigned, update student assignment table


afterUnassigned

public void afterUnassigned(long iteration,
                            ExamPlacement value)
An exam was unassigned, update student assignment table


equals

public boolean equals(Object o)
Compare two student for equality

Overrides:
equals in class Constraint<Exam,ExamPlacement>

hashCode

public int hashCode()
Hash code

Overrides:
hashCode in class Constraint<Exam,ExamPlacement>

toString

public String toString()
Student unique id

Overrides:
toString in class Object

compareTo

public int compareTo(Constraint<Exam,ExamPlacement> o)
Compare two students (by student ids)

Specified by:
compareTo in interface Comparable<Constraint<Exam,ExamPlacement>>
Overrides:
compareTo in class Constraint<Exam,ExamPlacement>

isHard

public boolean isHard()
Constraint is hard if isAllowDirectConflicts() is false.

Overrides:
isHard in class Constraint<Exam,ExamPlacement>

getOwners

public List<ExamOwner> getOwners()
Courses and/or sections that this student is enrolled to

Returns:
list of ExamOwner

isAvailable

public boolean isAvailable(ExamPeriod period)
True if the student is available (for examination timetabling) during the given period

Parameters:
period - a period
Returns:
true if a student can attend an exam at the given period, false if otherwise

setAvailable

public void setAvailable(int period,
                         boolean available)
Set whether the student is available (for examination timetabling) during the given period

Parameters:
period - a period
available - true if a student can attend an exam at the given period, false if otherwise