p3j.pppm.sets
Class Set

java.lang.Object
  extended by p3j.pppm.sets.Set
All Implemented Interfaces:
Serializable, IStochasticOccurrence

public class Set
extends Object
implements Serializable, IStochasticOccurrence

Represents a set in PPPM. A set is associated with a certain SetType, which defines for which ParameterInstance objects this set may define eligible ParameterAssignment objects. A set has a certain probability of occurrence and will be randomly chosen from a list with all sets associated with the same SetType. If it is chosen, for each ParameterInstance that is defined by its SetType one ParameterAssignment from this Set will be chosen randomly (so, there are two levels of random choosing, one in the SetType, one in the Set). The eligible ParameterAssignment objects are stored in a Map, there is a List for each ParameterInstance. See documentation of SetType for more information. Created on August 7, 2006

Author:
Christina Bohk, Roland Ewald
See Also:
Serialized Form

Constructor Summary
Set()
          Constructor for bean compatibility.
Set(List<ParameterInstance> definedParameters, String setName, String desc, double prob)
          Default constructor.
 
Method Summary
 void addParameterAssignment(ParameterAssignment paramAssign)
          Adds a new parameter assignment.
 void addParameterInstance(ParameterInstance parameterInstance)
          Adds a parameter instance to the set.
 String getDescription()
           
 int getID()
           
 String getName()
           
 int getNumberOfAssignments(ParameterInstance instance)
          Retrieve the number of eligible ParameterAssignment objects for a given ParameterInstance.
 ParameterAssignmentSet getParameterAssignments(ParameterInstance paramInstance)
          Get eligible ParameterAssignment objects for given ParameterInstance.
 double getProbability()
          Get the probability that this entity will be chosen.
 Map<ParameterInstance,ParameterAssignmentSet> getSetData()
           
 boolean isValid()
          Checks whether this set contains at least one assignment for every parameter instance.
 void removeParameterAssignment(ParameterAssignment paramAssign)
          Removes a parameter assignment.
 ParameterAssignmentSet removeParameterInstance(ParameterInstance parameterInstance)
          Removes a parameter instance from the set.
 void setDescription(String description)
           
 void setID(int uniqueID)
           
 void setName(String name)
           
 void setProbability(double probability)
          Set probability for being chosen.
protected  void setProblemOccurred(ParameterAssignment assignment)
          Throws a RuntimeException reporting on problems while processing a ParameterAssignment.
 void setSetData(Map<ParameterInstance,ParameterAssignmentSet> setData)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Set

public Set(List<ParameterInstance> definedParameters,
           String setName,
           String desc,
           double prob)
Default constructor.

Parameters:
definedParameters - set of parameter instances for which this set may define assignments
setName - name of the set
desc - description of the set
prob - probability of the set

Set

public Set()
Constructor for bean compatibility.

Method Detail

getParameterAssignments

public ParameterAssignmentSet getParameterAssignments(ParameterInstance paramInstance)
Get eligible ParameterAssignment objects for given ParameterInstance.

Parameters:
paramInstance - the parameter instance
Returns:
list of parameter assignments

addParameterInstance

public final void addParameterInstance(ParameterInstance parameterInstance)
Adds a parameter instance to the set. This adds an empty list of eligible ParameterAssignment objects to setData. This is a management method for the associated SetType.

Parameters:
parameterInstance - the parameter instance to be added

removeParameterInstance

public ParameterAssignmentSet removeParameterInstance(ParameterInstance parameterInstance)
Removes a parameter instance from the set. All associated ParameterAssignment objects will be removed from setData. This is a management method for the associated SetType.

Parameters:
parameterInstance - the parameter instance to be removed
Returns:
assignments associated with removed parameter instance (null if not existing)

addParameterAssignment

public void addParameterAssignment(ParameterAssignment paramAssign)
Adds a new parameter assignment.

Parameters:
paramAssign - parameter assignment to be added

removeParameterAssignment

public void removeParameterAssignment(ParameterAssignment paramAssign)
Removes a parameter assignment.

Parameters:
paramAssign - parameter assignment to be removed

setProblemOccurred

protected void setProblemOccurred(ParameterAssignment assignment)
Throws a RuntimeException reporting on problems while processing a ParameterAssignment. This method is called when the ParameterInstance associated with the ParameterAssignment is not managed by the SetType of this set.

Parameters:
assignment - the parameter assignment to be processed

getNumberOfAssignments

public int getNumberOfAssignments(ParameterInstance instance)
Retrieve the number of eligible ParameterAssignment objects for a given ParameterInstance.

Parameters:
instance - the parameter instance
Returns:
number of assignments for given instance

isValid

public boolean isValid()
Checks whether this set contains at least one assignment for every parameter instance.

Returns:
true, if set is valid (i.e. above condition is satisfied)

setProbability

public void setProbability(double probability)
Description copied from interface: IStochasticOccurrence
Set probability for being chosen.

Specified by:
setProbability in interface IStochasticOccurrence
Parameters:
probability - the probability (in [0,1])

toString

public String toString()
Overrides:
toString in class Object

getSetData

public Map<ParameterInstance,ParameterAssignmentSet> getSetData()

setSetData

public void setSetData(Map<ParameterInstance,ParameterAssignmentSet> setData)

getDescription

public String getDescription()

setDescription

public void setDescription(String description)

getName

public String getName()

setName

public void setName(String name)

getProbability

public double getProbability()
Description copied from interface: IStochasticOccurrence
Get the probability that this entity will be chosen.

Specified by:
getProbability in interface IStochasticOccurrence
Returns:
probability to be chosen, in [0,1]

getID

public int getID()

setID

public void setID(int uniqueID)


Copyright © 2012. All Rights Reserved.