net.sf.cpsolver.coursett.constraint
Class MaxBreaksFlexibleConstraint

java.lang.Object
  extended by net.sf.cpsolver.ifs.model.Constraint<Lecture,Placement>
      extended by net.sf.cpsolver.coursett.constraint.FlexibleConstraint
          extended by net.sf.cpsolver.coursett.constraint.MaxBreaksFlexibleConstraint
All Implemented Interfaces:
Comparable<Constraint<Lecture,Placement>>, WeakeningConstraint<Lecture,Placement>

public class MaxBreaksFlexibleConstraint
extends FlexibleConstraint
implements WeakeningConstraint<Lecture,Placement>

The MaxBreaks constraint limits the number of blocks of non back-to-back classes of an instructor on a day.
It has two parameters: a maximal number of breaks and a minimal length of a break between two classes not to be considered in the same block.
Reference _MaxBreaks:1:30_ translates to a maximum number of one break (two blocks) on a day of classes not more than 30 minutes a part.

Version:
CourseTT 1.2 (University Course Timetabling)
Copyright (C) 2013 Tomas Muller

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/.

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.cpsolver.coursett.constraint.FlexibleConstraint
FlexibleConstraint.Block, FlexibleConstraint.FlexibleConstraintType, FlexibleConstraint.PlacementTimeComparator
 
Field Summary
 
Fields inherited from class net.sf.cpsolver.coursett.constraint.FlexibleConstraint
iConstraintType, iReference, iWeeks
 
Fields inherited from class net.sf.cpsolver.ifs.model.Constraint
iAssignedVariables, iConstraintListeners, iId
 
Constructor Summary
MaxBreaksFlexibleConstraint(Long id, String owner, String preference, String reference)
           
 
Method Summary
 void assigned(long iteration, Placement value)
          Given value is to be assigned to its varable.
 void computeConflicts(Placement value, Set<Placement> conflicts)
          The only method which has to be implemented by any constraint.
 List<FlexibleConstraint.Block> getBlocks(int dayCode, Set<Placement> conflicts, Placement value, HashMap<Lecture,Placement> assignments, BitSet week)
           
 double getNrViolations(Set<Placement> conflicts, HashMap<Lecture,Placement> assignments)
           
 void weaken()
          Weaken the constraint.
 void weaken(Placement value)
          Weaken the constraint enough so that it can assign the given value.
 
Methods inherited from class net.sf.cpsolver.coursett.constraint.FlexibleConstraint
getCurrentPreference, getName, getOwner, getPrologPreference, getReference, getRelevantPlacements, getType, getWeeks, isConsistent, isHard, mergeToBlocks, toString, unassigned
 
Methods inherited from class net.sf.cpsolver.ifs.model.Constraint
addConstraintListener, addVariable, assignedVariables, compareTo, constraintListeners, countAssignedVariables, countVariables, equals, getDescription, getId, getModel, hashCode, inConflict, removeConstraintListener, removeVariable, setModel, variables
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MaxBreaksFlexibleConstraint

public MaxBreaksFlexibleConstraint(Long id,
                                   String owner,
                                   String preference,
                                   String reference)
Method Detail

getBlocks

public List<FlexibleConstraint.Block> getBlocks(int dayCode,
                                                Set<Placement> conflicts,
                                                Placement value,
                                                HashMap<Lecture,Placement> assignments,
                                                BitSet week)

getNrViolations

public double getNrViolations(Set<Placement> conflicts,
                              HashMap<Lecture,Placement> assignments)
Specified by:
getNrViolations in class FlexibleConstraint
Parameters:
conflicts - conflicting placements to be unassigned
assignments - assigned placements
Returns:
the number of violations of the constraint during days and all weeks of the semester

computeConflicts

public void computeConflicts(Placement value,
                             Set<Placement> 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 FlexibleConstraint
Parameters:
value - value to be assigned to its varaible
conflicts - resultant set of conflicting values

weaken

public void weaken()
Description copied from interface: WeakeningConstraint
Weaken the constraint. This method is called if the constraint participates in an unassigned of a variable.

Specified by:
weaken in interface WeakeningConstraint<Lecture,Placement>

weaken

public void weaken(Placement value)
Description copied from interface: WeakeningConstraint
Weaken the constraint enough so that it can assign the given value.

Specified by:
weaken in interface WeakeningConstraint<Lecture,Placement>

assigned

public void assigned(long iteration,
                     Placement 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 FlexibleConstraint


Copyright © 2014 UniTime LLC. All Rights Reserved.