net.sf.cpsolver.exam.heuristics

## Class ExamHillClimbing

- java.lang.Object
- - net.sf.cpsolver.exam.heuristics.ExamHillClimbing

- All Implemented Interfaces:
    NeighbourSelection<Exam,ExamPlacement>, LazyNeighbour.LazyNeighbourAcceptanceCriterion<Exam,ExamPlacement>, SolutionListener<Exam,ExamPlacement>

      public class ExamHillClimbing
      extends Object
      implements NeighbourSelection<Exam,ExamPlacement>, SolutionListener<Exam,ExamPlacement>, LazyNeighbour.LazyNeighbourAcceptanceCriterion<Exam,ExamPlacement>

  Hill climber. In each iteration, one of the following three neighbourhoods is selected first
  - random move (`ExamRandomMove`)
  - period swap (`ExamTimeMove`)
  - room swap (`ExamRoomMove`)
  , then a neighbour is generated and it is accepted if its value `ExamSimpleNeighbour.value()` is below or equal to zero. The search is stopped after a given amount of idle iterations ( can be defined by problem property HillClimber.MaxIdle).
  Version:
    ExamTT 1.2 (Examination Timetabling)
    Copyright (C) 2008 - 2010 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/.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExamHillClimbing(DataProperties properties)` Constructor
    `ExamHillClimbing(DataProperties properties, String name)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `accept(LazyNeighbour<Exam,ExamPlacement> neighbour, double value)` Accept lazy neighbour
    `void` | `bestCleared(Solution<Exam,ExamPlacement> solution)` Called by the solution when method `Solution.clearBest()` is called.
    `void` | `bestRestored(Solution<Exam,ExamPlacement> solution)` Called by the solution when method `Solution.restoreBest()` is called.
    `void` | `bestSaved(Solution<Exam,ExamPlacement> solution)` Memorize the iteration when the last best solution was found.
    `void` | `getInfo(Solution<Exam,ExamPlacement> solution, Map<String,String> info)` Called by the solution when it is asked to produce info table, see `Solution.getInfo()`.
    `void` | `getInfo(Solution<Exam,ExamPlacement> solution, Map<String,String> info, Collection<Exam> variables)` Called by the solution when it is asked to produce info table, see `Solution.getInfo()`.
    `void` | `init(Solver<Exam,ExamPlacement> solver)` Initialization
    `Neighbour<Exam,ExamPlacement>` | `selectNeighbour(Solution<Exam,ExamPlacement> solution)` Select one of the given neighbourhoods randomly, select neighbour, return it if its value is below or equal to zero (continue with the next selection otherwise).
    `void` | `solutionUpdated(Solution<Exam,ExamPlacement> solution)` Called by the solution when it is updated, see `Solution.update(double)`.

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

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

- - ### Constructor Detail

    - #### ExamHillClimbing

          public ExamHillClimbing(DataProperties properties)

      Constructor
      Parameters:
        `properties` - problem properties (use HillClimber.MaxIdle to set maximum number of idle iterations)

    - #### ExamHillClimbing

          public ExamHillClimbing(DataProperties properties,
                                  String name)

      Constructor
      Parameters:
        `properties` - problem properties (use HillClimber.MaxIdle to set maximum number of idle iterations)

  - ### Method Detail

    - #### init

          public void init(Solver<Exam,ExamPlacement> solver)

      Initialization
      Specified by:
        `init` in interface `NeighbourSelection<Exam,ExamPlacement>`

    - #### selectNeighbour

          public Neighbour<Exam,ExamPlacement> selectNeighbour(Solution<Exam,ExamPlacement> solution)

      Select one of the given neighbourhoods randomly, select neighbour, return it if its value is below or equal to zero (continue with the next selection otherwise). Return null when the given number of idle iterations is reached.
      Specified by:
        `selectNeighbour` in interface `NeighbourSelection<Exam,ExamPlacement>`
      Parameters:
        `solution` - given solution
      Returns:
        a neighbour assignment

    - #### bestSaved

          public void bestSaved(Solution<Exam,ExamPlacement> solution)

      Memorize the iteration when the last best solution was found.
      Specified by:
        `bestSaved` in interface `SolutionListener<Exam,ExamPlacement>`
      Parameters:
        `solution` - source solution

    - #### solutionUpdated

          public void solutionUpdated(Solution<Exam,ExamPlacement> solution)

      Description copied from interface: `SolutionListener`
      Called by the solution when it is updated, see `Solution.update(double)`.
      Specified by:
        `solutionUpdated` in interface `SolutionListener<Exam,ExamPlacement>`
      Parameters:
        `solution` - source solution

    - #### getInfo

          public void getInfo(Solution<Exam,ExamPlacement> solution,
                              Map<String,String> info)

      Description copied from interface: `SolutionListener`
      Called by the solution when it is asked to produce info table, see `Solution.getInfo()`. A listener can also add some its info into this table.
      Specified by:
        `getInfo` in interface `SolutionListener<Exam,ExamPlacement>`
      Parameters:
        `solution` - source solution
        `info` - produced info table

    - #### getInfo

          public void getInfo(Solution<Exam,ExamPlacement> solution,
                              Map<String,String> info,
                              Collection<Exam> variables)

      Description copied from interface: `SolutionListener`
      Called by the solution when it is asked to produce info table, see `Solution.getInfo()`. A listener can also add some its info into this table.
      Specified by:
        `getInfo` in interface `SolutionListener<Exam,ExamPlacement>`
      Parameters:
        `solution` - source solution
        `info` - produced info table
        `variables` - only variables from this set are included

    - #### bestCleared

          public void bestCleared(Solution<Exam,ExamPlacement> solution)

      Description copied from interface: `SolutionListener`
      Called by the solution when method `Solution.clearBest()` is called.
      Specified by:
        `bestCleared` in interface `SolutionListener<Exam,ExamPlacement>`
      Parameters:
        `solution` - source solution

    - #### bestRestored

          public void bestRestored(Solution<Exam,ExamPlacement> solution)

      Description copied from interface: `SolutionListener`
      Called by the solution when method `Solution.restoreBest()` is called.
      Specified by:
        `bestRestored` in interface `SolutionListener<Exam,ExamPlacement>`
      Parameters:
        `solution` - source solution

    - #### accept

          public boolean accept(LazyNeighbour<Exam,ExamPlacement> neighbour,
                                double value)

      Accept lazy neighbour
      Specified by:
        `accept` in interface `LazyNeighbour.LazyNeighbourAcceptanceCriterion<Exam,ExamPlacement>`
      Parameters:
        `neighbour` - neighbour that was assigned
        `value` - change in overall solution value
      Returns:
        true if the neighbour can be accepted (false to undo the assignment)