Interface NeighborhoodTester<Solution_>

Type Parameters:
Solution_ - the planning solution type
All Known Implementing Classes:
DefaultNeighborhoodTester

@NullMarked public interface NeighborhoodTester<Solution_>
Entry point for evaluating MoveProviders on a given solution. Given a planning solution, it produces an NeighborhoodTestContext which contains all moves that can be generated from that solution using the provided MoveProvider.

Example usage:


 var solutionMetaModel = PlanningSolutionMetaModel.of(MySolution.class, MyEntity.class);
 var context = NeighborhoodTester.build(new MyMoveProvider(), solutionMetaModel)
         .using(solution);
 var moveIterator = context.getMovesAsIterator();

 while (moveIterator.hasNext()) {
     var move = moveIterator.next();
     // Run assertions on the move here.
 }
 

This package and all of its contents are part of the Neighborhoods API, which is under development and is only offered as a preview feature. There are no guarantees for backward compatibility; any method or field may change or be removed without prior notice, although we will strive to avoid this as much as possible.

  • Method Details

    • build

      static <Solution_> NeighborhoodTester<Solution_> build(MoveProvider<Solution_> moveProvider, PlanningSolutionMetaModel<Solution_> solutionMetaModel)
      Creates a new NeighborhoodTester for the given move provider and the given solution and entity classes.

      This method validates inputs, and initializes many internal structures. These are heavy operations performed once and cached for reuse.

      Shadow variables are initialized later when a solution is bound via using(Object).

      Type Parameters:
      Solution_ - the planning solution type
      Parameters:
      moveProvider - the move provider to generate moves
      solutionMetaModel - the planning solution meta-model; use PlanningSolutionMetaModel.of(Class, Class[]) to build one.
      Returns:
      a new NeighborhoodTester instance
    • using

      Creates an evaluation context for the given solution instance. Once you have the context, you can retrieve the moves via methods such as NeighborhoodTestContext.getMovesAsStream().

      Different evaluation contexts can be created, each bound to a different solution instance. They will operate independently of each other.

      Parameters:
      solution - the planning solution instance
      Returns:
      a new execution context bound to the given solution