Re: Suggestions for Maintaining "Object" State?
- To: mathgroup at smc.vnet.net
- Subject: [mg78344] Re: Suggestions for Maintaining "Object" State?
- From: "Steve Luttrell" <steve at _removemefirst_luttrell.org.uk>
- Date: Thu, 28 Jun 2007 06:33:28 -0400 (EDT)
- References: <f5vsk1$l46$1@smc.vnet.net>
In version 6 there is a very interesting tutorial that you can see by typing tutorial/AdvancedDynamicFunctionality into the Documentation Center window. Local variables defined within DynamicModule have their states preserved, because they are stored (in a hidden way) in the output cell created by DynamicModule. Although I haven't yet used this behaviour to do simulations of the sort that you describe, it looks to me as if DynamicModule may well give you the functionality you want. Steve Luttrell West Malvern, UK "Carey Sublette" <careysub at earthling.net> wrote in message news:f5vsk1$l46$1 at smc.vnet.net... >I am starting to develop a fairly complex simulation using Mathematica 6 >and > am confronting a basic issue that I am unsure how best to resolve: "How to > preserve the state of an object?" > > Physical objects represented in a simulation have internal state that is > preserved and affects how they respond to stimulus from the simulation > environment. > > Possible ways of implementing this behavior includes creating modules > representing objects and: > * exporting state to the session (or other enclosing scope) as a list of > values, which either exists as a global variable or is passed in as a > parameter; > * using UpValues or Tags to assign object state to symbols(?). > > At the moment the objects in the simulation have a 1-to-1 relationship, > there is only one of each type, which simplifies the problem, though in > the > future I may need to maintain state for multiple objects of the same type. > > Does anyone have recommendations for how to do this, optimized either for > convenience or efficiency? > >