You are right!  I've checked in your fix.
Thanks!

Edward

At 05:46 AM 3/28/2006, Adriana Ricchiuti wrote:
Hi all,
I have some problem with the Sequencer actor. In fact, the actor behavior should be the following: if this actor produced an output, then it may be immediately followed by tokens that were previously saved, if their sequence numbers are next. But this isn't, because the data structure, in which the tokens with sequence number are saved, isn't cleared between one execution and next. The structure should be cleared in initialize() method, but this method didn't. Could it be a bag of the Sequencer actor?
This is the original code:

public void initialize() throws IllegalActionException {
       _fireProducedOutput = false;
       _nextSequenceNumber = ((IntToken) startingSequenceNumber.getToken())
           .intValue();
   }

The data structure is cleared by adding a new code row in initialize() method:

public void initialize() throws IllegalActionException {
       _fireProducedOutput = false;
       _nextSequenceNumber = ((IntToken) startingSequenceNumber.getToken())
           .intValue();
       _pending.clear();
   }

In the model I attached, it is possible to note that actor behavior is non-deterministic, with the original code. With the updated code, the behavior is deterministic, because the data structure is always cleared whenever the actor is executed.

Thanks,
Adriana


<?xml version="1.0" standalone="no"?>
<!DOCTYPE entity PUBLIC "-//UC Berkeley//DTD MoML 1//EN"
    "http://ptolemy.eecs.berkeley.edu/xml/dtd/MoML_1.dtd";>
<entity name="Sequencer" class="ptolemy.actor.TypedCompositeActor">
<property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" value="5.0.1">
    </property>
<property name="DE Director" class="ptolemy.domains.de.kernel.DEDirector"> <property name="stopTime" class="ptolemy.data.expr.Parameter" value="20">
        </property>
<property name="stopWhenQueueIsEmpty" class="ptolemy.data.expr.Parameter" value="false">
        </property>
<property name="_location" class="ptolemy.kernel.util.Location" value="[100.0, 55.0]">
        </property>
    </property>
<property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds={88, 0, 820, 406}, maximized=false}">
    </property>
<property name="_vergilSize" class="ptolemy.actor.gui.SizeAttribute" value="[598, 293]">
    </property>
<property name="_vergilZoomFactor" class="ptolemy.data.expr.ExpertParameter" value="1.0">
    </property>
<property name="_vergilCenter" class="ptolemy.data.expr.ExpertParameter" value="{299.0, 146.5}">
    </property>
    <entity name="Sequencer" class="ptolemy.actor.lib.Sequencer">
<property name="startingSequenceNumber" class="ptolemy.data.expr.Parameter" value="0">
        </property>
<property name="_location" class="ptolemy.kernel.util.Location" value="[435.0, 210.0]">
        </property>
    </entity>
    <entity name="Display" class="ptolemy.actor.lib.gui.Display">
<property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds={805, 640, 468, 205}, maximized=false}">
        </property>
<property name="_location" class="ptolemy.kernel.util.Location" value="[530.0, 210.0]">
        </property>
    </entity>
    <entity name="Clock" class="ptolemy.actor.lib.Clock">
        <doc>Create a set of pulses</doc>
<property name="_location" class="ptolemy.kernel.util.Location" value="[95.0, 165.0]">
        </property>
    </entity>
    <entity name="Clock2" class="ptolemy.actor.lib.Clock">
        <doc>Create a set of pulses</doc>
<property name="_location" class="ptolemy.kernel.util.Location" value="[95.0, 255.0]">
        </property>
    </entity>
    <entity name="Sequence2" class="ptolemy.actor.lib.Sequence">
<property name="values" class="ptolemy.data.expr.Parameter" value="{0, 2, 3, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}">
        </property>
<property name="repeat" class="ptolemy.data.expr.Parameter" value="false">
        </property>
        <property name="SequenceIcon" class="ptolemy.vergil.icon.EditorIcon">
<property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds={57, 18, 815, 516}, maximized=false}">
            </property>
<property name="_vergilSize" class="ptolemy.actor.gui.SizeAttribute" value="[600, 400]">
            </property>
        </property>
<property name="_location" class="ptolemy.kernel.util.Location" value="[290.0, 255.0]">
        </property>
    </entity>
    <entity name="IsPresent2" class="ptolemy.actor.lib.logic.IsPresent">
<property name="_location" class="ptolemy.kernel.util.Location" value="[195.0, 255.0]">
        </property>
    </entity>
    <entity name="Ramp" class="ptolemy.actor.lib.Ramp">
        <doc>Create a sequence of tokens with increasing value</doc>
<property name="_location" class="ptolemy.kernel.util.Location" value="[225.0, 175.0]">
        </property>
    </entity>
    <relation name="relation3" class="ptolemy.actor.TypedIORelation">
    </relation>
    <relation name="relation2" class="ptolemy.actor.TypedIORelation">
    </relation>
    <relation name="relation4" class="ptolemy.actor.TypedIORelation">
    </relation>
    <relation name="relation7" class="ptolemy.actor.TypedIORelation">
    </relation>
    <relation name="relation" class="ptolemy.actor.TypedIORelation">
    </relation>
    <relation name="relation5" class="ptolemy.actor.TypedIORelation">
    </relation>
    <link port="Sequencer.input" relation="relation5"/>
    <link port="Sequencer.output" relation="relation3"/>
    <link port="Sequencer.sequenceNumber" relation="relation7"/>
    <link port="Display.input" relation="relation3"/>
    <link port="Clock.output" relation="relation"/>
    <link port="Clock2.output" relation="relation4"/>
    <link port="Sequence2.enable" relation="relation2"/>
    <link port="Sequence2.output" relation="relation7"/>
    <link port="IsPresent2.input" relation="relation4"/>
    <link port="IsPresent2.output" relation="relation2"/>
    <link port="Ramp.output" relation="relation5"/>
    <link port="Ramp.trigger" relation="relation"/>
</entity>

------------
Edward A. Lee
Professor, Chair of the EE Division, Associate Chair of EECS
231 Cory Hall, UC Berkeley, Berkeley, CA 94720
phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845
[EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal

----------------------------------------------------------------------------
Posted to the ptolemy-hackers mailing list.  Please send administrative
mail for this list to: [EMAIL PROTECTED]

Reply via email to