net.sf.cpsolver.studentsct.model
Class Request

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

public abstract class Request
extends Variable<Request,Enrollment>

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.2 (Student Sectioning)
Copyright (C) 2007 - 2010 Tomas Muller
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
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, Enrollment enrollment)
          Assign given enrollment to this request.
 int compareTo(Request r)
          Compare to requests, non-alternative requests go first, otherwise use priority (a request with lower priority goes first)
abstract  List<Enrollment> computeEnrollments()
          Compute available enrollments
 boolean equals(Object o)
           
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.
 int hashCode()
           
 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)
 boolean isAssigned()
          Return true if request is assigned.
 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.
 List<Enrollment> values()
          Domain of this variable -- list of available enrollments.
 
Methods inherited from class net.sf.cpsolver.ifs.model.Variable
addContstraint, addVariableListener, constraints, constraintVariables, countAssignments, getAssignment, getBestAssignment, getBestAssignmentIteration, getDescription, getExtra, getInitialAssignment, getModel, getName, getVariableListeners, hardConstraints, hasAssignment, 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<Request,Enrollment>

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(Request r)
Compare to requests, non-alternative requests go first, otherwise use priority (a request with lower priority goes first)

Specified by:
compareTo in interface Comparable<Request>
Overrides:
compareTo in class Variable<Request,Enrollment>

computeEnrollments

public abstract List<Enrollment> computeEnrollments()
Compute available enrollments


values

public List<Enrollment> values()
Domain of this variable -- list of available enrollments. Method computeEnrollments() is used.

Overrides:
values in class Variable<Request,Enrollment>

assign

public void assign(long iteration,
                   Enrollment enrollment)
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<Request,Enrollment>
Parameters:
iteration - current iteration
enrollment - 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<Request,Enrollment>
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.


isAssigned

public boolean isAssigned()
Return true if request is assigned.


hashCode

public int hashCode()
Overrides:
hashCode in class Variable<Request,Enrollment>

equals

public boolean equals(Object o)
Overrides:
equals in class Variable<Request,Enrollment>


Copyright © 2014 UniTime LLC. All Rights Reserved.