Class ExploreResult<M extends Move<S,I>,S extends Solution<S,I>,I extends Instance>

java.lang.Object
es.urjc.etsii.grafo.solution.neighborhood.ExploreResult<M,S,I>
Type Parameters:
M - Move type
S - Solution type
I - Instance type
Direct Known Subclasses:
ListExploreResult

public class ExploreResult<M extends Move<S,I>,S extends Solution<S,I>,I extends Instance> extends Object

Optionally calculate how big the neighborhood is for a given solution. It does not need to be an exact value, but it should be an upper bound. It is perfectly valid to estimate the size to 100 and then returning only 90 elements from the neighborhood, but it is not ok to estimate size to 10 and then returning 100 elements. Internally will be used to correctly size data structures and try to improve performance. Implementation should have O(1) or O(log n) complexity, if the size can be calculated but takes O(n) or longer, return Neighborhood.UNKNOWN_SIZE instead.

  • Constructor Details

    • ExploreResult

      public ExploreResult(Stream<M> moves, int size)
      Explore result from a stream of moves, with given size.
      Parameters:
      moves - stream of moves
      size - neighborhood size if known, Neighborhood.UNKNOWN_SIZE if not
    • ExploreResult

      public ExploreResult()
      Empty explore results
  • Method Details

    • fromStream

      public static <M extends Move<S, I>, S extends Solution<S, I>, I extends Instance> ExploreResult<M,S,I> fromStream(Stream<M> moves)
      Unknown size constructor from stream
      Parameters:
      moves - move stream
    • fromStream

      public static <M extends Move<S, I>, S extends Solution<S, I>, I extends Instance> ExploreResult<M,S,I> fromStream(Stream<M> moves, int size)
      Explore result from a stream of moves, with given size.
      Parameters:
      moves - stream of moves
      size - neighborhood size if known, Neighborhood.UNKNOWN_SIZE if not
    • empty

      public static <M extends Move<S, I>, S extends Solution<S, I>, I extends Instance> ExploreResult<M,S,I> empty()
      Empty explore results
      Returns:
      empty explore results
    • fromList

      public static <M extends Move<S, I>, S extends Solution<S, I>, I extends Instance> ExploreResult<M,S,I> fromList(List<M> moves)
      Explore result from a list
      Parameters:
      moves - list of moves
    • sized

      public boolean sized()
      Optionally calculate how big the neighborhood is for a given solution. It does not need to be an exact value, but it should be an upper bound. It is perfectly valid to estimate the size to 100 and then returning only 90 elements from the neighborhood, but it is not ok to estimate size to 10 and then returning 100 elements. Internally will be used to correctly size data structures and try to improve performance. Implementation should have O(1) or O(log n) complexity, if the size can be calculated but takes O(n) or longer, return Neighborhood.UNKNOWN_SIZE instead.
      Returns:
      true if the neighborhood has a size estimation, UNKNOWN_SIZE if the size is unknown or cannot be estimated.
    • moves

      public Stream<M> moves()
    • size

      public int size()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object