Class

com.cra.figaro.algorithm.sampling.parallel

ParSampler

Related Doc: package parallel

Permalink

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
Visibility
  1. Public
  2. All

Instance Constructors

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

    Permalink

Type Members

  1. class NotATargetException[T] extends AlgorithmException

    Permalink
    Definition Classes
    BaseProbQueryAlgorithm

Value Members

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

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  4. var active: Boolean

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

    Permalink
    Definition Classes
    Any
  6. def cleanUp(): Unit

    Permalink

    Calls cleanUp() on all algorithms.

    Calls cleanUp() on all algorithms.

    Definition Classes
    ParSamplingAlgorithmAlgorithm
  7. def clone(): AnyRef

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

    Permalink

    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

    Permalink

    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

    Permalink

    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)]

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

    Permalink

    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)]

    Permalink

    Methods from BaseProbQueryAlgorithm *

    Methods from BaseProbQueryAlgorithm *

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

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

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

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

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

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

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

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

    Permalink

    Get an element from a reference *

    Get an element from a reference *

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

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

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

    Permalink

    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 expectation[T](target: Reference[T], function: (T) ⇒ Double): Double

    Permalink

    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
  26. def finalize(): Unit

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

    Permalink
    Definition Classes
    AnyRef → Any
  28. def getTotalWeight: Double

    Permalink

    Log sum of total weights of individual algorithms *

    Log sum of total weights of individual algorithms *

    Definition Classes
    ParSamplerBaseProbQuerySampler
  29. def hashCode(): Int

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

    Permalink

    Calls initialize() on all algorithms.

    Calls initialize() on all algorithms.

    Definition Classes
    ParSamplingAlgorithmAlgorithm
  31. def isActive: Boolean

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

    Permalink
    Definition Classes
    Any
  33. def kill(): Unit

    Permalink

    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
  34. def mean(target: Reference[Double]): Double

    Permalink

    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
  35. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  36. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  37. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  38. val parAlgs: ParSeq[ProbQuerySampler]

    Permalink

    A parallel collection of algorithms *

    A parallel collection of algorithms *

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

    Permalink

    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
  40. def probability[T](target: Reference[T])(predicate: (T) ⇒ Boolean, c: Any = DummyImplicit): Double

    Permalink

    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
  41. def probability[T](target: Reference[T], predicate: (T) ⇒ Boolean): Double

    Permalink

    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
  42. val queryTargets: Seq[Reference[_]]

    Permalink

    The query targets are references in this case *

    The query targets are references in this case *

    Definition Classes
    ParSamplerBaseProbQueryAlgorithm
  43. def resume(): Unit

    Permalink

    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
  44. def start(): Unit

    Permalink

    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
  45. def stop(): Unit

    Permalink

    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
  46. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  47. def toString(): String

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

    Permalink

    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
  49. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from ParSamplingAlgorithm

Inherited from Algorithm

Inherited from AnyRef

Inherited from Any

Ungrouped