org.cpsolver.studentsct.heuristics.selection

## Class StandardSelection

- java.lang.Object
- - org.cpsolver.studentsct.heuristics.selection.StandardSelection

- All Implemented Interfaces:
    NeighbourSelection<Request,Enrollment>, AssignmentCheck<Request,Enrollment>
  Direct Known Subclasses:
    CriticalStandardSelection

      public class StandardSelection
      extends Object
      implements NeighbourSelection<Request,Enrollment>, AssignmentCheck<Request,Enrollment>

  Use the provided variable and value selection for some time. The provided variable and value selection is used for the number of iterations equal to the number of all variables in the problem. If a complete solution is found, the neighbour selection is stopped (it returns null).
  Parameters:

  Related Solver Parameters
  Parameter | Type | Comment
  --- | --- | ---
  Neighbour.StandardIterations | `Long` | Number of iterations to perform. If -1, number of iterations is set to the number of unassigned variables.

  Version:
    StudentSct 1.3 (Student Sectioning)
    Copyright (C) 2007 - 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

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `iCanConflict`
    `protected boolean` | `iCanHigherPriorityConflict`
    `protected boolean` | `iCanWorsen`
    `protected boolean` | `iCanWorsenCritical`
    `protected long` | `iConflictTimeOut`
    `protected long` | `iNrIterations`
    `protected boolean` | `iPreferPriorityStudents`
    `protected long` | `iTimeOut`
    `protected ValueSelection<Request,Enrollment>` | `iValueSelection`
    `protected VariableSelection<Request,Enrollment>` | `iVariableSelection`
    `protected long` | `iWorsenTimeOut`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StandardSelection(DataProperties properties, VariableSelection<Request,Enrollment> variableSelection, ValueSelection<Request,Enrollment> valueSelection)` Constructor (variable and value selection are expected to be already initialized).

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `accept(SimpleNeighbour<Request,Enrollment> n, Solution<Request,Enrollment> solution)` Check whether the given neighbors can be returned
    `boolean` | `canUnassign(Enrollment enrollment, Enrollment conflict, Assignment<Request,Enrollment> assignment)` Check if the given conflicting enrollment can be unassigned
    `void` | `init(Solver<Request,Enrollment> solver)` Initialization
    `protected void` | `init(Solver<Request,Enrollment> solver, String name)`
    `Neighbour<Request,Enrollment>` | `selectNeighbour(Solution<Request,Enrollment> solution)` Employ the provided `VariableSelection` and `ValueSelection` and return the selected value as `SimpleNeighbour`.

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### iValueSelection

          protected ValueSelection<Request,Enrollment> iValueSelection

    - #### iVariableSelection

          protected VariableSelection<Request,Enrollment> iVariableSelection

    - #### iNrIterations

          protected long iNrIterations

    - #### iPreferPriorityStudents

          protected boolean iPreferPriorityStudents

    - #### iConflictTimeOut

          protected long iConflictTimeOut

    - #### iWorsenTimeOut

          protected long iWorsenTimeOut

    - #### iTimeOut

          protected long iTimeOut

    - #### iCanConflict

          protected boolean iCanConflict

    - #### iCanWorsen

          protected boolean iCanWorsen

    - #### iCanWorsenCritical

          protected boolean iCanWorsenCritical

    - #### iCanHigherPriorityConflict

          protected boolean iCanHigherPriorityConflict

  - ### Constructor Detail

    - #### StandardSelection

          public StandardSelection(DataProperties properties,
                                   VariableSelection<Request,Enrollment> variableSelection,
                                   ValueSelection<Request,Enrollment> valueSelection)

      Constructor (variable and value selection are expected to be already initialized).
      Parameters:
        `properties` - configuration
        `variableSelection` - variable selection
        `valueSelection` - value selection

  - ### Method Detail

    - #### init

          public void init(Solver<Request,Enrollment> solver)

      Initialization
      Specified by:
        `init` in interface `NeighbourSelection<Request,Enrollment>`
      Parameters:
        `solver` - current solver

    - #### init

          protected void init(Solver<Request,Enrollment> solver,
                              String name)

    - #### canUnassign

          public boolean canUnassign(Enrollment enrollment,
                                     Enrollment conflict,
                                     Assignment<Request,Enrollment> assignment)

      Check if the given conflicting enrollment can be unassigned
      Specified by:
        `canUnassign` in interface `AssignmentCheck<Request,Enrollment>`
      Parameters:
        `conflict` - given enrollment
        `enrollment` - value to be assigned
        `assignment` - current assignment
      Returns:
        if running MPP, do not unassign initial enrollments

    - #### accept

          public boolean accept(SimpleNeighbour<Request,Enrollment> n,
                                Solution<Request,Enrollment> solution)

      Check whether the given neighbors can be returned
      Returns:
        by default, any neighbors is accepted

    - #### selectNeighbour

          public Neighbour<Request,Enrollment> selectNeighbour(Solution<Request,Enrollment> solution)

      Employ the provided `VariableSelection` and `ValueSelection` and return the selected value as `SimpleNeighbour`. The selection is stopped (null is returned) after the number of iterations equal to the number of variables in the problem or when a complete solution is found.
      Specified by:
        `selectNeighbour` in interface `NeighbourSelection<Request,Enrollment>`
      Parameters:
        `solution` - given solution
      Returns:
        a neighbour assignment