[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Swarm-Support] Re: integers
From: |
Paul Johnson |
Subject: |
[Swarm-Support] Re: integers |
Date: |
Wed, 07 Feb 2007 12:39:46 -0600 |
User-agent: |
Thunderbird 1.5.0.9 (X11/20070130) |
Luke Premo wrote:
Paul,
thanks for the response. i actually thought about going that route,
but i was sure there was some way to get integers in lists or arrays.
but now that you have cleared that misconception up for me, i will go
the route of making integer classes.
thanks for the help. i'll let the support list know how it works out.
Luke
The alternative to a list is to just approach this as a C problem with
an array of fixed length. In the artificial stock market model, I found
that they had used C bitmath to pack a great deal of information into
integers. Consider an integer that has 8 bits, for example.
01011111
If you break that down and think of the first pair as one setting, and
the second pair as another setting, and so forth, then you have very
compact storage. You could, for example, let 00 represent the value
"0", while 01 could be "1" and 10 could be -1 and 11 could be
"unknown". I'm a political scientist by training and it took me a while
to wrap my brain around the bit math, and I think I would have to think
hard to remember how to do it, but it is very efficient storage and made
for some fast calculations. I wrote down a lot of comments in the
source for the revised version so maybe you can figure it out. You can
read the ASM sourcecode if you want--either read the original ASM or the
one where I tried to clean it up and make it a bit more object oriented
by putting in a class "BitVector.
This presupposes you really do have a relatively finite, fixed 'bit
string' to keep track of, rather than something that can grow and shrink
indefinitely. There is a certain slowdown involved in creating
Integers, putting them in lists, getting Integer objects out, getting
values from there, and so forth.
I often wondered if there is speedup involved if you make an instance
variable public and then get the value out with the -> operator rather
than doing the Objective-C thing [x getValue]. If you find out, let me
know. In the ASM, they make a great deal of use of the -> operator to
exchange values, and I had been given the advice that doing so is not
really as "object oriented" as we might like. But, the more time goes
on, I recognize evaluations like that as more-or-less matters of taste
(or religion) rather than rules we have to follow.
--
Paul E. Johnson email: address@hidden
Professor, Political Science http://pj.freefaculty.org
1541 Lilac Lane, Rm 504
University of Kansas Office: (785) 864-9086
Lawrence, Kansas 66044-3177 FAX: (785) 864-5700
- [Swarm-Support] Re: integers,
Paul Johnson <=