[kepler-dev] Problems with PortParameters in RunCompositeActor

Edward A. Lee eal at eecs.berkeley.edu
Thu Sep 28 06:39:24 PDT 2006


Dan,

There were two issues here.  One was simply that the
Display actor clears the display in its initialize()
method.  So the second time the model inside the RunCompositeActor
is run, the first value that was displayed is cleared,
and only the second value is displayed.

However, if you modify the model to send the data to standard
out, then it exposed a bug in RunCompositeActor.  It wasn't
handling port parameters right, and was reading two inputs
on each firing.  I've checked in a fix and a test based on your
model.

Thanks for pointing out the problem and providing a simple example.

Edward

At 03:11 PM 9/23/2006, Dan Higgins wrote:
>Hi all,
>
>    I have run into some problems trying to use PortParameters 
> inside a RunComposite actor. There are 2 attached Ptolemy workflows 
> that illustrate the problem.
>    Each workflow creates a simple sequence of 2 tokens. The 
> test1.xml workflow sends these tokens to a Composite actor that 
> just prints the token values using a Display actor. The composite 
> uses a PortParameter. This workflow runs as expected, displaying 
> the 2 token values.
>
>    The same actors are used in the test.xml example except that the 
> Composite is replaced by a RunCompositeActor HOC actor. In this 
> case, however, only the last of the two tokens gets printed! Why is 
> only the last token displayed? I thought the RunComposite should 
> execute its contained workflow for each set of inputs passed to the 
> contained PortParameters. (At least that is what I hoped since I 
> wanted to be able to run a workflow multiple times for some set of 
> varied input parameters.) It looks like the workflow inside the 
> RunComposite actor is getting executed only once; i.e. the 
> PortParameter may be set twice before the internal workflow is executed.
>
>    Any thoughts on what is going on? Am I misunderstanding what 
> should be happening?
>
>Dan Higgins
>NCEAS
>
>
><?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="test1" class="ptolemy.actor.TypedCompositeActor">
>     <property name="_createdBy" 
> class="ptolemy.kernel.attributes.VersionAttribute" value="6.0-alpha">
>     </property>
>     <property name="SDF Director" 
> class="ptolemy.domains.sdf.kernel.SDFDirector">
>         <property name="iterations" 
> class="ptolemy.data.expr.Parameter" value="0">
>         </property>
>         <property name="_location" 
> class="ptolemy.kernel.util.Location" value="[75.0, 45.0]">
>         </property>
>     </property>
>     <property name="_windowProperties" 
> class="ptolemy.actor.gui.WindowPropertiesAttribute" 
> value="{bounds={309, 229, 813, 507}, maximized=false}">
>     </property>
>     <property name="_vergilSize" 
> class="ptolemy.actor.gui.SizeAttribute" value="[600, 400]">
>     </property>
>     <property name="_vergilZoomFactor" 
> class="ptolemy.data.expr.ExpertParameter" value="1.0">
>     </property>
>     <property name="_vergilCenter" 
> class="ptolemy.data.expr.ExpertParameter" value="{300.0, 200.0}">
>     </property>
>     <entity name="Expression" class="ptolemy.actor.lib.Expression">
>         <property name="expression" 
> class="ptolemy.kernel.util.StringAttribute" value="{1,2}">
>         </property>
>         <property name="_icon" class="ptolemy.vergil.icon.BoxedValueIcon">
>             <property name="attributeName" 
> class="ptolemy.kernel.util.StringAttribute" value="expression">
>             </property>
>             <property name="displayWidth" 
> class="ptolemy.data.expr.Parameter" value="60">
>             </property>
>         </property>
>         <property name="_location" 
> class="ptolemy.kernel.util.Location" value="[80.0, 165.0]">
>         </property>
>     </entity>
>     <entity name="ArrayToSequence" 
> class="ptolemy.domains.sdf.lib.ArrayToSequence">
>         <property name="arrayLength" 
> class="ptolemy.data.expr.Parameter" value="2">
>         </property>
>         <property name="ArrayToSequenceIcon" 
> class="ptolemy.vergil.icon.EditorIcon">
>             <property name="_windowProperties" 
> class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds 
> = {104, 129, 815, 509}, 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="[240.0, 220.0]">
>         </property>
>     </entity>
>     <entity name="Display" class="ptolemy.actor.lib.gui.Display">
>         <property name="_windowProperties" 
> class="ptolemy.actor.gui.WindowPropertiesAttribute" 
> value="{bounds={478, 345, 484, 209}, maximized=false}">
>         </property>
>         <property name="_location" 
> class="ptolemy.kernel.util.Location" value="{410, 90}">
>         </property>
>     </entity>
>     <entity name="CompositeActor" class="ptolemy.actor.TypedCompositeActor">
>         <property name="_location" 
> class="ptolemy.kernel.util.Location" value="[445.0, 260.0]">
>         </property>
>         <property name="PortParameter" 
> class="ptolemy.actor.parameters.PortParameter" value="3">
>             <property name="_hideName" 
> class="ptolemy.kernel.util.SingletonAttribute">
>             </property>
>             <property name="_iconDescription" 
> class="ptolemy.kernel.util.SingletonConfigurableAttribute">
>                 <configure>
>       <svg>
>         <polyline points="-15,-15, -3,-5, -16,5" 
> style="stroke:black"></polyline>
>       </svg>
>     </configure>
>             </property>
>             <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
>             </property>
>             <property name="_smallIconDescription" 
> class="ptolemy.kernel.util.SingletonConfigurableAttribute">
>                 <configure>
>       <svg>
>         <text x="20" style="font-size:14; font-family:SansSerif; 
> fill:black" y="20">-P-</text>
>       </svg>
>     </configure>
>             </property>
>             <property name="_editorFactory" 
> class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
>             </property>
>             <property name="_location" 
> class="ptolemy.kernel.util.Location" value="[220.0, 130.0]">
>             </property>
>         </property>
>         <property name="SDF Director" 
> class="ptolemy.domains.sdf.kernel.SDFDirector">
>             <property name="iterations" 
> class="ptolemy.data.expr.Parameter" value="2">
>             </property>
>             <property name="_location" 
> class="ptolemy.kernel.util.Location" value="{95.0, 55.0}">
>             </property>
>         </property>
>         <port name="PortParameter" 
> class="ptolemy.actor.parameters.ParameterPort">
>             <property name="input"/>
>             <property name="_location" 
> class="ptolemy.kernel.util.Location" value="{200.0, 125.0}">
>             </property>
>         </port>
>         <entity name="Display" class="ptolemy.actor.lib.gui.Display">
>             <property name="_windowProperties" 
> class="ptolemy.actor.gui.WindowPropertiesAttribute" 
> value="{bounds={624, 491, 484, 209}, maximized=false}">
>             </property>
>             <property name="_location" 
> class="ptolemy.kernel.util.Location" value="{310.0, 225.0}">
>             </property>
>         </entity>
>         <entity name="Const" class="ptolemy.actor.lib.Const">
>             <property name="value" 
> class="ptolemy.data.expr.Parameter" value="PortParameter">
>             </property>
>             <doc>Create a constant sequence.</doc>
>             <property name="_icon" 
> class="ptolemy.vergil.icon.BoxedValueIcon">
>                 <property name="attributeName" 
> class="ptolemy.kernel.util.StringAttribute" value="value">
>                 </property>
>                 <property name="displayWidth" 
> class="ptolemy.data.expr.Parameter" value="60">
>                 </property>
>             </property>
>             <property name="_location" 
> class="ptolemy.kernel.util.Location" value="{130.0, 215.0}">
>             </property>
>         </entity>
>         <relation name="relation" class="ptolemy.actor.TypedIORelation">
>             <property name="width" 
> class="ptolemy.data.expr.Parameter" value="1">
>             </property>
>         </relation>
>         <link port="Display.input" relation="relation"/>
>         <link port="Const.output" relation="relation"/>
>     </entity>
>     <relation name="relation" class="ptolemy.actor.TypedIORelation">
>         <property name="width" class="ptolemy.data.expr.Parameter" value="1">
>         </property>
>     </relation>
>     <relation name="relation3" class="ptolemy.actor.TypedIORelation">
>         <property name="width" class="ptolemy.data.expr.Parameter" value="1">
>         </property>
>         <vertex name="vertex1" value="[335.0, 205.0]">
>         </vertex>
>     </relation>
>     <link port="Expression.output" relation="relation"/>
>     <link port="ArrayToSequence.input" relation="relation"/>
>     <link port="ArrayToSequence.output" relation="relation3"/>
>     <link port="Display.input" relation="relation3"/>
>     <link port="CompositeActor.PortParameter" relation="relation3"/>
></entity>
>
><?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="test" class="ptolemy.actor.TypedCompositeActor">
>     <property name="_createdBy" 
> class="ptolemy.kernel.attributes.VersionAttribute" value="6.0-alpha">
>     </property>
>     <property name="SDF Director" 
> class="ptolemy.domains.sdf.kernel.SDFDirector">
>         <property name="iterations" 
> class="ptolemy.data.expr.Parameter" value="1">
>         </property>
>         <property name="_location" 
> class="ptolemy.kernel.util.Location" value="[75.0, 45.0]">
>         </property>
>     </property>
>     <property name="_windowProperties" 
> class="ptolemy.actor.gui.WindowPropertiesAttribute" 
> value="{bounds={309, 229, 813, 507}, maximized=false}">
>     </property>
>     <property name="_vergilSize" 
> class="ptolemy.actor.gui.SizeAttribute" value="[600, 400]">
>     </property>
>     <property name="_vergilZoomFactor" 
> class="ptolemy.data.expr.ExpertParameter" value="1.0">
>     </property>
>     <property name="_vergilCenter" 
> class="ptolemy.data.expr.ExpertParameter" value="{300.0, 200.0}">
>     </property>
>     <entity name="Expression" class="ptolemy.actor.lib.Expression">
>         <property name="expression" 
> class="ptolemy.kernel.util.StringAttribute" value="{1,2}">
>         </property>
>         <property name="_icon" class="ptolemy.vergil.icon.BoxedValueIcon">
>             <property name="attributeName" 
> class="ptolemy.kernel.util.StringAttribute" value="expression">
>             </property>
>             <property name="displayWidth" 
> class="ptolemy.data.expr.Parameter" value="60">
>             </property>
>         </property>
>         <property name="_location" 
> class="ptolemy.kernel.util.Location" value="[80.0, 165.0]">
>         </property>
>     </entity>
>     <entity name="ArrayToSequence" 
> class="ptolemy.domains.sdf.lib.ArrayToSequence">
>         <property name="arrayLength" 
> class="ptolemy.data.expr.Parameter" value="2">
>         </property>
>         <property name="ArrayToSequenceIcon" 
> class="ptolemy.vergil.icon.EditorIcon">
>             <property name="_windowProperties" 
> class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds 
> = {104, 129, 815, 509}, 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="[240.0, 220.0]">
>         </property>
>     </entity>
>     <entity name="RunCompositeActor" 
> class="ptolemy.actor.lib.hoc.RunCompositeActor">
>         <property name="_location" 
> class="ptolemy.kernel.util.Location" value="[425.0, 220.0]">
>         </property>
>         <property name="PortParameter" 
> class="ptolemy.actor.parameters.PortParameter" value="3">
>             <property name="_hideName" 
> class="ptolemy.kernel.util.SingletonAttribute">
>             </property>
>             <property name="_iconDescription" 
> class="ptolemy.kernel.util.SingletonConfigurableAttribute">
>                 <configure>
>       <svg>
>         <polyline points="-15,-15, -3,-5, -16,5" 
> style="stroke:black"></polyline>
>       </svg>
>     </configure>
>             </property>
>             <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
>             </property>
>             <property name="_smallIconDescription" 
> class="ptolemy.kernel.util.SingletonConfigurableAttribute">
>                 <configure>
>       <svg>
>         <text x="20" style="font-size:14; font-family:SansSerif; 
> fill:black" y="20">-P-</text>
>       </svg>
>     </configure>
>             </property>
>             <property name="_editorFactory" 
> class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
>             </property>
>             <property name="_location" 
> class="ptolemy.kernel.util.Location" value="[180.0, 85.0]">
>             </property>
>         </property>
>         <property name="SDF Director" 
> class="ptolemy.domains.sdf.kernel.SDFDirector">
>             <property name="iterations" 
> class="ptolemy.data.expr.Parameter" value="1">
>             </property>
>             <property name="_location" 
> class="ptolemy.kernel.util.Location" value="{85.0, 45.0}">
>             </property>
>         </property>
>         <port name="PortParameter" 
> class="ptolemy.actor.parameters.ParameterPort">
>             <property name="input"/>
>             <property name="_location" 
> class="ptolemy.kernel.util.Location" value="{160.0, 80.0}">
>             </property>
>         </port>
>         <entity name="Display" class="ptolemy.actor.lib.gui.Display">
>             <property name="_windowProperties" 
> class="ptolemy.actor.gui.WindowPropertiesAttribute" 
> value="{bounds={624, 491, 484, 209}, maximized=false}">
>             </property>
>             <property name="_location" 
> class="ptolemy.kernel.util.Location" value="{300.0, 215.0}">
>             </property>
>         </entity>
>         <entity name="Const" class="ptolemy.actor.lib.Const">
>             <property name="value" 
> class="ptolemy.data.expr.Parameter" value="PortParameter">
>             </property>
>             <doc>Create a constant sequence.</doc>
>             <property name="_icon" 
> class="ptolemy.vergil.icon.BoxedValueIcon">
>                 <property name="attributeName" 
> class="ptolemy.kernel.util.StringAttribute" value="value">
>                 </property>
>                 <property name="displayWidth" 
> class="ptolemy.data.expr.Parameter" value="60">
>                 </property>
>             </property>
>             <property name="_location" 
> class="ptolemy.kernel.util.Location" value="{120.0, 205.0}">
>             </property>
>         </entity>
>         <relation name="relation" class="ptolemy.actor.TypedIORelation">
>             <property name="width" 
> class="ptolemy.data.expr.Parameter" value="1">
>             </property>
>         </relation>
>         <link port="Display.input" relation="relation"/>
>         <link port="Const.output" relation="relation"/>
>     </entity>
>     <entity name="Display" class="ptolemy.actor.lib.gui.Display">
>         <property name="_windowProperties" 
> class="ptolemy.actor.gui.WindowPropertiesAttribute" 
> value="{bounds={478, 345, 484, 209}, maximized=false}">
>         </property>
>         <property name="_location" 
> class="ptolemy.kernel.util.Location" value="{410, 90}">
>         </property>
>     </entity>
>     <relation name="relation" class="ptolemy.actor.TypedIORelation">
>         <property name="width" class="ptolemy.data.expr.Parameter" value="1">
>         </property>
>     </relation>
>     <relation name="relation3" class="ptolemy.actor.TypedIORelation">
>         <property name="width" class="ptolemy.data.expr.Parameter" value="1">
>         </property>
>         <vertex name="vertex1" value="[335.0, 205.0]">
>         </vertex>
>     </relation>
>     <link port="Expression.output" relation="relation"/>
>     <link port="ArrayToSequence.input" relation="relation"/>
>     <link port="ArrayToSequence.output" relation="relation3"/>
>     <link port="RunCompositeActor.PortParameter" relation="relation3"/>
>     <link port="Display.input" relation="relation3"/>
></entity>

------------
Edward A. Lee
Professor, Chair of EECS
231 Cory Hall, UC Berkeley, Berkeley, CA 94720-1770
phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845
eal at eecs.Berkeley.EDU, http://ptolemy.eecs.berkeley.edu/~eal  



More information about the Kepler-dev mailing list