net.sf.cpsolver.studentsct.model
Class Request

java.lang.Object
  extended by net.sf.cpsolver.ifs.model.Variable
      extended by net.sf.cpsolver.studentsct.model.Request
All Implemented Interfaces:
Comparable
Direct Known Subclasses:
CourseRequest, FreeTimeRequest

public abstract class Request
extends Variable
implements Comparable

Representation of a request of a student for a course(s) or a free time. This can be either CourseRequest or FreeTimeRequest. Each request contains id, priority, weight, and a student. A request can be also marked as alternative.

For each student, all non-alternative requests should be satisfied (an enrollment is assigned to a request). If not, an alternative request can be assigned instead of a non-alternative course request. In the case when only one of two requests can be assigned, the one with the lowest priority is preferred.

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
static boolean sCacheValues
          True means that method values() will cache its results.
 
Fields inherited from class net.sf.cpsolver.ifs.model.Variable
iValue
 
Constructor Summary
Request(long id, int priority, boolean alternative, Student student)
          Constructor
 
Method Summary
 void assign(long iteration, Value value)
          Assign given enrollment to this request.
 int compareTo(Object o)
          Compare to requests, non-alternative requests go first, otherwise use priority (a request with lower priority goes first)
abstract  Vector computeEnrollments()
          Compute available enrollments
abstract  double getBound()
          Get bound, i.e., the value of the best possible enrollment
 long getId()
          Request id
 int getPriority()
          Request priority -- if there is a choice, request with lower priority is more preferred to be assigned
 Student getStudent()
          Student to which this request belongs
 double getWeight()
          Request weight, set by default to 1.0, defines the amount of space which will be taken in the section by this request.
 boolean isAlternative()
          True, if the request is alternative (alternative request can be assigned instead of a non-alternative course requests, if it is left unassigned)
 void setPriority(int priority)
          Set request priority
 void setWeight(double weight)
          Set request weight.
 void unassign(long iteration)
          Unassign currently assigned enrollment from this request.
 Vector values()
          Domain of this variable -- list of available enrollments.
 
Methods inherited from class net.sf.cpsolver.ifs.model.Variable
addContstraint, addVariableListener, constraints, constraintVariables, countAssignments, equals, getAssignment, getBestAssignment, getBestAssignmentIteration, getDescription, getExtra, getInitialAssignment, getModel, getName, getVariableListeners, hardConstraints, hasAssignment, hashCode, hasInitialAssignment, hasValues, lastAssignmentIteration, lastUnassignmentIteration, removeContstraint, removeInitialValue, removeValue, removeVariableListener, setBestAssignment, setExtra, setInitialAssignment, setModel, setValues, softConstraints, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

sCacheValues

public static boolean sCacheValues
True means that method values() will cache its results.

Constructor Detail

Request

public Request(long id,
               int priority,
               boolean alternative,
               Student student)
Constructor

Parameters:
id - course/free time request unique id
priority - request priority -- if there is a choice, request with lower priority is more preferred to be assigned
alternative - true if the request is alternative (alternative request can be assigned instead of a non-alternative course requests, if it is left unassigned)
student - student to which this request belongs
Method Detail

getId

public long getId()
Request id

Overrides:
getId in class Variable

getPriority

public int getPriority()
Request priority -- if there is a choice, request with lower priority is more preferred to be assigned


setPriority

public void setPriority(int priority)
Set request priority


isAlternative

public boolean isAlternative()
True, if the request is alternative (alternative request can be assigned instead of a non-alternative course requests, if it is left unassigned)


getStudent

public Student getStudent()
Student to which this request belongs


compareTo

public int compareTo(Object o)
Compare to requests, non-alternative requests go first, otherwise use priority (a request with lower priority goes first)

Specified by:
compareTo in interface Comparable
Overrides:
compareTo in class Variable

computeEnrollments

public abstract Vector computeEnrollments()
Compute available enrollments


values

public Vector values()
Domain of this variable -- list of available enrollments. Method computeEnrollments() is used.

Overrides:
values in class Variable

assign

public void assign(long iteration,
                   Value value)
Assign given enrollment to this request. This method also calls Assignment.assigned(Enrollment) on for all the assignments of the enrollment.

Overrides:
assign in class Variable
Parameters:
iteration - current iteration
value - the value to be assigned

unassign

public void unassign(long iteration)
Unassign currently assigned enrollment from this request. This method also calls Assignment.unassigned(Enrollment) on for all the assignments of the current enrollment.

Overrides:
unassign in class Variable
Parameters:
iteration - current iteration

getBound

public abstract double getBound()
Get bound, i.e., the value of the best possible enrollment


getWeight

public double getWeight()
Request weight, set by default to 1.0, defines the amount of space which will be taken in the section by this request.


setWeight

public void setWeight(double weight)
Set request weight. It defines the amount of space which will be taken in the section by this request.