[kepler-dev] [Bug 4086] - Port-Parameters half-work with composite actors

bugzilla-daemon at ecoinformatics.org bugzilla-daemon at ecoinformatics.org
Thu Jun 4 16:50:35 PDT 2009


http://bugzilla.ecoinformatics.org/show_bug.cgi?id=4086


cxh at eecs.berkeley.edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX




------- Comment #2 from cxh at eecs.berkeley.edu  2009-06-04 16:50 -------
PortParameters work with opaque composite actors (composite actors
that have directors), but not transparent composite actors.

The class comment for PortParameter says:
--start--
 There are a few situations where PortParameter might not do what
 you expect:


 * If it is used in a transparent composite actor, then a token provided
 to a PortParameter will never be read.  A transparent composite actor
 is one without a director.
 Workaround: Put a director in the composite.

 * Certain actors (such as the Integrator in CT) read parameter
 values only during initialization.  During initialization, a
 PortParameter can only have a value set via the parameter (it
 can't have yet received a token).  So if the initial value of the
 Integrator is set to the value of the PortParameter, then it will
 see only the parameter value, never the value provided via the
 port.
 Workaround: Use a RunCompositeActor to contain the model with the
 Integrator.
--end--


Also, there was this thread in November 2007 on ptdevel:  
--start--
[Christopher wrote:]
Hi Dan,
Right, sorry.

It is sort of a zen thing,  "The port is connected, yet it is
not connected" :-)

I have sort of a wacky view of PortParameters in that I see them to be
"like" Ports and Parameters, yet also not like either Ports or
Parameters.  In this case the PortParameter is not actually a Port at
preinitialize time.

I agree that it is confusing.  Perhaps the PortParameter
constructor should look for a director in the container and
print a message if there is no director.  This seems a little
over kill.

I'm not that fond of PortParameters, they do seem fragile.
However, they are very powerful.

_Christopher

--------

    Christopher,
        My problem is that test.const IS CONNECTED, despite the message (at 
    least on my display). Putting a SDF Director inside the Composite does 
    fix the problem.

    Dan

    Christopher Brooks wrote:
    > Dan writes:
    >   
    >> Hi Christopher,
    >>    We have recently run into some problems using the PortParameter in
    >> Kepler (example: deleting a PortParamter seems to really trash Kepler!)
    >> So I thought I would try a simple workflow in Ptolemy (attached). This
    >> is a SDF model with a constant feeding a PortParameter inside a
    >> Composite. Inside the Composite the PortParameter name is used in
    >> another constant connected to a Display.
    >>
    >>   When I try running this in VergiI I get an error that the SDF
    >> scheduler found disconnected actor (the external constant). It sure
    >> doesn't look disconnected! Any ideas on what's up?
    >>     
    >
    > Hi Dan,
    > The error message is:
    > ptolemy.actor.sched.NotSchedulableException: SDF scheduler found disconne
   cted actors! Usually, disconnected actors in an SDF model indicates an error
   .  If this is not an error, try setting the SDFDirector parameter allowDisco
   nnectedGraphs to true.
    > Unreached Actors:
    > .test.Const 
    > Reached Actors:
    > .test.CompositeActor.Const .test.CompositeActor.Display 
    >   at ptolemy.domains.sdf.kernel.SDFScheduler._solveBalanceEquations(SDFSc
   heduler.java:787)
    >   at ptolemy.domains.sdf.kernel.SDFScheduler._getSchedule(SDFScheduler.ja
   va:539)
    >   at ptolemy.actor.sched.Scheduler.getSchedule(Scheduler.java:188)
    >   at ptolemy.domains.sdf.kernel.SDFDirector.preinitialize(SDFDirector.jav
   a:542)
    >   at ptolemy.actor.CompositeActor.preinitialize(CompositeActor.java:1047)
    >   at ptolemy.actor.Manager.preinitializeAndResolveTypes(Manager.java:912)
    >   at ptolemy.actor.Manager.initialize(Manager.java:578)
    >   at ptolemy.actor.Manager.execute(Manager.java:321)
    >   at ptolemy.actor.Manager.run(Manager.java:1070)
    >   at ptolemy.actor.Manager$3.run(Manager.java:1111)
    >
    >
    > The problem is that test.Const is not connected.  One workaround
    > is to set the "allowDisconnectedGraphs" parameter in the SDF Director.
    >
    > Another workaround is to put a SDF director inside the CompositeActor.
    >
    > The PortParameter class docs say:
    > --start--
    >    There are a few situations where PortParameter might not do what      

    >  you expect:                                                             

    >                                                                          


    >    If it is used in a transparent composite actor, then a token provided 

    >  to a PortParameter will never be read.  A transparent composite actor   

    >  is one without a director.                                              

    >   Workaround: Put a director in the composite.                           

    >  --end-                      
    >
    > I think the problem here is that when SDF is trying to calculate the bala
   nce
    > equations, it is not finding the connection.  This is a problem with
    > transparent CompositeActors.
    >
    > I verified that the error message appears in Ptolemy II 6.1.devel,
    > 6.0.2 and 5.0.1, so this is not a new misfeature.
    >
    > _Christopher
    >
    >   
--end--


The error message about ports being disconnected was misleading (aka wrong).
However, there is no easy fix for this as a transparent composite actor
has nothing to fire during initialize(), so there is no easy way to detect
this.

We could modify PortParameter so that it can only be placed in a composite
that has a director, but then if the director was removed after the
PortParameter was instantianted, we would not have any way of detecting this.
Also, if the MoML created the PortParameter before the director was added,
then there would be an error.

I modified SDFScheduler so that if actors are not connected, it looks for
transparent composite actors that have PortParameters and lists the
PortParameters.  This is a hack, but better than nothing.  To get this
change, update to the most recent version of ptolemy by using the
magic ant command in the build system that builds from the ptII head.
The default "ant update" will not build from the ptII head.

I'm marking this as WONTFIX because we are not likely to ever fix this.
If someone disagrees, feel free to reopen and hopefully give a lower priority.


More information about the Kepler-dev mailing list