Hi, are your agents Oz objects, i.e. instances of classes? And which Oz version are you using?
By default, objects are mobile. Methods calls are executed in the thread that invoked the method. See http://www.mozart-oz.org/documentation/dstutorial/node2.html#label25 You can make an object "stationary". In this case, the methods are execute on the site where the object was created. For example: ---------------------- declare class Test meth init skip end %% Call this with an unbound variable. %% Returns whether this object runs on a remote site. %% WARNING: this is a hack that exploits implementation details; %% do not use in real code meth isRemote(Unbound $) {Value.toVirtualString Unbound 1000 1000} == "_<simple distributed>" end end %% create a mobile instance T = {New Test init} %% create a stationary instance (Mozart 1.4.0 needed) T2 = {New Test init} {DP.annotate T2 stationary} %% The code in this functor is executed on the remote site functor RemoteCode import Inspector define {Inspector.inspect {T isRemote( _ $)}} {Inspector.inspect {T2 isRemote( _ $)}} end RM = {New Remote.manager init} {RM apply(RemoteCode _)} %{RM close} ---------------------- So the easiest way would be to create the blue (remote) agents on the remote site and annotate them as stationary. Then their methods will always be executed on the remote site. I don't think it is possible to make existing objects migrate explicitly. It IS however possible to create a procedural wrapper around an existing object that makes sure that the methods are executed on a remote site when called through that wrapper. (Recipe: create a server on the remote site in its own thread; send object to server; server calls MakeStat on object and returns result, http://www.mozart-oz.org/documentation/dstutorial/node3.html#making.stationary.objects). If you want to go this way and need an example, let me know. Cheers, Wolfgang On Wed, Aug 11, 2010 at 7:57 PM, Khadija EL MAHRSI < [email protected]> wrote: > Hello, > I have a problem which I've been trying to solve for quite some time now but > to no avail (I'm still very new to Oz/Mozart). > I have a class Environment in which I created 2 lists containing each a > numbre of a determined type of agents (Let us say a list of red agents and a > list of blue ones). > The agents of one of these lists (the red agents for example) must remain > local while the others are sent to a remote site. > I'm trying to achive this using Remote but it's not working. > I have an Environment class which has two methods: init (which initializes > the agents and displays them on the screen) and start (which makes my agents > move by starting each agent in both list). > The same goes for the agents (both red and blue): an init method initializes > them while the start method allows the agent to start moving). > > My problem is how to write such a thing (If this is possible to achieve). > The result I want is that after applying the Remote I would get the list of > blue agents which I can manipulate exactly as if it were local (but whose > agents are actually running on a remote site) in my Environment class. > > I would appreciate any help offered. > > Thanks > > _________________________________________________________________________________ > mozart-users mailing list > [email protected] > http://www.mozart-oz.org/mailman/listinfo/mozart-users >
_________________________________________________________________________________ mozart-users mailing list [email protected] http://www.mozart-oz.org/mailman/listinfo/mozart-users
