org.eclipse.viatra.dse.api.strategy.impl

## Class DepthFirstStrategy

- java.lang.Object
- - org.eclipse.viatra.dse.api.strategy.impl.DepthFirstStrategy

- All Implemented Interfaces:
    IStrategy

      public class DepthFirstStrategy
      extends java.lang.Object
      implements IStrategy

  A depth-first search algorithm implementation, that
  - can work with multiple threads,
  - randomly traverses the search space,
  - saves all states (trajectories) as solutions that fulfill all the hard objectives,
  - can have a depth limit,
  - will backtrack when a model satisfies the hard objectives (after saving it as a solution), which can be modified by calling `continueIfHardObjectivesFulfilled()`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DepthFirstStrategy()` Creates a new depth-first search algorithm without depth limit.
    `DepthFirstStrategy(int maxDepth)` Creates a new depth-first search algorithm with depth limit.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `DepthFirstStrategy` | `continueIfHardObjectivesFulfilled()` If called, the algorithm will not backtrack after the hard objectives are fulfilled, instead it goes deeper in the search space.
    `void` | `explore()` This method explores the design space as the implementation specifies.
    `void` | `initStrategy(ThreadContext context)` Initializes the strategy with a specific `ThreadContext`.
    `void` | `interruptStrategy()` The implementation of this interface should be ready to be interrupted.

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

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

- - ### Constructor Detail

    - #### DepthFirstStrategy

          public DepthFirstStrategy()

      Creates a new depth-first search algorithm without depth limit.

    - #### DepthFirstStrategy

          public DepthFirstStrategy(int maxDepth)

      Creates a new depth-first search algorithm with depth limit.
      Parameters:
        `maxDepth` - A negative `maxDepth` means no depth limit, zero means the checking of the initial state.

  - ### Method Detail

    - #### continueIfHardObjectivesFulfilled

          public DepthFirstStrategy continueIfHardObjectivesFulfilled()

      If called, the algorithm will not backtrack after the hard objectives are fulfilled, instead it goes deeper in the search space.

    - #### initStrategy

          public void initStrategy(ThreadContext context)

      Description copied from interface: `IStrategy`
      Initializes the strategy with a specific `ThreadContext`.
      Specified by:
        `initStrategy` in interface `IStrategy`
      Parameters:
        `context` - The context.

    - #### explore

          public void explore()

      Description copied from interface: `IStrategy`
      This method explores the design space as the implementation specifies. It will be called only once, hence the exploration loop is run by the implementation. The termination condition is also specified by the implementation and when it returns the exploration thread will be disposed.
      Specified by:
        `explore` in interface `IStrategy`

    - #### interruptStrategy

          public void interruptStrategy()

      Description copied from interface: `IStrategy`
      The implementation of this interface should be ready to be interrupted. If this method is called, the `IStrategy.explore()` method should return ASAP. This method is also called by the `SolutionStore` class if enough solutions are found.
      Specified by:
        `interruptStrategy` in interface `IStrategy`