swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: modelProbeMap in simpleExperSwarm.m


From: Sven N. Thommesen
Subject: Re: modelProbeMap in simpleExperSwarm.m
Date: Tue, 15 Sep 1998 13:36:15 -0500

>Date: Tue, 15 Sep 1998 13:29:45 -0500
>To: address@hidden
From: "Sven N. Thommesen" <address@hidden>
>Subject: Re: modelProbeMap in simpleExperSwarm.m
>X-Attachments: G:\iqbal.tar;
>In-Reply-To: <address@hidden>
>References: <address@hidden>
>
>At 07:45 PM 9/14/1998 +0100, you wrote:
>> 
>>> Zafar,
>>> it's difficult to tell what may be going wrong with the info you've given
>>> us. Please make me a tarball* of your whole appdir and send it to me
>>> privately as an email appendix, and I'll see if I can spot anything
obvious.
>>> 
>>> Sven
>>> 
>>> * # make clean
>>>   # cd ..
>>>   # tar -czvf tosven.tgz appdir
>>> 
>>
>>the tar command failed - I got a message saying option z 
>>not recognised. So I've attached the necessary files 
>>instead. Hop this works, fingers crossed !
>>It's getting late here and I have to be going...
>>
>>I must say its awfully kind of you to take the time to look 
>>at this.
>>
>>      Zafar
>>
>
Zafar,

it took me a while to work my way through your app, but attached here is a
tarball with the app as I have changed it. Just do 'tar -xvf iqbal.tar'.

Some comments:

a) I had to make some changes just to make the app compile cleanly. In the
future, if you go on the list and ask about the way your app *runs*, we
should be able to assume the app *compiled* cleanly first! Otherwise, fix
the compile problems before posting. 
(I had to #import <math.h> in Agent.m and ModelSwarm.m to get sqrt(). Also
the compiler complained about the variable r in PlotsOfLand:drawSelfOn (it
hides the instance variable r).

b) I added an update to soilGraph and an update to the probe manager to
your displaySchedule in ExperSwarm.

c) To be able to see the graph and raster before the model starts running,
I scheduled a call to displayActions and a call to setStateStopped at start.

d) I moved -checkToStop from ModelSwarm to ExperSwarm so that we could use
[controlPanel setStateStopped] -- then you get to see the state of affairs
when it stops. Also added test for totalSoil < 0 (assuming negative soil
makes little sense ???)

e) The variable 'r' in PlotsOfLand was not set, which means it stayed =
0.0. Hence in -step the deduction from soil comes out to zero every time. I
set it to a small value (e-8) to get some action.

f) The model *appeared* to be doing nothing because each time step takes so
long; on my PII/300 each step takes over 10 minutes. Since you had nothing
displaying until after agent steps, I guess there was nothing to see. On my
computer, I have a little cpu-load-meter going, and it showed the app
suching up all available CPU, so I could tell it was doing SOMETHING.

g) I reduced the number of agents (agentDensity = 0.01) to speed things up,
and discovered that the app aborted. The error message was not helpful, and
the debugger likewise did not help. I located the problem in your creation
of the EZGraph: your code said

        [soilGraph createSequence: "totSoil"
                withFeedFrom: [modelSwarm getPlotList]
                andSelector: M(getTotalSoil) ];

Note that while all the other sequences you can create
(createTotalSequence, createAverageSequence etc.) need their feed from a
list, 'createSequence' needs its feed from some single object. In the above
case, it is modelSwarm itself that answers to getTotalSoil, so the second
line should be 'withFeedFrom: modelSwarm'. 

Or, you could instead do

        [soilGraph createTotalSequence: "totSoil"
                withFeedFrom: [modelSwarm getPlotList]
                andSelector: M(getSoil) ];

Unfortunately, the compiler can't catch this type of error. 

h) The reason your app is so slow to run, is that in the -step method of
each agent, you have loops-within-loops: the outer loop cycles over every
square of the 80x80 world, then an inner loop cycles over the world again
-- hence the innermost code executes over 40 million times for each agent!
Possibly the outer loop is not needed -- especially since you seem to
compute distance from the executing agent to the agent/plot located in the
inner loop ... ?

Anyway, the app now runs and you can get on with your programming.

Good luck,
Sven Thommesen


                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.
                  ==================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]