Interface MoveTester<Solution_>

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

@NullMarked public interface MoveTester<Solution_>
Entry point for executing Moves on planning solutions.

Provides a fluent API for testing move implementations in both permanent and temporary modes. Designed for testing and development use cases, not production solving workflows.

This class is NOT thread-safe. Each thread must create its own MoveTester instance.

Example usage:


     var solutionMetaModel = PlanningSolutionMetaModel.of(MySolution.class, MyEntity.class);
     var tester = MoveTester.build(solutionMetaModel);
     var basicVariable = solutionMetaModel.genuineEntity(MyEntity.class)
          .basicVariable();

     var move = Moves.change(basicVariable, ..., ...);

     // Permanent execution
     var context = tester.using(solution);
     context.execute(move);

     // Temporary execution with automatic undo
     context.executeTemporarily(move, view -> {
         assertThat(view.getValue(...)).isEqualTo(expected);
     });
 

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_> MoveTester<Solution_> build(PlanningSolutionMetaModel<Solution_> solutionMetaModel)
      Creates a new MoveTester for 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:
      solutionMetaModel - the planning solution class; use PlanningSolutionMetaModel.of(Class, Class[]) to build one.
      Returns:
      a new instance
    • using

      Creates an execution context for the given solution instance.

      This method creates a score director from the cached factory and sets the working solution, which automatically triggers shadow variable initialization for the provided solution.

      Multiple execution contexts can be created from the same MoveTester instance, allowing sequential move execution with different solutions or the same solution at different points in time.

      Parameters:
      solution - the planning solution instance
      Returns:
      a new execution context bound to the given solution with initialized shadow variables