|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectunbbayes.simulation.montecarlo.sampling.AMonteCarloSampling
public abstract class AMonteCarloSampling
Field Summary | |
---|---|
protected int |
currentProgress
|
protected String |
currentProgressStatus
|
protected int[] |
factors
|
protected int |
maxProgress
|
protected int |
nTrials
|
protected ProbabilisticNetwork |
pn
|
protected Map<Integer,Integer> |
sampledStatesMap
|
protected byte[][] |
sampledStatesMatrix
|
protected List<Node> |
samplingNodeOrderQueue
|
protected int[] |
timesSampled
|
Constructor Summary | |
---|---|
AMonteCarloSampling()
|
Method Summary | |
---|---|
protected void |
addToSamplingOrderQueue(ArrayList<Node> children,
boolean[] nodeAddedList)
Take the children of a node that have already been added to the queue. |
protected void |
computeFactors()
Calculate the factors necessary to transform the linear coordinate into a multidimensional one (which is the the state for each possible node - target and evidence). |
protected void |
createSamplingOrderQueue()
Creates the queue of the nodes that are going to be analyzed. |
protected double[][] |
getCumulativeDistributionFunction(double[] pmf)
Creates the cumulative distribution function (cdf) based on the node RV's pmf. |
int |
getCurrentProgress()
The current number of this long task progress. |
String |
getCurrentProgressStatus()
Returns a message with a description of the current status of the long task progress. |
protected Integer |
getIndexInQueue(Node node)
Retrieves the node's index in the queue. |
int |
getLinearCoord(int[] multidimensionalCoord)
Get the linear coordinate from the multidimensional one. |
int |
getMaxProgress()
The maximum number allowed for this long task progress. |
byte[] |
getMultidimensionalCoord(int linearCoord)
Get the multidimensional coordinate from the linear one. |
protected List<Integer> |
getParentsIndexesInQueue(ProbabilisticNode node)
Return the indexes (sampling order) in the queue for the parents of a given node. |
int |
getPercentageDone()
Returns the percentage of the progress done so far. |
protected double[] |
getProbabilityMassFunction(int[] sampledStates,
List<Integer> parentsIndexes,
ProbabilisticNode node)
Creates the probability mass function based on the states sampled for the parents. |
abstract byte[][] |
getSampledStatesCompactMatrix()
Returns the generated compact sample matrix. |
abstract Map<Integer,Integer> |
getSampledStatesMap()
Returns the generated sample map, with key = linear coord (representing the sates sampled) and value = number of times this key was sampled. |
abstract byte[][] |
getSampledStatesMatrix()
Returns the generated sample matrix. |
List<Node> |
getSamplingNodeOrderQueue()
Return the order the nodes are in the sampled matrix. |
protected byte |
getState(double[] pmf)
Uses the pmf to retrieve the cdf to choose a state from a random generated number (between 0 and 1). |
abstract int[] |
getStatesSetTimesSampled()
The number of times the ith set of states was sampled. |
protected void |
initSamplingOrderQueue(boolean[] nodeAddedList)
Initializes the queue with the nodes that are root. |
void |
notityObservers(LongTaskProgressChangedEvent event)
|
void |
registerObserver(ILongTaskProgressObserver observer)
|
void |
removeObserver(ILongTaskProgressObserver observer)
|
abstract void |
start(ProbabilisticNetwork pn,
int nTrials)
Generates the MC sample with the given size for the given probabilistic network. |
protected void |
updateProgress(int progress)
|
protected void |
updateProgress(int progress,
String progressStatus)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int maxProgress
protected int currentProgress
protected String currentProgressStatus
protected ProbabilisticNetwork pn
protected int nTrials
protected List<Node> samplingNodeOrderQueue
protected Map<Integer,Integer> sampledStatesMap
protected byte[][] sampledStatesMatrix
protected int[] timesSampled
protected int[] factors
Constructor Detail |
---|
public AMonteCarloSampling()
Method Detail |
---|
public void registerObserver(ILongTaskProgressObserver observer)
registerObserver
in interface ILongTaskProgressObservable
public void removeObserver(ILongTaskProgressObserver observer)
removeObserver
in interface ILongTaskProgressObservable
public void notityObservers(LongTaskProgressChangedEvent event)
notityObservers
in interface ILongTaskProgressObservable
public int getMaxProgress()
ILongTaskProgressObservable
getMaxProgress
in interface ILongTaskProgressObservable
public int getCurrentProgress()
ILongTaskProgressObservable
getCurrentProgress
in interface ILongTaskProgressObservable
public int getPercentageDone()
ILongTaskProgressObservable
getPercentageDone
in interface ILongTaskProgressObservable
public String getCurrentProgressStatus()
ILongTaskProgressObservable
getCurrentProgressStatus
in interface ILongTaskProgressObservable
protected void updateProgress(int progress, String progressStatus)
protected void updateProgress(int progress)
public abstract byte[][] getSampledStatesMatrix()
getSampledStatesMatrix
in interface IMonteCarloSampling
public abstract byte[][] getSampledStatesCompactMatrix()
getStatesSetTimesSampled()
.
getSampledStatesCompactMatrix
in interface IMonteCarloSampling
public abstract int[] getStatesSetTimesSampled()
getStatesSetTimesSampled
in interface IMonteCarloSampling
public abstract Map<Integer,Integer> getSampledStatesMap()
getSampledStatesMap
in interface IMonteCarloSampling
public abstract void start(ProbabilisticNetwork pn, int nTrials)
start
in interface IMonteCarloSampling
pn
- Probabilistic network that will be used for sampling.nTrials
- Number of trials to generate.public List<Node> getSamplingNodeOrderQueue()
getSamplingNodeOrderQueue
in interface IMonteCarloSampling
protected void createSamplingOrderQueue()
protected void initSamplingOrderQueue(boolean[] nodeAddedList)
nodeAddedList
- Keeps track of the nodes that have already been added to the queue (nodeAddedList[nodeIndex]=true).protected void addToSamplingOrderQueue(ArrayList<Node> children, boolean[] nodeAddedList)
children
- Children of a node that is already in the queue.nodeAddedList
- Nodes that have already been added to the queue.protected List<Integer> getParentsIndexesInQueue(ProbabilisticNode node)
node
- The node to retrieve the parents for finding the indexes.
protected Integer getIndexInQueue(Node node)
node
-
protected byte getState(double[] pmf)
pmf
- The probability mass function for the node RV that we want to sample the state for.
protected double[][] getCumulativeDistributionFunction(double[] pmf)
pmf
- The probability mass function of the RV to calculate the cdf.
protected double[] getProbabilityMassFunction(int[] sampledStates, List<Integer> parentsIndexes, ProbabilisticNode node)
sampledStates
- The states (sampledStates[nodeIndex]) sampled for the nodes (nodeIndex).parentsIndexes
- The nodeIndex for each parent.node
- The node/RV to calculate the pmf.
protected void computeFactors()
public final int getLinearCoord(int[] multidimensionalCoord)
getLinearCoord
in interface IMonteCarloSampling
multidimensionalCoord
- Multidimensional coordinate (represented by the state for
each node).
public final byte[] getMultidimensionalCoord(int linearCoord)
getMultidimensionalCoord
in interface IMonteCarloSampling
linearCoord
- The linear coordinate.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |