unbbayes.evaluation
Class AEvaluation

java.lang.Object
  extended by unbbayes.evaluation.AEvaluation
All Implemented Interfaces:
IEvaluation, ILongTaskProgressObservable
Direct Known Subclasses:
ExactEvaluation, FastLWApproximateEvaluation, FastMCApproximateEvaluation, MemoryEfficientApproximateEvaluation

public abstract class AEvaluation
extends Object
implements IEvaluation


Field Summary
protected  int currentProgress
           
protected  String currentProgressStatus
           
protected  List<EvidenceEvaluation> evidenceEvaluationList
           
protected  TreeVariable[] evidenceNodeList
           
protected  float[][] evidenceSetCM
           
protected  float evidenceSetPCC
           
protected  int evidenceStatesProduct
           
protected  int[] factors
           
protected  int lastProgressUpdated
           
protected  int maxProgress
           
protected  ProbabilisticNetwork net
           
protected  int statesProduct
           
protected  TreeVariable[] targetNodeList
           
protected  int targetStatesProduct
           
static float UNSET_VALUE
           
 
Constructor Summary
AEvaluation()
           
 
Method Summary
protected abstract  float[][] computeCM(List<String> targetNodeNameList, List<String> evidenceNodeNameList)
           
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 evaluate(List<String> targetNodeNameList, List<String> evidenceNodeNameList, boolean onlyGCM)
           
 void evaluate(ProbabilisticNetwork net, List<String> targetNodeNameList, List<String> evidenceNodeNameList, boolean onlyGCM)
           
 void evaluate(String netFileName, List<String> targetNodeNameList, List<String> evidenceNodeNameList, boolean onlyGCM)
           
 List<EvidenceEvaluation> getBestIndividualCostRate()
           
 List<EvidenceEvaluation> getBestIndividualPCC()
           
 List<EvidenceEvaluation> getBestMarginalImprovement()
           
 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.
abstract  float getError()
           
 List<EvidenceEvaluation> getEvidenceEvaluationList()
           
protected  int getEvidenceLinearCoord(int[] multidimensionalCoord)
          Get the evidence linear coordinate from the multidimensional one.
 float[][] getEvidenceSetCM()
           
 float getEvidenceSetPCC()
           
protected  int getLinearCoord(int[] multidimensionalCoord)
          Get the linear coordinate from the multidimensional one.
 int getMaxProgress()
          The maximum number allowed for this long task progress.
protected  int[] getMultidimensionalCoord(int linearCoord)
          Get the multidimensional coordinate from the linear one.
 int getPercentageDone()
          Returns the percentage of the progress done so far.
protected  void init(List<String> targetNodeNameList, List<String> evidenceNodeNameList)
          It creates the target and evidence node list of TreeVariable and the product of the target, evidence and total states.
protected  void loadNetwork(String netFileName)
           
 void notityObservers(LongTaskProgressChangedEvent event)
           
 void registerObserver(ILongTaskProgressObserver observer)
           
 void removeObserver(ILongTaskProgressObserver observer)
           
protected static void show(float[][] a)
           
protected  void updateProgress(int progress)
           
protected  void updateProgress(int progress, String progressStatus)
          As this progress is an approximation, it is going to be updated until it reaches 98%.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

net

protected ProbabilisticNetwork net

targetStatesProduct

protected int targetStatesProduct

targetNodeList

protected TreeVariable[] targetNodeList

UNSET_VALUE

public static final float UNSET_VALUE
See Also:
Constant Field Values

evidenceNodeList

protected TreeVariable[] evidenceNodeList

statesProduct

protected int statesProduct

evidenceStatesProduct

protected int evidenceStatesProduct

evidenceSetCM

protected float[][] evidenceSetCM

evidenceSetPCC

protected float evidenceSetPCC

evidenceEvaluationList

protected List<EvidenceEvaluation> evidenceEvaluationList

factors

protected int[] factors

maxProgress

protected int maxProgress

currentProgress

protected int currentProgress

currentProgressStatus

protected String currentProgressStatus

lastProgressUpdated

protected int lastProgressUpdated
Constructor Detail

AEvaluation

public AEvaluation()
Method Detail

getEvidenceEvaluationList

public List<EvidenceEvaluation> getEvidenceEvaluationList()
Specified by:
getEvidenceEvaluationList in interface IEvaluation

getEvidenceSetCM

public float[][] getEvidenceSetCM()
Specified by:
getEvidenceSetCM in interface IEvaluation

getError

public abstract float getError()
Specified by:
getError in interface IEvaluation

getEvidenceSetPCC

public float getEvidenceSetPCC()
                        throws EvaluationException
Specified by:
getEvidenceSetPCC in interface IEvaluation
Throws:
EvaluationException

getBestIndividualPCC

public List<EvidenceEvaluation> getBestIndividualPCC()
                                              throws EvaluationException
Specified by:
getBestIndividualPCC in interface IEvaluation
Throws:
EvaluationException

getBestIndividualCostRate

public List<EvidenceEvaluation> getBestIndividualCostRate()
                                                   throws EvaluationException
Specified by:
getBestIndividualCostRate in interface IEvaluation
Throws:
EvaluationException

getBestMarginalImprovement

public List<EvidenceEvaluation> getBestMarginalImprovement()
                                                    throws EvaluationException
Specified by:
getBestMarginalImprovement in interface IEvaluation
Throws:
EvaluationException

evaluate

public void evaluate(String netFileName,
                     List<String> targetNodeNameList,
                     List<String> evidenceNodeNameList,
                     boolean onlyGCM)
              throws LoadException,
                     IOException,
                     javax.xml.bind.JAXBException,
                     EvaluationException
Specified by:
evaluate in interface IEvaluation
Throws:
LoadException
IOException
javax.xml.bind.JAXBException
EvaluationException

evaluate

public void evaluate(ProbabilisticNetwork net,
                     List<String> targetNodeNameList,
                     List<String> evidenceNodeNameList,
                     boolean onlyGCM)
              throws EvaluationException
Specified by:
evaluate in interface IEvaluation
Throws:
EvaluationException

evaluate

protected void evaluate(List<String> targetNodeNameList,
                        List<String> evidenceNodeNameList,
                        boolean onlyGCM)
                 throws EvaluationException
Throws:
EvaluationException

computeCM

protected abstract float[][] computeCM(List<String> targetNodeNameList,
                                       List<String> evidenceNodeNameList)
                                throws EvaluationException
Throws:
EvaluationException

computeFactors

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). FactorForNode[i + 1] = ProductOf(NumberOfStates[i]), for all previous nodes (i).


getLinearCoord

protected final int getLinearCoord(int[] multidimensionalCoord)
Get the linear coordinate from the multidimensional one. LinearCoord = SumOf(StateOf[i] * FactorOf[i]), for all possible nodes (i).

Parameters:
multidimensionalCoord - Multidimensional coordinate (represented by the state for each node).
Returns:
The corresponding linear coordinate.

getEvidenceLinearCoord

protected final int getEvidenceLinearCoord(int[] multidimensionalCoord)
Get the evidence linear coordinate from the multidimensional one. It basically ignores the target node (for now just one). LinearCoord = SumOf(StateOf[i] * FactorOf[i]), for all possible evidence nodes (i).

Parameters:
multidimensionalCoord - Multidimensional coordinate (represented by the state for each node).
Returns:
The corresponding evidence linear coordinate.

getMultidimensionalCoord

protected final int[] getMultidimensionalCoord(int linearCoord)
Get the multidimensional coordinate from the linear one.

Parameters:
linearCoord - The linear coordinate.
Returns:
The corresponding multidimensional coordinate.

init

protected void init(List<String> targetNodeNameList,
                    List<String> evidenceNodeNameList)
It creates the target and evidence node list of TreeVariable and the product of the target, evidence and total states.

Parameters:
targetNodeNameList - List of the target nodes name.
evidenceNodeNameList -

loadNetwork

protected void loadNetwork(String netFileName)
                    throws LoadException,
                           IOException
Throws:
LoadException
IOException

show

protected static void show(float[][] a)

registerObserver

public void registerObserver(ILongTaskProgressObserver observer)
Specified by:
registerObserver in interface ILongTaskProgressObservable

removeObserver

public void removeObserver(ILongTaskProgressObserver observer)
Specified by:
removeObserver in interface ILongTaskProgressObservable

notityObservers

public void notityObservers(LongTaskProgressChangedEvent event)
Specified by:
notityObservers in interface ILongTaskProgressObservable

getMaxProgress

public int getMaxProgress()
Description copied from interface: ILongTaskProgressObservable
The maximum number allowed for this long task progress. It represents 100%.

Specified by:
getMaxProgress in interface ILongTaskProgressObservable
Returns:
the maximum number allowed for this long task progress. It represents 100%.

getCurrentProgress

public int getCurrentProgress()
Description copied from interface: ILongTaskProgressObservable
The current number of this long task progress. It represents a percentage.

Specified by:
getCurrentProgress in interface ILongTaskProgressObservable
Returns:
the current number of this long task progress. It represents a percentage.

getPercentageDone

public int getPercentageDone()
Description copied from interface: ILongTaskProgressObservable
Returns the percentage of the progress done so far. It should be Math.round((float)currentProgress / maxProgress * 10000), a number between 0 and 10000.

Specified by:
getPercentageDone in interface ILongTaskProgressObservable
Returns:
the percentage of the progress done so far.

getCurrentProgressStatus

public String getCurrentProgressStatus()
Description copied from interface: ILongTaskProgressObservable
Returns a message with a description of the current status of the long task progress.

Specified by:
getCurrentProgressStatus in interface ILongTaskProgressObservable
Returns:
a message with a description of the current status of the long task progress.

updateProgress

protected void updateProgress(int progress,
                              String progressStatus)
As this progress is an approximation, it is going to be updated until it reaches 98%. Then the progress is not going to be updated anymore to avoid getting to 100% before the task is done.


updateProgress

protected void updateProgress(int progress)


Copyright © 2001-2010 University of Brasilia - UnB. All Rights Reserved.