java.lang.Object
es.urjc.etsii.grafo.solution.neighborhood.ExploreResult<M,S,I>
- Type Parameters:
M
- Move typeS
- Solution typeI
- 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 Summary
ConstructorsConstructorDescriptionEmpty explore resultsExploreResult
(Stream<M> moves, int size) Explore result from a stream of moves, with given size. -
Method Summary
Modifier and TypeMethodDescriptionstatic <M extends Move<S,
I>, S extends Solution<S, I>, I extends Instance>
ExploreResult<M, S, I> empty()
Empty explore resultsboolean
static <M extends Move<S,
I>, S extends Solution<S, I>, I extends Instance>
ExploreResult<M, S, I> Explore result from a liststatic <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 streamstatic <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.int
hashCode()
moves()
int
size()
boolean
sized()
Optionally calculate how big the neighborhood is for a given solution.toString()
-
Constructor Details
-
ExploreResult
Explore result from a stream of moves, with given size.- Parameters:
moves
- stream of movessize
- 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>, ExploreResult<M,S extends Solution<S, I>, I extends Instance> S, fromStreamI> (Stream<M> moves) Unknown size constructor from stream- Parameters:
moves
- move stream
-
fromStream
public static <M extends Move<S,I>, ExploreResult<M,S extends Solution<S, I>, I extends Instance> S, fromStreamI> (Stream<M> moves, int size) Explore result from a stream of moves, with given size.- Parameters:
moves
- stream of movessize
- neighborhood size if known,Neighborhood.UNKNOWN_SIZE
if not
-
empty
public static <M extends Move<S,I>, ExploreResult<M,S extends Solution<S, I>, I extends Instance> S, empty()I> Empty explore results- Returns:
- empty explore results
-
fromList
public static <M extends Move<S,I>, ExploreResult<M,S extends Solution<S, I>, I extends Instance> S, fromListI> (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, returnNeighborhood.UNKNOWN_SIZE
instead.- Returns:
- true if the neighborhood has a size estimation, UNKNOWN_SIZE if the size is unknown or cannot be estimated.
-
moves
-
size
public int size() -
equals
-
hashCode
public int hashCode() -
toString
-