Class SequenceSchedule
- java.lang.Object
-
- ptolemy.actor.sched.ScheduleElement
-
- ptolemy.actor.sched.Schedule
-
- ptolemy.domains.sequence.kernel.SequenceSchedule
-
public class SequenceSchedule extends Schedule
An extension of the Schedule class to support sequenced actors. This includes support for control actors and support for upstream actors. If control actors are present, the firing of a SequenceSchedule depends on which control branches are chosen. The SequenceSchedule is different from other schedules in that it This class overwrites actorIterator() and firingIterator(). FIXME: actorIterator() is not implemented yet. The firingIterator() will evaluate the condition of control actors and determine which actors to place in the scheduler next. FIXME: add(), insert(), remove() currently not supported. What should they do for this kind of schedule? Not sure how other entities should be allowed to add to schedule. FIXME: size() is also not correct. This should probably count all actors in the sub-graphs as well? How should the control branches be reflected in the size()? Should it just be the number of actors scheduled so far? FIXME: toString() not implemented. The SequenceSchedule schedules itself... // Begin Ptolemy standard comments This class represents a static schedule of actor executions. An instance of this class is returned by the scheduler of a model to represent order of actor firings in the model. A schedule consists of a list of schedule elements and the number of times the schedule should repeat (called the iteration count).Each element of the schedule is represented by an instance of the ScheduleElement class. Each element may correspond to a number of firings of a single actor (represented by the Firing class) or an entire sub-schedule (represented by a hierarchically contained instance of this class). This nesting allows this concise representation of looped schedules. The nesting can be arbitrarily deep, but must be a tree where the leaf nodes represent actor firings. It is up to the scheduler to enforce this requirement.
The add() and remove() methods are used to add or remove schedule elements. Only elements of type ScheduleElement (Schedule or Firing) may be added to the schedule list. Otherwise an exception will occur.
The iteration count is set by the setIterationCount() method. If this method is not invoked, a default value of one will be used.
As an example, suppose that we have an SDF graph containing actors A, B, C, and D, with the firing order ABCBCBCDD. This firing order can be represented by a simple looped schedule. The code to create this schedule appears below.
Schedule S = new Schedule(); Firing S1 = new Firing(); Schedule S2 = new Schedule(); Firing S3 = new Firing(); S.add(S1); S.add(S2); S.add(S3); S1.setActor(A); S2.setIterationCount(3); Firing S2_1 = new Firing(); Firing S2_2 = new Firing(); S2_1.setActor(B); S2_2.setActor(C); S2.add(S2_1); S2.add(S2_2); S3.setIterationCount(2); S3.setActor(D);
Note that this implementation is not synchronized. It is therefore not safe for a thread to make modifications to the schedule structure while multiple threads are concurrently accessing the schedule.
References
S. S. Bhattacharyya, P K. Murthy, and E. A. Lee, Software Syntheses from Dataflow Graphs, Kluwer Academic Publishers, 1996.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Brian K. Vogel, Steve Neuendorffer, Elizabeth Latronico (Bosch)
- See Also:
Firing
,ScheduleElement
- Pt.AcceptedRating:
- Red (beth)
- Pt.ProposedRating:
- Red (beth)
-
-
Field Summary
Fields Modifier and Type Field Description protected SequenceAttribute
_currentControlSeqAttr
Keeps track of the last-executed control actor.protected int
_schedulePosition
Keeps track of our position in the list.-
Fields inherited from class ptolemy.actor.sched.ScheduleElement
_parent
-
-
Constructor Summary
Constructors Constructor Description SequenceSchedule()
Construct a schedule with iteration count of one and an empty schedule list.SequenceSchedule(java.util.List<SequenceAttribute> independentList, java.util.Hashtable<SequenceAttribute,java.util.Hashtable> controlTable, java.util.Hashtable<SequenceAttribute,DirectedAcyclicGraph> sequencedActorsToSubgraph)
Instantiate a new schedule based on these data structures.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Iterator
firingIterator()
Return the actor invocation sequence of this schedule in the form of a sequence of firings.java.util.List<SequenceAttribute>
getUnexecutedList()
Return the list of unexecuted actor sequence numbers that were not executed during the schedule because their branches were not taken.-
Methods inherited from class ptolemy.actor.sched.Schedule
actorIterator, add, add, get, iterator, remove, size, toString
-
Methods inherited from class ptolemy.actor.sched.ScheduleElement
_getVersion, _incrementVersion, getIterationCount, setIterationCount, setParent
-
-
-
-
Field Detail
-
_schedulePosition
protected int _schedulePosition
Keeps track of our position in the list. Used by the hasNext() methods of the iterators.
-
_currentControlSeqAttr
protected SequenceAttribute _currentControlSeqAttr
Keeps track of the last-executed control actor. If this variable is other than null, need to check the controlTable to get the correct next actor to execute. Note that not all control actors may be present in the _independentList since some might be nested. All control actors must have a SequenceAttribute (if an actor is nested, it will still have a SequenceAttribute, but no process name).
-
-
Constructor Detail
-
SequenceSchedule
public SequenceSchedule()
Construct a schedule with iteration count of one and an empty schedule list. This constructor should be used when creating a root schedule. The constructor that takes a parameter should be used when creating a subschedule.
-
SequenceSchedule
public SequenceSchedule(java.util.List<SequenceAttribute> independentList, java.util.Hashtable<SequenceAttribute,java.util.Hashtable> controlTable, java.util.Hashtable<SequenceAttribute,DirectedAcyclicGraph> sequencedActorsToSubgraph)
Instantiate a new schedule based on these data structures.- Parameters:
independentList
- List of independent sequence attributes. (and, associated actors, found by calling .getContainer on a SequenceAttribute) There must be at least one sequence attribute in the _independentList.controlTable
- A hash table mapping a sequence actor name to a hash table of branches and a list of dependent actors (if any) for each branch.sequencedActorsToSubgraph
- Hash table of sequenced actor nodes to their subgraphs Used in conjunction with the control graph for determining the schedule.
-
-
Method Detail
-
firingIterator
public java.util.Iterator firingIterator()
Return the actor invocation sequence of this schedule in the form of a sequence of firings. All of the lowest-level nodes of the schedule should be an instance of Firing. Otherwise an exception will occur at some point in the iteration.A runtime exception is thrown if the underlying schedule structure is modified while the iterator is active.
Implementation note: This method is optimized to be memory efficient. It walks the schedule tree structure as the iterator methods are invoked.
- Overrides:
firingIterator
in classSchedule
- Returns:
- An iterator over a sequence of firings.
- Throws:
java.util.ConcurrentModificationException
- If the underlying schedule structure is modified while the iterator is active.
-
getUnexecutedList
public java.util.List<SequenceAttribute> getUnexecutedList()
Return the list of unexecuted actor sequence numbers that were not executed during the schedule because their branches were not taken.- Returns:
- The list of unexecuted actor sequence numbers.
-
-