org.yawlfoundation.yawl.resourcing.allocators
Class AbstractAllocator

java.lang.Object
  extended by org.yawlfoundation.yawl.resourcing.AbstractSelector
      extended by org.yawlfoundation.yawl.resourcing.allocators.AbstractAllocator
Direct Known Subclasses:
CheapestCompleter, CheapestResource, CheapestStarter, CheapestToAllocate, DearestResource, FastestResource, FastestToAllocate, FastestToComplete, FastestToStart, GenericAllocator, RandomChoice, RoundRobinByExperience, RoundRobinByLeastFrequency, RoundRobinByTime, ShortestQueue

public abstract class AbstractAllocator
extends AbstractSelector

The base class for all allocators. Create Date: 03/08/2007. Last Date: 09/11/2007

Version:
2.0
Author:
Michael Adams (BPM Group, QUT Australia)

Nested Class Summary
protected  class AbstractAllocator.EventPair
           
 
Field Summary
 
Fields inherited from class org.yawlfoundation.yawl.resourcing.AbstractSelector
_canonicalName, _description, _displayName, _name, _params
 
Constructor Summary
AbstractAllocator()
          Constructors
AbstractAllocator(String name)
           
AbstractAllocator(String name, HashMap<String,String> params)
           
AbstractAllocator(String name, String description)
           
AbstractAllocator(String name, String desc, HashMap<String,String> params)
           
 
Method Summary
protected  Map<String,Long> getAvgDurations(Collection<AbstractAllocator.EventPair> pairs)
           
protected  Map<String,Long> getAvgDurations(EventLogger.event fromEvent, EventLogger.event toEvent, WorkItemRecord wir)
          Gets the average duration (in msecs) between two events for each participant recorded against those events for a task
protected  double getCost(XNode resNode, String duration)
           
protected  Map<String,XNode> getCostMap(Set<String> pids, WorkItemRecord wir)
          Gets from the cost service the cost per msec of each of the participants ids listed for the work item
protected  List getLoggedEvents(WorkItemRecord wir, EventLogger.event event)
          Gets a list of all resource log rows for a given specification + task + event combination.
protected  Map<String,Participant> participantSetToMap(Set<Participant> pSet)
          Converts a set of participants to a map
abstract  Participant performAllocation(Set<Participant> resources, WorkItemRecord wir)
          Performs an allocation using some strategy
 String toXML()
          Generates the XML required for the specification file
static AbstractAllocator unmarshal(org.jdom.Element elAllocator)
          Creates a runtime instance of this class from an XML description of it
 
Methods inherited from class org.yawlfoundation.yawl.resourcing.AbstractSelector
addKey, addParam, addParams, getCanonicalName, getClassName, getDescription, getDisplayName, getInformation, getKeys, getName, getParamKeys, getParams, getParamValue, reconstitute, setCanonicalName, setDescription, setDisplayName, setKeyValue, setName, setParams, toString, unmarshalParams
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractAllocator

public AbstractAllocator()
Constructors


AbstractAllocator

public AbstractAllocator(String name)

AbstractAllocator

public AbstractAllocator(String name,
                         HashMap<String,String> params)

AbstractAllocator

public AbstractAllocator(String name,
                         String description)

AbstractAllocator

public AbstractAllocator(String name,
                         String desc,
                         HashMap<String,String> params)
Method Detail

toXML

public String toXML()
Generates the XML required for the specification file

Overrides:
toXML in class AbstractSelector
Returns:
an XML'd String containing the member values of an instantiation of this class

unmarshal

public static AbstractAllocator unmarshal(org.jdom.Element elAllocator)
Creates a runtime instance of this class from an XML description of it

Parameters:
elAllocator - a JDOM Element describing the class
Returns:
the instantiated object

getLoggedEvents

protected List getLoggedEvents(WorkItemRecord wir,
                               EventLogger.event event)
Gets a list of all resource log rows for a given specification + task + event combination.

Parameters:
wir - a workitem record which is an instance of the specification+task in question.
event - the type of event to get records for
Returns:
the matching list of ResourceEvent objects (each one a row of the log)

participantSetToMap

protected Map<String,Participant> participantSetToMap(Set<Participant> pSet)
Converts a set of participants to a map

Parameters:
pSet - the set of participants
Returns:
a map of participant id to participant

getCostMap

protected Map<String,XNode> getCostMap(Set<String> pids,
                                       WorkItemRecord wir)
Gets from the cost service the cost per msec of each of the participants ids listed for the work item

Parameters:
pids - a set of participant ids
wir - the work item to allocate
Returns:
a map containing each participant id and its corresponding cost per msec to perform this work item

getCost

protected double getCost(XNode resNode,
                         String duration)

getAvgDurations

protected Map<String,Long> getAvgDurations(EventLogger.event fromEvent,
                                           EventLogger.event toEvent,
                                           WorkItemRecord wir)
Gets the average duration (in msecs) between two events for each participant recorded against those events for a task

Parameters:
fromEvent - the earlier event (start of duration)
toEvent - the later event (end of duration)
wir - a work item to allocate
Returns:
a Map of participant ids and average durations

getAvgDurations

protected Map<String,Long> getAvgDurations(Collection<AbstractAllocator.EventPair> pairs)

performAllocation

public abstract Participant performAllocation(Set<Participant> resources,
                                              WorkItemRecord wir)
Performs an allocation using some strategy

Parameters:
resources - the distribution set of participants
wir - the work item to allocate
Returns:
the Participant chosen by the allocation strategy


Copyright © 2004-2012 The YAWL Foundation.