[kepler-dev] referencing nested parameters

Christopher Brooks cxh at eecs.berkeley.edu
Fri Oct 12 16:39:42 PDT 2012


Hi Dan,
Try ::

See kepler/ptolemy/src/doc/expressionsa3.htm

Below is the LaTeX.

_Christopher
> In the context of Ptolemy II models, the variables in scope include
> all parameters defined at the same level of the hierarchy or
> higher. So for example, if an actor has a parameter named ``\expr{x}'' 
> with
> value \expr{1.0}, then another parameter of the same actor can have an
> expression with value ``\expr{PI*x/2.0}'', which will evaluate to $\pi$/2.
>
> Consider a parameter \parameter{P} in actor \actorName{X} which is in 
> turn contained by
> composite actor \actorName{Y}. The scope of an expression for 
> \parameter{P} includes all the
> parameters contained by \actorName{X} and \actorName{Y}, plus those of 
> the container of \actorName{Y}, its
> container, etc. That is, the scope includes any parameters defined
> above in the hierarchy.
>
> You can \index{parameters, adding} add parameters to actors (composite
> or not) by right clicking on the actor, selecting
>  \submenu{Customize}{Configure} and then clicking on
> ``\expr{Add},'' or by dragging in a parameter from the \library{Utilities}
> library. Thus, you can add variables to any scope, a capability that
> serves the same role as the \index{let} ``let'' construct in many
> functional programming languages.
>
> Occasionally, it is desirable to access parameters that are not in
> scope. The expression language supports a limited syntax that permits
> access to certain variables out of scope. In particular, if in place
> of a variable name \expr{x} in an expression you write \expr{A::x},
> then instead of looking for \expr{x} in scope, the interpreter looks
> for a container named \expr{A} in the scope and a parameter named
> \expr{x} in \expr{A}.  This allows reaching down one level in the
> hierarchy from either the current container or any of its containers.

On 10/12/12 4:23 PM, Daniel Crawl wrote:
>
> Hi Christopher,
>
> Is it possible to reference a Parameter contained within another
> Parameter? For example, if Parameter x contains Parameter y, I
> expect to access y using x.y with a Const or Expression actor, but
> this does not work. What do you suggest?
>
> Thanks,
>
>   --dan

-- 
Christopher Brooks, PMP                       University of California
CHESS Executive Director                      US Mail: 337 Cory Hall
Programmer/Analyst CHESS/Ptolemy/Trust        Berkeley, CA 94720-1774
ph: 510.643.9841                                (Office: 545Q Cory)
home: (F-Tu) 707.665.0131 cell: 707.332.0670



More information about the Kepler-dev mailing list