com.cra.figaro.algorithm.sampling.parallel

ParSampler

Related Doc: package parallel

abstract class ParSampler extends BaseProbQuerySampler[Reference] with ParSamplingAlgorithm

Parallel version of a sampling algorithm. Has a parallel collection of algorithm instances that will do its work on separate threads, over separate universes. Uses Scala's parallel collections to divide up the work, so it will work best if told to run on a number of threads less than or equal to the number of worker threads Scala creates when operating over parallel collections.

This creates two major differences with how a user interacts with the algorithm. First of all, rather than defining a model on a universe and then starting the algorithm, the user must define a function that generates a universe and applies any evidence, and then pass that to the companion object to create the algorithm. The second major difference is that elements must be referred to using references, since each variable will exist as multiple elements across the different universes.

One-time sampling will be faster, since it divides the work over the different threads. Anytime sampling should provide more accurate results, since it can take more samples over the same amount of time. Both cases will most likely require more memory, at least using the current implementation of WeightedSampler, which keeps track of all values and weights that have been sampled. When querying, a weighted combination of the results of the various threads is returned. This last step adds some overhead, which should be negligible as long as you are taking a large number of samples.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ParSampler
  2. ParSamplingAlgorithm
  3. BaseProbQuerySampler
  4. BaseProbQueryAlgorithm
  5. Algorithm
  6. AnyRef
  7. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ParSampler(algs: Seq[ProbQuerySampler], targets: Reference[_]*)

Type Members

  1. class NotATargetException[T] extends AlgorithmException

    Definition Classes
    BaseProbQueryAlgorithm

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. var active: Boolean

    Attributes
    protected
    Definition Classes
    Algorithm
  5. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  6. def cleanUp(): Unit

    Calls cleanUp() on all algorithms.

    Calls cleanUp() on all algorithms.

    Definition Classes
    ParSamplingAlgorithmAlgorithm
  7. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def computeDistribution[T](target: Reference[T]): Stream[(Double, T)]

    Return an estimate of the expectation of the function under the marginal probability distribution of the target.

    Return an estimate of the expectation of the function under the marginal probability distribution of the target.

    Definition Classes
    BaseProbQuerySamplerBaseProbQueryAlgorithm
  9. def computeExpectation[T](target: Reference[T], function: (T) ⇒ Double): Double

    Return an estimate of the expectation of the function under the marginal probability distribution of the target.

    Return an estimate of the expectation of the function under the marginal probability distribution of the target.

    Definition Classes
    BaseProbQuerySamplerBaseProbQueryAlgorithm
  10. def computeProbability[T](target: Reference[T], predicate: (T) ⇒ Boolean): Double

    Return an estimate of the probability of the predicate under the marginal probability distribution of the target.

    Return an estimate of the probability of the predicate under the marginal probability distribution of the target.

    Definition Classes
    BaseProbQueryAlgorithm
  11. def computeProjection[T](target: Reference[T]): List[(T, Double)]

    Attributes
    protected[com.cra.figaro.algorithm]
    Definition Classes
    ParSamplerBaseProbQueryAlgorithm
  12. def distribution[T](target: Reference[T]): Stream[(Double, T)]

    Return an estimate of the marginal probability distribution over the target that lists each element with its probability.

    Return an estimate of the marginal probability distribution over the target that lists each element with its probability. The result is a lazy stream. It is up to the algorithm how the stream is ordered. Throws NotATargetException if called on a target that is not in the list of targets of the algorithm. Throws AlgorithmInactiveException if the algorithm is inactive.

    Definition Classes
    BaseProbQueryAlgorithm
  13. def doDistribution[T](target: Reference[T]): Stream[(Double, T)]

    Methods from BaseProbQueryAlgorithm *

    Methods from BaseProbQueryAlgorithm *

    Attributes
    protected
    Definition Classes
    ParSamplerBaseProbQueryAlgorithm
  14. def doExpectation[T](target: Reference[T], function: (T) ⇒ Double): Double

    Attributes
    protected
    Definition Classes
    ParSamplerBaseProbQueryAlgorithm
  15. def doKill(): Unit

    Attributes
    protected[com.cra.figaro.algorithm]
    Definition Classes
    ParSamplingAlgorithmAlgorithm
  16. def doProbability[T](target: Reference[T], predicate: (T) ⇒ Boolean): Double

    Attributes
    protected
    Definition Classes
    ParSamplerBaseProbQueryAlgorithm
  17. def doProjection[T](target: Reference[T]): List[(T, Double)]

    Attributes
    protected
    Definition Classes
    ParSamplerBaseProbQueryAlgorithm
  18. def doResume(): Unit

    Attributes
    protected[com.cra.figaro.algorithm]
    Definition Classes
    ParSamplingAlgorithmAlgorithm
  19. def doStart(): Unit

    Attributes
    protected[com.cra.figaro.algorithm]
    Definition Classes
    ParSamplingAlgorithmAlgorithm
  20. def doStop(): Unit

    Attributes
    protected[com.cra.figaro.algorithm]
    Definition Classes
    ParSamplingAlgorithmAlgorithm
  21. def element[T](alg: ProbQuerySampler, element: Reference[T]): Element[T]

    Get an element from a reference *

    Get an element from a reference *

    Attributes
    protected
  22. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  23. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  24. def expectation[T](target: Reference[T], function: (T) ⇒ Double): Double

    Return an estimate of the expectation of the function under the marginal probability distribution of the target.

    Return an estimate of the expectation of the function under the marginal probability distribution of the target. Throws NotATargetException if called on a target that is not in the list of targets of the algorithm. Throws AlgorithmInactiveException if the algorithm is inactive.

    Definition Classes
    BaseProbQueryAlgorithm
  25. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  26. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  27. def getTotalWeight: Double

    Log sum of total weights of individual algorithms *

    Log sum of total weights of individual algorithms *

    Definition Classes
    ParSamplerBaseProbQuerySampler
  28. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  29. def initialize(): Unit

    Calls initialize() on all algorithms.

    Calls initialize() on all algorithms.

    Definition Classes
    ParSamplingAlgorithmAlgorithm
  30. def isActive: Boolean

    Definition Classes
    Algorithm
  31. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  32. def kill(): Unit

    Kill the algorithm so that it is inactive.

    Kill the algorithm so that it is inactive. It will no longer be able to provide answers.Throws AlgorithmInactiveException if the algorithm is not active.

    Definition Classes
    Algorithm
  33. def mean(target: Reference[Double]): Double

    Return the mean of the probability density function for the given continuous element.

    Return the mean of the probability density function for the given continuous element.

    Definition Classes
    BaseProbQueryAlgorithm
  34. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  35. final def notify(): Unit

    Definition Classes
    AnyRef
  36. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  37. val parAlgs: ParSeq[ProbQuerySampler]

    A parallel collection of algorithms *

    A parallel collection of algorithms *

    Attributes
    protected
    Definition Classes
    ParSamplerParSamplingAlgorithm
  38. def probability[T](target: Reference[T], value: T): Double

    Return an estimate of the probability that the target produces the value.

    Return an estimate of the probability that the target produces the value. Throws NotATargetException if called on a target that is not in the list of targets of the algorithm. Throws AlgorithmInactiveException if the algorithm is inactive.

    Definition Classes
    BaseProbQueryAlgorithm
  39. def probability[T](target: Reference[T], predicate: (T) ⇒ Boolean): Double

    Return an estimate of the probability of the predicate under the marginal probability distribution of the target.

    Return an estimate of the probability of the predicate under the marginal probability distribution of the target. Throws NotATargetException if called on a target that is not in the list of targets of the algorithm. Throws AlgorithmInactiveException if the algorithm is inactive.

    Definition Classes
    BaseProbQueryAlgorithm
  40. val queryTargets: Seq[Reference[_]]

    The query targets are references in this case *

    The query targets are references in this case *

    Definition Classes
    ParSamplerBaseProbQueryAlgorithm
  41. def resume(): Unit

    Resume the computation of the algorithm, if it has been stopped.

    Resume the computation of the algorithm, if it has been stopped. Throws AlgorithmInactiveException if the algorithm is not active.

    Definition Classes
    Algorithm
  42. def start(): Unit

    Start the algorithm and make it active.

    Start the algorithm and make it active. After it returns, the algorithm must be ready to provide answers. Throws AlgorithmActiveException if the algorithm is already active.

    Definition Classes
    Algorithm
  43. def stop(): Unit

    Stop the algorithm from computing.

    Stop the algorithm from computing. The algorithm is still ready to provide answers after it returns. Throws AlgorithmInactiveException if the algorithm is not active.

    Definition Classes
    Algorithm
  44. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  45. def toString(): String

    Definition Classes
    AnyRef → Any
  46. def variance(target: Reference[Double]): Double

    Return the variance of the probability density function for the given continuous element.

    Return the variance of the probability density function for the given continuous element.

    Definition Classes
    BaseProbQueryAlgorithm
  47. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  48. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  49. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from ParSamplingAlgorithm

Inherited from Algorithm

Inherited from AnyRef

Inherited from Any

Ungrouped