gov.sandia.cognition.learning.function.cost
Class ParallelNegativeLogLikelihood<DataType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.function.cost.AbstractCostFunction<ComputableDistribution<DataType>,Collection<? extends DataType>>
          extended by gov.sandia.cognition.learning.function.cost.NegativeLogLikelihood<DataType>
              extended by gov.sandia.cognition.learning.function.cost.ParallelNegativeLogLikelihood<DataType>
Type Parameters:
DataType - Type of data generated by the Distribution
All Implemented Interfaces:
ParallelAlgorithm, Evaluator<ComputableDistribution<DataType>,Double>, CostFunction<ComputableDistribution<DataType>,Collection<? extends DataType>>, CloneableSerializable, Serializable, Cloneable

public class ParallelNegativeLogLikelihood<DataType>
extends NegativeLogLikelihood<DataType>
implements ParallelAlgorithm

Parallel implementation of the NegativeLogLikleihood cost function

See Also:
Serialized Form

Nested Class Summary
protected static class ParallelNegativeLogLikelihood.NegativeLogLikelihoodTask<DataType>
          Task for computing partial log likelihoods
 
Field Summary
protected  ArrayList<ParallelNegativeLogLikelihood.NegativeLogLikelihoodTask<DataType>> tasks
          Tasks to compute partial log likelihoods
protected  ThreadPoolExecutor threadPool
          Thread pool for executing the tasks.
 
Fields inherited from class gov.sandia.cognition.learning.function.cost.AbstractCostFunction
costParameters
 
Constructor Summary
ParallelNegativeLogLikelihood()
          Default constructor
ParallelNegativeLogLikelihood(Collection<? extends DataType> costParameters)
          Creates a new instance of ParallelNegativeLogLikelihood
 
Method Summary
 Double evaluate(ComputableDistribution<DataType> target)
          Computes the cost of the given target.
 int getNumThreads()
          Gets the number of threads in the thread pool.
 ThreadPoolExecutor getThreadPool()
          Gets the thread pool for the algorithm to use.
 void setThreadPool(ThreadPoolExecutor threadPool)
          Sets the thread pool for the algorithm to use.
 
Methods inherited from class gov.sandia.cognition.learning.function.cost.NegativeLogLikelihood
evaluate
 
Methods inherited from class gov.sandia.cognition.learning.function.cost.AbstractCostFunction
clone, getCostParameters, setCostParameters
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.util.CloneableSerializable
clone
 

Field Detail

threadPool

protected transient ThreadPoolExecutor threadPool
Thread pool for executing the tasks.


tasks

protected transient ArrayList<ParallelNegativeLogLikelihood.NegativeLogLikelihoodTask<DataType>> tasks
Tasks to compute partial log likelihoods

Constructor Detail

ParallelNegativeLogLikelihood

public ParallelNegativeLogLikelihood()
Default constructor


ParallelNegativeLogLikelihood

public ParallelNegativeLogLikelihood(Collection<? extends DataType> costParameters)
Creates a new instance of ParallelNegativeLogLikelihood

Parameters:
costParameters - Data generated by the target distribution
Method Detail

evaluate

public Double evaluate(ComputableDistribution<DataType> target)
Description copied from interface: CostFunction
Computes the cost of the given target.

Specified by:
evaluate in interface Evaluator<ComputableDistribution<DataType>,Double>
Specified by:
evaluate in interface CostFunction<ComputableDistribution<DataType>,Collection<? extends DataType>>
Overrides:
evaluate in class NegativeLogLikelihood<DataType>
Parameters:
target - The object to evaluate.
Returns:
The cost of the given object.

getThreadPool

public ThreadPoolExecutor getThreadPool()
Description copied from interface: ParallelAlgorithm
Gets the thread pool for the algorithm to use.

Specified by:
getThreadPool in interface ParallelAlgorithm
Returns:
Thread pool used for parallelization.

setThreadPool

public void setThreadPool(ThreadPoolExecutor threadPool)
Description copied from interface: ParallelAlgorithm
Sets the thread pool for the algorithm to use.

Specified by:
setThreadPool in interface ParallelAlgorithm
Parameters:
threadPool - Thread pool used for parallelization.

getNumThreads

public int getNumThreads()
Description copied from interface: ParallelAlgorithm
Gets the number of threads in the thread pool.

Specified by:
getNumThreads in interface ParallelAlgorithm
Returns:
Number of threads in the thread pool