An archive implementation inspired by @KyleErwin and my own research on the multi-guided PSO proposed by Dr Christiaan Scheepers.
The archive can either be unbounded (unbounded empty archive), bounded (bounded empty archive), boundedNonEmpty, or unboundedNonEmpty:
private final case class Empty[A](b: ArchiveBound, insertPolicy: (A, A) => Boolean) extends Archive[A] private final case class NonEmpty[A](l: List[A], b: ArchiveBound, insertPolicy: (A, A) => Boolean) extends Archive[A] def bounded[A](limit: Int Refined Positive, insertPolicy: (A, A) => Boolean, deletePolicy: List[A] => A): Archive[A] def unbounded[A](insertPolicy: (A, A) => Boolean): Archive[A] def boundedNonEmpty[A](seeds: NonEmptyList[A], limit: Int Refined Positive, insertPolicy: (A, A) => Boolean, deletePolicy: List[A] => A): Archive[A] def unboundedNonEmpty[A](seeds: NonEmptyList[A], insertPolicy: (A, A) => Boolean): Archive[A]
All implementations require some ArchiveBound type and an insert policy (determining whether a solution is "good" enough to be inserted into the Archive or not). The ArchiveBound type is used to (possibly) limit the capacity of the archive:
sealed trait ArchiveBound final case class Bounded[A](limit: Int Refined Positive, deletePolicy: List[A] => A) extends ArchiveBound final case class Unbounded() extends ArchiveBound
The NonEmpty Archive also accepts a list of "seed" values/solutions to be inserted into the Archive upon creation of the Archive.
The bounded and boundedNonEmpty Archives, in addition, accepts a delete policy which chooses a solution to be removed from the Archive once the Archive has reached max capacity.
The Archive use a List[A] as the underlying data structure to store solutions inserted into the Archive.
An archive implementation inspired by @KyleErwin and my own research on the multi-guided PSO proposed by Dr Christiaan Scheepers.
The archive can either be
unbounded
(unbounded empty archive),bounded
(bounded empty archive),boundedNonEmpty
, orunboundedNonEmpty
:private final case class Empty[A](b: ArchiveBound, insertPolicy: (A, A) => Boolean) extends Archive[A] private final case class NonEmpty[A](l: List[A], b: ArchiveBound, insertPolicy: (A, A) => Boolean) extends Archive[A] def bounded[A](limit: Int Refined Positive, insertPolicy: (A, A) => Boolean, deletePolicy: List[A] => A): Archive[A] def unbounded[A](insertPolicy: (A, A) => Boolean): Archive[A] def boundedNonEmpty[A](seeds: NonEmptyList[A], limit: Int Refined Positive, insertPolicy: (A, A) => Boolean, deletePolicy: List[A] => A): Archive[A] def unboundedNonEmpty[A](seeds: NonEmptyList[A], insertPolicy: (A, A) => Boolean): Archive[A]
All implementations require some
ArchiveBound
type and an insert policy (determining whether a solution is "good" enough to be inserted into the Archive or not). TheArchiveBound
type is used to (possibly) limit the capacity of the archive:sealed trait ArchiveBound final case class Bounded[A](limit: Int Refined Positive, deletePolicy: List[A] => A) extends ArchiveBound final case class Unbounded() extends ArchiveBound
The
NonEmpty
Archive also accepts a list of "seed" values/solutions to be inserted into the Archive upon creation of the Archive.The
bounded
andboundedNonEmpty
Archives, in addition, accepts a delete policy which chooses a solution to be removed from the Archive once the Archive has reached max capacity.The
Archive
use aList[A]
as the underlying data structure to store solutions inserted into the Archive.