org.processmining.models.heuristics.impl
Class HeuristicsNetImpl

java.lang.Object
  extended by org.processmining.models.heuristics.impl.HeuristicsNetImpl
All Implemented Interfaces:
java.lang.Comparable<HeuristicsNet>, HeuristicsNet
Direct Known Subclasses:
SimpleHeuristicsNet

public class HeuristicsNetImpl
extends java.lang.Object
implements java.lang.Comparable<HeuristicsNet>, HeuristicsNet

Implements the HeuristicsNet objects that are used by the Genetic Miner algorithm.

Author:
Ana Karla Alves de Medeiros

Field Summary
static java.lang.String AND_SEPARATOR
          Constant used to build the String representation of a HeuristicsNetImpl object.
static java.lang.String EMPTY_SET
          Constant used to build the String representation of a HeuristicsNetImpl object.
static java.lang.String EVENT_SEPARATOR
          Constant used to build the String representation of a HeuristicsNetImpl object.
static java.lang.String FIELD_SEPARATOR
          Constant used to build the String representation of a HeuristicsNetImpl object.
static java.lang.String INPUT_SETS_HEADER
          Constant used to build the String representation of a HeuristicsNetImpl object.
static java.lang.String OR_SEPARATOR
          Constant used to build the String representation of a HeuristicsNetImpl object.
static java.lang.String OUTPUT_SETS_HEADER
          Constant used to build the String representation of a HeuristicsNetImpl object.
static java.lang.String SETS_SEPARATOR
          Constant used to build the String representation of a HeuristicsNetImpl object.
static java.lang.String WME_HEADER
          Constant used to build the String representation of a HeuristicsNetImpl object.
static char WME_NAME_DELIMITER
          Constant used to build the String representation of a HeuristicsNetImpl object.
 
Constructor Summary
HeuristicsNetImpl(ActivitiesMappingStructures activitiesMappingStructures)
          Builds a HeuristicsNetImpl objects based on a given ActivitiesMapping object.
 
Method Summary
protected  HeuristicsNet clone()
          Returns a deep cloning of the current HeuristicsNet.
 int compareTo(HeuristicsNet otherHeuristicsNet)
          Compares other HeuristicsNet object with this HeuristicsNet object.
 HeuristicsNet copy()
          Makes a copy (deep clone) of this HeuristicsNet object.
 void disconnectArcsUsedBelowThreshold(double threshold)
          Removes from this HeuristicsNet object all the arcs that have not been used up to a given threshold.
 void disconnectUnusedElements()
          Disconnects in this HeuristicsNet object the activities and arcs that are not used during the parsing of an event log.
 boolean equals(java.lang.Object other)
          Checks if a given HeuristicsNet object is equal to this HeuristicsNet object.
 int[] getActivitiesActualFiring()
          Retrieves the variable that keeps track of how often activities have been executed (or fired) during the parsing of a log.
 int[] getActivitiesActualFiring(java.util.Map<java.lang.Integer,java.lang.Integer> oldNewIndexMap, int newSize)
           
 ActivitiesMappingStructures getActivitiesMappingStructures()
          Retrieves the current ActivitiesMappingStructures that is used by this HeuristicsNet object.
 HNSubSet getAllElementsInputSet(int index)
          Retrieves a set containing all the input activities of a given activity.
 HNSubSet getAllElementsOutputSet(int index)
          Retrieves a set containing all the output activities of a given activity.
 cern.colt.matrix.DoubleMatrix2D getArcUsage()
          Retrieves the variable that keeps track of how often arcs have been used during the parsing of a log.
 cern.colt.matrix.DoubleMatrix2D getArcUsage(java.util.Map<java.lang.Integer,java.lang.Integer> oldNewIndexMap, int newSize)
           
static int[] getElements(HNSet set)
          Returns an array contains all the activities that are in the subset of the HNSet structure.
 HNSubSet getEndActivities()
          Retrieves the current set of end activities for this HeuristicsNet object.
 HNSubSet getEndActivities(java.util.Map<java.lang.Integer,java.lang.Integer> oldNewIndexMap)
           
 double getFitness()
          Retrieves the current fitness of this HeuristicsNet object.
 HNSet getInputSet(int index)
          Retrieves the input set of a given activity in this HeuristicsNet object.
 HNSet[] getInputSets()
          Retrieves the array that contains all the input sets of the activities for this HeuristicsNet object.
 HNSet getInputSetsWithElement(int index, int element)
          Retrieves subsets from an input set of an activity.
 HNSet getOutputSet(int index)
          Retrieves the output set of a given activity in this HeuristicsNet object.
 HNSet[] getOutputSets()
          Retrieves the array that contains all the output sets of the activities for this HeuristicsNet object.
 HNSet getOutputSetsWithElement(int index, int element)
          Retrieves subsets from an output set of an activity.
 HNSubSet getStartActivities()
          Retrieves the current set of start activities for this HeuristicsNet object.
 HNSubSet getStartActivities(java.util.Map<java.lang.Integer,java.lang.Integer> oldNewIndexMap)
           
 int hashCode()
          Computes the hashCode for this HeuristicsNet.
 void increaseArcUsage(int activity, HNSubSet usedInputActivities, int amount)
          Increases arc usage in this HeuristicsNet object.
 void increaseElementActualFiring(int activity, int amount)
          Increases by the specified amount the number of times an activity has fired.
 void resetActivitiesActualFiring()
          Resets the variable that keeps track of activities that are actually fired during the parsing of a log.
 void resetArcUsage()
          Resets the variable that keeps track of how often arcs are actually used during the parsing of a log by this HeuristicsNet.
In this case, all arc usages are set to 0.
 boolean setActivitiesActualFiring(int[] newActivitiesActualFiring)
          Sets the variable that keeps track of how often activities have been executed during the parsing of a log by this HeuristicsNet.
 boolean setActivitiesMappingStructures(ActivitiesMappingStructures newActivitiesMappingStructures)
          Replaces the current ActivitiesMappingStructures that is used by this HeuristicsNet object.
 boolean setArcUsage(cern.colt.matrix.DoubleMatrix2D newArcUsage)
          Sets the variable that keeps track of how often arcs are actually used during the parsing of a log by this HeuristicsNet.
 void setEndActivities(HNSubSet activities)
          Sets the end activities of this HeuristicsNet object.
 void setFitness(double newFitnessValue)
          Sets the fitness value of this HeuristicsNet object.
 boolean setInputSet(int index, HNSet sets)
          Sets the input sets of a given activity in this HeuristicsNet object.
 boolean setOutputSet(int index, HNSet sets)
          Sets the output sets of a given activity in this HeuristicsNet object.
 void setStartActivities(HNSubSet activities)
          Sets the start activities of this HeuristicsNet object.
 int size()
          Retrieves the number of activities in this HeuristicsNet object.
 java.lang.String toString()
          Creates a string representation of this HeuristicsNet object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

WME_HEADER

public static final java.lang.String WME_HEADER
Constant used to build the String representation of a HeuristicsNetImpl object.

See Also:
Constant Field Values

WME_NAME_DELIMITER

public static final char WME_NAME_DELIMITER
Constant used to build the String representation of a HeuristicsNetImpl object.

See Also:
Constant Field Values

INPUT_SETS_HEADER

public static final java.lang.String INPUT_SETS_HEADER
Constant used to build the String representation of a HeuristicsNetImpl object.

See Also:
Constant Field Values

OUTPUT_SETS_HEADER

public static final java.lang.String OUTPUT_SETS_HEADER
Constant used to build the String representation of a HeuristicsNetImpl object.

See Also:
Constant Field Values

EVENT_SEPARATOR

public static final java.lang.String EVENT_SEPARATOR
Constant used to build the String representation of a HeuristicsNetImpl object.

See Also:
Constant Field Values

EMPTY_SET

public static final java.lang.String EMPTY_SET
Constant used to build the String representation of a HeuristicsNetImpl object.

See Also:
Constant Field Values

AND_SEPARATOR

public static final java.lang.String AND_SEPARATOR
Constant used to build the String representation of a HeuristicsNetImpl object.

See Also:
Constant Field Values

OR_SEPARATOR

public static final java.lang.String OR_SEPARATOR
Constant used to build the String representation of a HeuristicsNetImpl object.

See Also:
Constant Field Values

SETS_SEPARATOR

public static final java.lang.String SETS_SEPARATOR
Constant used to build the String representation of a HeuristicsNetImpl object.

See Also:
Constant Field Values

FIELD_SEPARATOR

public static final java.lang.String FIELD_SEPARATOR
Constant used to build the String representation of a HeuristicsNetImpl object.

See Also:
Constant Field Values
Constructor Detail

HeuristicsNetImpl

public HeuristicsNetImpl(ActivitiesMappingStructures activitiesMappingStructures)
Builds a HeuristicsNetImpl objects based on a given ActivitiesMapping object.

Parameters:
activitiesMappingStructures - object with the correct number of activities per XEventClass for a given log.
Method Detail

resetActivitiesActualFiring

public void resetActivitiesActualFiring()
Description copied from interface: HeuristicsNet
Resets the variable that keeps track of activities that are actually fired during the parsing of a log. The activities that do not fire are not shown in the graphical representation of the HeuristicsNet.
In this case, all activities have their counters set to 0.

Specified by:
resetActivitiesActualFiring in interface HeuristicsNet

resetArcUsage

public void resetArcUsage()
Description copied from interface: HeuristicsNet
Resets the variable that keeps track of how often arcs are actually used during the parsing of a log by this HeuristicsNet.
In this case, all arc usages are set to 0.

Specified by:
resetArcUsage in interface HeuristicsNet

getActivitiesActualFiring

public int[] getActivitiesActualFiring()
Description copied from interface: HeuristicsNet
Retrieves the variable that keeps track of how often activities have been executed (or fired) during the parsing of a log.

Specified by:
getActivitiesActualFiring in interface HeuristicsNet
Returns:
An array containing the number of times that a given activity has fired.

getActivitiesActualFiring

public int[] getActivitiesActualFiring(java.util.Map<java.lang.Integer,java.lang.Integer> oldNewIndexMap,
                                       int newSize)
Specified by:
getActivitiesActualFiring in interface HeuristicsNet

getArcUsage

public cern.colt.matrix.DoubleMatrix2D getArcUsage()
Description copied from interface: HeuristicsNet
Retrieves the variable that keeps track of how often arcs have been used during the parsing of a log.

Specified by:
getArcUsage in interface HeuristicsNet
Returns:
A matrix containing the number of times that a given arc has been used.

getArcUsage

public cern.colt.matrix.DoubleMatrix2D getArcUsage(java.util.Map<java.lang.Integer,java.lang.Integer> oldNewIndexMap,
                                                   int newSize)
Specified by:
getArcUsage in interface HeuristicsNet

setActivitiesActualFiring

public boolean setActivitiesActualFiring(int[] newActivitiesActualFiring)
Description copied from interface: HeuristicsNet
Sets the variable that keeps track of how often activities have been executed during the parsing of a log by this HeuristicsNet.

Specified by:
setActivitiesActualFiring in interface HeuristicsNet
Parameters:
newActivitiesActualFiring - array containing the new values for the activities firing. This variable should have the same length of the current variable used to keep track of the activities firing.
Returns:
true if the variable has been successfully updated, false otherwise.

setArcUsage

public boolean setArcUsage(cern.colt.matrix.DoubleMatrix2D newArcUsage)
Description copied from interface: HeuristicsNet
Sets the variable that keeps track of how often arcs are actually used during the parsing of a log by this HeuristicsNet.

Specified by:
setArcUsage in interface HeuristicsNet
Parameters:
newArcUsage - matrix containing the new arc usage values for the activities. This variable should have the same dimension that the current matrix has.
Returns:
true if the variable has been successfully updated, false otherwise.

increaseElementActualFiring

public void increaseElementActualFiring(int activity,
                                        int amount)
Description copied from interface: HeuristicsNet
Increases by the specified amount the number of times an activity has fired.

Specified by:
increaseElementActualFiring in interface HeuristicsNet
Parameters:
activity - activity to have the number of firing increased.
amount - value to be added to the current amount of time the activity has fired.

increaseArcUsage

public void increaseArcUsage(int activity,
                             HNSubSet usedInputActivities,
                             int amount)
Description copied from interface: HeuristicsNet
Increases arc usage in this HeuristicsNet object.

Specified by:
increaseArcUsage in interface HeuristicsNet
Parameters:
activity - index of the activity to which output arcs should be increased.
usedInputActivities - HNSubSet with the activities to which these output arcs connect to. In other words, set containing the output activities.
amount - value by which each output arc usage should be increased.

getStartActivities

public HNSubSet getStartActivities()
Description copied from interface: HeuristicsNet
Retrieves the current set of start activities for this HeuristicsNet object.

Specified by:
getStartActivities in interface HeuristicsNet
Returns:
HNSubSet with the start activities.

getStartActivities

public HNSubSet getStartActivities(java.util.Map<java.lang.Integer,java.lang.Integer> oldNewIndexMap)
Specified by:
getStartActivities in interface HeuristicsNet

getEndActivities

public HNSubSet getEndActivities()
Description copied from interface: HeuristicsNet
Retrieves the current set of end activities for this HeuristicsNet object.

Specified by:
getEndActivities in interface HeuristicsNet
Returns:
HNSubSet with the end activities.

getEndActivities

public HNSubSet getEndActivities(java.util.Map<java.lang.Integer,java.lang.Integer> oldNewIndexMap)
Specified by:
getEndActivities in interface HeuristicsNet

setStartActivities

public void setStartActivities(HNSubSet activities)
Description copied from interface: HeuristicsNet
Sets the start activities of this HeuristicsNet object.

Specified by:
setStartActivities in interface HeuristicsNet
Parameters:
activities - HNSubSet with start activities.

setEndActivities

public void setEndActivities(HNSubSet activities)
Description copied from interface: HeuristicsNet
Sets the end activities of this HeuristicsNet object.

Specified by:
setEndActivities in interface HeuristicsNet
Parameters:
activities - HNSubSet with end activities.

size

public int size()
Description copied from interface: HeuristicsNet
Retrieves the number of activities in this HeuristicsNet object.

Specified by:
size in interface HeuristicsNet
Returns:
number of activities.

setFitness

public void setFitness(double newFitnessValue)
Description copied from interface: HeuristicsNet
Sets the fitness value of this HeuristicsNet object.

Specified by:
setFitness in interface HeuristicsNet
Parameters:
newFitnessValue - double representing the new fitness value.

getActivitiesMappingStructures

public ActivitiesMappingStructures getActivitiesMappingStructures()
Description copied from interface: HeuristicsNet
Retrieves the current ActivitiesMappingStructures that is used by this HeuristicsNet object.

Specified by:
getActivitiesMappingStructures in interface HeuristicsNet
Returns:
ActivitiesMappingStructures currently used by this HeuristicsNet object.

setActivitiesMappingStructures

public boolean setActivitiesMappingStructures(ActivitiesMappingStructures newActivitiesMappingStructures)
Description copied from interface: HeuristicsNet
Replaces the current ActivitiesMappingStructures that is used by this HeuristicsNet object. Furthermore, all other related structured of the HeuristicsNet object are also updated!

Specified by:
setActivitiesMappingStructures in interface HeuristicsNet
Returns:
true if the variable has been successfully updated, false otherwise.

getFitness

public double getFitness()
Description copied from interface: HeuristicsNet
Retrieves the current fitness of this HeuristicsNet object.

Specified by:
getFitness in interface HeuristicsNet
Returns:
double value representing the fitness.

setInputSet

public boolean setInputSet(int index,
                           HNSet sets)
Description copied from interface: HeuristicsNet
Sets the input sets of a given activity in this HeuristicsNet object.

Specified by:
setInputSet in interface HeuristicsNet
Parameters:
index - activity index.
sets - new input set.
Returns:
true if the update was successful, false otherwise.

setOutputSet

public boolean setOutputSet(int index,
                            HNSet sets)
Description copied from interface: HeuristicsNet
Sets the output sets of a given activity in this HeuristicsNet object.

Specified by:
setOutputSet in interface HeuristicsNet
Parameters:
index - activity index.
sets - new output set.
Returns:
true if the update was successful, false otherwise.

getInputSets

public HNSet[] getInputSets()
Description copied from interface: HeuristicsNet
Retrieves the array that contains all the input sets of the activities for this HeuristicsNet object.

Specified by:
getInputSets in interface HeuristicsNet
Returns:
array with activities' input sets.

getOutputSets

public HNSet[] getOutputSets()
Description copied from interface: HeuristicsNet
Retrieves the array that contains all the output sets of the activities for this HeuristicsNet object.

Specified by:
getOutputSets in interface HeuristicsNet
Returns:
array with activities' output sets.

getInputSet

public HNSet getInputSet(int index)
Description copied from interface: HeuristicsNet
Retrieves the input set of a given activity in this HeuristicsNet object.

Specified by:
getInputSet in interface HeuristicsNet
Parameters:
index - activity index.
Returns:
input set of this activity.

getOutputSet

public HNSet getOutputSet(int index)
Description copied from interface: HeuristicsNet
Retrieves the output set of a given activity in this HeuristicsNet object.

Specified by:
getOutputSet in interface HeuristicsNet
Parameters:
index - activity index.
Returns:
output set of this activity.

toString

public java.lang.String toString()
Description copied from interface: HeuristicsNet
Creates a string representation of this HeuristicsNet object.

Specified by:
toString in interface HeuristicsNet
Overrides:
toString in class java.lang.Object
Returns:
string representation of this HeuristicsNet object.

compareTo

public int compareTo(HeuristicsNet otherHeuristicsNet)
Description copied from interface: HeuristicsNet
Compares other HeuristicsNet object with this HeuristicsNet object. The comparison is based on their fitness values.

Specified by:
compareTo in interface java.lang.Comparable<HeuristicsNet>
Specified by:
compareTo in interface HeuristicsNet
Parameters:
otherHeuristicsNet - other HeuristicsNet object to compare with this HeuristicsNet object.
Returns:
0 if the two HeuristicsNets have the same fitness value, 1 if this object's fitness value is bigger than the fitness value of the other object, -1 if the this object's fitness value is smaller than the other object's fitness value.

clone

protected HeuristicsNet clone()
Returns a deep cloning of the current HeuristicsNet.

Overrides:
clone in class java.lang.Object

copy

public HeuristicsNet copy()
Description copied from interface: HeuristicsNet
Makes a copy (deep clone) of this HeuristicsNet object.

Specified by:
copy in interface HeuristicsNet
Returns:
a copy of this HeuristicsNet object.

equals

public boolean equals(java.lang.Object other)
Description copied from interface: HeuristicsNet
Checks if a given HeuristicsNet object is equal to this HeuristicsNet object. Two HeuristicsNet objects are equal when: (i) they have the same size; (ii) they contain the same ActivitiesMappingStructures; and (iii) their input and output sets are the same.

Specified by:
equals in interface HeuristicsNet
Overrides:
equals in class java.lang.Object
Parameters:
other - HeuristicsNet object to compare with this one.
Returns:
true if the two HeuristicsNet objects satisfy the three conditions above, false otherwise.

hashCode

public int hashCode()
Description copied from interface: HeuristicsNet
Computes the hashCode for this HeuristicsNet.

Specified by:
hashCode in interface HeuristicsNet
Overrides:
hashCode in class java.lang.Object
Returns:
hashcode value.

getAllElementsInputSet

public HNSubSet getAllElementsInputSet(int index)
Description copied from interface: HeuristicsNet
Retrieves a set containing all the input activities of a given activity.

Specified by:
getAllElementsInputSet in interface HeuristicsNet
Parameters:
index - activity to which the union set should be computed.
Returns:
HNSubSet with all input activities for this activity.

getAllElementsOutputSet

public HNSubSet getAllElementsOutputSet(int index)
Description copied from interface: HeuristicsNet
Retrieves a set containing all the output activities of a given activity.

Specified by:
getAllElementsOutputSet in interface HeuristicsNet
Parameters:
index - activity to which the union set should be computed.
Returns:
HNSubSet with all output activities for this activity.

getInputSetsWithElement

public HNSet getInputSetsWithElement(int index,
                                     int element)
Description copied from interface: HeuristicsNet
Retrieves subsets from an input set of an activity. These subsets contain a certain element (or activity).

Specified by:
getInputSetsWithElement in interface HeuristicsNet
Parameters:
index - activity whose input set must the searched.
element - activity to be contained in the input subsets.
Returns:
a HNSet with the subsets that contain element, or null otherwise.

getOutputSetsWithElement

public HNSet getOutputSetsWithElement(int index,
                                      int element)
Description copied from interface: HeuristicsNet
Retrieves subsets from an output set of an activity. These subsets contain a certain element (or activity).

Specified by:
getOutputSetsWithElement in interface HeuristicsNet
Parameters:
index - activity whose output set must the searched.
element - activity to be contained in the output subsets.
Returns:
a HNSet with the subsets that contain element, or null otherwise.

getElements

public static final int[] getElements(HNSet set)
Returns an array contains all the activities that are in the subset of the HNSet structure. In practice, this array represents the multiset of the union of all the subsets in the HNSet.

Parameters:
set - HNSet with the subsets to be joined.
Returns:
array with all the activities in the subsets of set.

disconnectArcsUsedBelowThreshold

public void disconnectArcsUsedBelowThreshold(double threshold)
Description copied from interface: HeuristicsNet
Removes from this HeuristicsNet object all the arcs that have not been used up to a given threshold.

Specified by:
disconnectArcsUsedBelowThreshold in interface HeuristicsNet
Parameters:
threshold - double value of the threshold to be used during the arc pruning.

disconnectUnusedElements

public void disconnectUnusedElements()
Description copied from interface: HeuristicsNet
Disconnects in this HeuristicsNet object the activities and arcs that are not used during the parsing of an event log.

Note: This method should be used with care since, at the starting of a parsing, no elements (activities or arcs) have been used!

Specified by:
disconnectUnusedElements in interface HeuristicsNet