Hello and thanks,
*> **are your agents Oz objects, i.e. instances of classes?*
Yes my agents are instances of classes that I've already created (A class
for blue agents and a class for red agents since they don't behave alike)
*> 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.*
this is what I had in mind too but in order to use "{DP.annotate X
stationary}" (which I find easiest to use) I need Mozart 1.4.0 which I don't
have (basically because (correct me if I'm wrong) I read somewhere that
Mozart 1.4.0 had a problem with distributed programming. I wanted to make
sure so I wrote a small code (which I can't remember since it's been months
ago) and ran it using Mozart 1.3.8 and it worked perfectly but using Mozart
1.4.0 it didn't work at all).
Also, I tried the little code you wrote while connecting to my localhost as
the remote site and I got false as a result for both T and T2, is this
result correct or should I try connecting to another machine rather than my
own? If not then what should I have obtained (for T2 I used the code in the
link you provided since I'm using Mozart 1.3.8).
Anyway, I'm planning to procede in this direction so if you have examples
that can help me have a better idea on how to write my code I would
appreciate it (especially how to use Remote in my Environment class in order
to create (using init method) and execute (using start method) my agents on
remote sites. Because the functor Remote needs is confusing me (like where
to write it and how to make it create and start the agents on the remote
site).
Thanks a lot for the help.
2010/8/12 Wolfgang Meyer <[email protected]>
> 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
>
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users