org.cpsolver.coursett.constraint

## Class MinimizeNumberOfUsedGroupsOfTime

- java.lang.Object
- - org.cpsolver.ifs.model.Constraint<V,T>
  - - org.cpsolver.ifs.assignment.context.ConstraintWithContext<Lecture,Placement,MinimizeNumberOfUsedGroupsOfTime.MinimizeNumberOfUsedGroupsOfTimeContext>
    - - org.cpsolver.coursett.constraint.MinimizeNumberOfUsedGroupsOfTime

- All Implemented Interfaces:
    Comparable<Constraint<Lecture,Placement>>, CanHoldContext, HasAssignmentContext<Lecture,Placement,MinimizeNumberOfUsedGroupsOfTime.MinimizeNumberOfUsedGroupsOfTimeContext>, WeakeningConstraint<Lecture,Placement>

      public class MinimizeNumberOfUsedGroupsOfTime
      extends ConstraintWithContext<Lecture,Placement,MinimizeNumberOfUsedGroupsOfTime.MinimizeNumberOfUsedGroupsOfTimeContext>
      implements WeakeningConstraint<Lecture,Placement>

  Minimize number of used groups of time within a set of classes.
  This constraint implements the following distribution/group constraints:
  MIN_GRUSE(10x1h) (Minimize Use Of 1h Groups)
  Minimize number of groups of time that are used by the given classes. The time is spread into the following 10 groups of one hour: 7:30a-8:30a, 8:30a-9:30a, 9:30a-10:30a, ... 4:30p-5:30p.
  MIN_GRUSE(5x2h) (Minimize Use Of 2h Groups)
  Minimize number of groups of time that are used by the given classes. The time is spread into the following 5 groups of two hours: 7:30a-9:30a, 9:30a-11:30a, 11:30a-1:30p, 1:30p-3:30p, 3:30p-5:30p.
  MIN_GRUSE(3x3h) (Minimize Use Of 3h Groups)
  Minimize number of groups of time that are used by the given classes. The time is spread into the following 3 groups: 7:30a-10:30a, 10:30a-2:30p, 2:30p-5:30p.
  MIN_GRUSE(2x5h) (Minimize Use Of 5h Groups)
  Minimize number of groups of time that are used by the given classes. The time is spread into the following 2 groups: 7:30a-12:30a, 12:30a-5:30p.
  Version:
    CourseTT 1.3 (University Course Timetabling)
    Copyright (C) 2006 - 2014 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/.
  Author:
    Tomáš Müller

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `MinimizeNumberOfUsedGroupsOfTime.MinimizeNumberOfUsedGroupsOfTimeContext`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static org.cpsolver.coursett.constraint.MinimizeNumberOfUsedGroupsOfTime.GroupOfTime[]` | `sGroups10of1h`
    `static org.cpsolver.coursett.constraint.MinimizeNumberOfUsedGroupsOfTime.GroupOfTime[]` | `sGroups2of5h`
    `static org.cpsolver.coursett.constraint.MinimizeNumberOfUsedGroupsOfTime.GroupOfTime[]` | `sGroups3of3h`
    `static org.cpsolver.coursett.constraint.MinimizeNumberOfUsedGroupsOfTime.GroupOfTime[]` | `sGroups5of2h`

    - ### Fields inherited from class org.cpsolver.ifs.model.Constraint

      `iConstraintListeners, iId`

    - ### Fields inherited from interface org.cpsolver.ifs.assignment.context.CanHoldContext

      `sMaxSize`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MinimizeNumberOfUsedGroupsOfTime(DataProperties config, String name, org.cpsolver.coursett.constraint.MinimizeNumberOfUsedGroupsOfTime.GroupOfTime[] groupsOfTime)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `computeConflicts(Assignment<Lecture,Placement> assignment, Placement placement, Set<Placement> conflicts)` The only method which has to be implemented by any constraint.
    `MinimizeNumberOfUsedGroupsOfTime.MinimizeNumberOfUsedGroupsOfTimeContext` | `createAssignmentContext(Assignment<Lecture,Placement> assignment)` Create a new assignment context for the given assignment.
    `int` | `estimateLimit()`
    `String` | `getConstraintName()`
    `String` | `getName()` Constraint's name -- for printing purposes
    `String` | `toString()`
    `void` | `weaken(Assignment<Lecture,Placement> assignment)` Weaken the constraint.
    `void` | `weaken(Assignment<Lecture,Placement> assignment, Placement value)` Weaken the constraint enough so that it can assign the given value.

    - ### Methods inherited from class org.cpsolver.ifs.assignment.context.ConstraintWithContext

      `assigned, getAssignmentContextReference, getContext, getContext, setAssignmentContextReference, setModel, unassigned`

    - ### Methods inherited from class org.cpsolver.ifs.model.Constraint

      `addConstraintListener, addVariable, assignedVariables, compareTo, computeConflictsNoForwardCheck, constraintListeners, countAssignedVariables, countVariables, equals, getDescription, getId, getModel, hashCode, inConflict, isConsistent, isHard, removeConstraintListener, removeVariable, variables`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### sGroups2of5h

          public static org.cpsolver.coursett.constraint.MinimizeNumberOfUsedGroupsOfTime.GroupOfTime[] sGroups2of5h

    - #### sGroups3of3h

          public static org.cpsolver.coursett.constraint.MinimizeNumberOfUsedGroupsOfTime.GroupOfTime[] sGroups3of3h

    - #### sGroups5of2h

          public static org.cpsolver.coursett.constraint.MinimizeNumberOfUsedGroupsOfTime.GroupOfTime[] sGroups5of2h

    - #### sGroups10of1h

          public static org.cpsolver.coursett.constraint.MinimizeNumberOfUsedGroupsOfTime.GroupOfTime[] sGroups10of1h

  - ### Constructor Detail

    - #### MinimizeNumberOfUsedGroupsOfTime

          public MinimizeNumberOfUsedGroupsOfTime(DataProperties config,
                                                  String name,
                                                  org.cpsolver.coursett.constraint.MinimizeNumberOfUsedGroupsOfTime.GroupOfTime[] groupsOfTime)

  - ### Method Detail

    - #### estimateLimit

          public int estimateLimit()

    - #### computeConflicts

          public void computeConflicts(Assignment<Lecture,Placement> assignment,
                                       Placement placement,
                                       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 `Constraint<Lecture,Placement>`
      Parameters:
        `assignment` - current assignment
        `placement` - value to be assigned to its variable
        `conflicts` - resultant set of conflicting values

    - #### getConstraintName

          public String getConstraintName()

    - #### getName

          public String getName()

      Description copied from class: `Constraint`
      Constraint's name -- for printing purposes
      Overrides:
        `getName` in class `Constraint<Lecture,Placement>`
      Returns:
        constraint name

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### weaken

          public void weaken(Assignment<Lecture,Placement> assignment)

      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>`
      Parameters:
        `assignment` - current assignment

    - #### weaken

          public void weaken(Assignment<Lecture,Placement> assignment,
                             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>`
      Parameters:
        `assignment` - current assignment
        `value` - a conflicting value to be assigned

    - #### createAssignmentContext

          public MinimizeNumberOfUsedGroupsOfTime.MinimizeNumberOfUsedGroupsOfTimeContext createAssignmentContext(Assignment<Lecture,Placement> assignment)

      Description copied from interface: `HasAssignmentContext`
      Create a new assignment context for the given assignment. If there are already some variables assigned in the value, the method should make sure that the context is appropriately initialized.
      Specified by:
        `createAssignmentContext` in interface `HasAssignmentContext<Lecture,Placement,MinimizeNumberOfUsedGroupsOfTime.MinimizeNumberOfUsedGroupsOfTimeContext>`
      Parameters:
        `assignment` - an assignment for which there needs to be an assignment context
      Returns:
        a new instance of the assignment context, filled according to the given assignment