[kepler-users] modal model questions

Edward Lee eal at eecs.berkeley.edu
Wed Oct 16 20:15:41 PDT 2013



On 10/16/13 9:28 AM, Frank White wrote:
> Greetings:
> I have a couple questions regarding modal models, and one general 
> modeling question.
>
> 1a. Should I be able to modify extended state parameters from within 
> transition refinements using SetVariable?
>
> In the attached simple (but otherwise uninteresting) example, I can 
> successfully SetVariable from within the state refinement and via the 
> transition setAction, but apparently not from within the transition 
> refinement.

I works for me.  ???
I'm running the model in the current version of Ptolemy (10.0 devel), 
not in Kepler.
Is Kepler using an older version?

If I reset all parameters to zero and run the model, all three get set 
as intended.
Note that the refinement of the final state does not fire, as entering 
the final state causes the model to terminate.

Transition refinements are deprecated.
The preferred way to to do this is to use immediate transitions.
This is documented in chapters 6 and 8 of the book: 
http://ptolemy.org/systems

Also, I try to avoid SetVariable. It's too much like global variables :-)
I prefer to set values using the set actions of transitions.
>
> 1b. When I run the attached simple example the first time after 
> loading it, I get the following error.  It works as expected on 
> subsequent runs.  What does this error mean?
>
>     ptolemy.kernel.util.IllegalActionException: Failed to compute
>     schedule:
>       in .vergiltest.state.SDF Director
>     Because:
>     Invalid weight argument, the number of elements for this weight is
>     zero.
>     The weight is of class ptolemy.data.expr.Variable and its
>     description follows:
>     ptolemy.data.expr.Variable {.vergiltest.relation.Parameter2} value
>     undefined
>     A Dump of the offending graph follows.
>
>     **I can send the rest if desired**
>

Again, I don't get this error.

> 2.  Is there any mechanism to reference the current state by name from 
> within a state refinement?  I wish to do this for logging purposes.
There is a hack:
Inside a state refinement, a Const actor with value given by 
"this.getContainer().getName()" will return the name of the refinement.
By default, the name of the refinement is the same as the name of the state.

This might be a bit of a kludge.
It might be better for a modal model to output the name of a state (e.g. 
the destination state) on each transition.

>
> 3.  Is there any mechanism to for a model to reference the current 
> top-level director's iteration count?  (this is for any model - not 
> just modal models, also for logging purposes)
The notion of an iteration count is particular to SDF and SR directors. 
I don't think the other directors have it.
At the top level, you could feed a Ramp into a SetVariable (OK, maybe 
there are valid uses for SetVariable :-)

Edward

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nceas.ucsb.edu/kepler/pipermail/kepler-users/attachments/20131016/5b52dda6/attachment.html>


More information about the Kepler-users mailing list