Short version of the question:
Is there any way to make a picturebox control 15,000 pixels square or bigger? Do I just need to have vb allocate more memory or are there some fundamental limitations to doing this? Given the longer explanation below, is there a better or faster way to store and access the data I need?
Why would anyone need a picturebox that big? Well, I'm building a model of how army ants swarm for part of my PhD. These ants are blind and find their way around by leaving trails made out of chemicals called “pheromones”. The ants swarm 100 meters or more in a day and they move around on a 1mm scale so this makes a lot of numbers to be tracked. Basic model is this: each ant samples the “pheromone” values from the area in front of it with its antennae, it moves, then it increments the value of the “pheromone” at its new location. Pretty simple except for the huge scale. (More background if you’re interested at: http://www.infiniteworld.org/research/research.htm
More detailed explanation of the problem(s):
1) Pheromone map: I'd like to be able to create an array of about 225 million integer values (i.e. that’s the size of an area of 15,000 x 15,000) that can be quickly accessed with x/y coordinates. That is, an ant at a given x/y position needs to be able to get the value of the point where it is and leave a new value at a nearby point (and maybe a few adjacent points). If it makes any difference, the data will be mostly zeros. Since 200 million 2byte integers is only about 425 MB of memory it doesn’t seem unreasonable that this could be done somehow.
2) Plotting and Zooming: To be able to debug the program, I need to be able to see what the ants are seeing by quickly plotting a visual representation of this data to the screen and to be able to "zoom in" to smaller sections of the ant-world and see the pheromone map and ants there. This means that some (possibly lower resolution) version of the pheromone has to be stored as an image.
3) Time constraint: Ideally a single loop of 4000 or so ants would take less than 30millisec since that would be "realtime" for the model, i.e. the model needs to run for a few hours in "ant time" and the model time step is 1/30 of a second so loop times longer than 30msec would make models runs take hours.
Things I’ve tried:
Change scalemode -- In a previous version I was just setting the “scalemode” to whatever width I wanted but I’m pretty sure VB only tracks color at the pixel scale so that doesn’t work <-- Anyone know this for sure?
Scaling the picturebox to worldsize -- The simplest solution seemed to be to have the ants leave their "pheromone" as a change to color in a PictureBox Control since that way I can just look at the image to see what's going on, and the ant can just sample the x/y value of where it is and increment the color values to add pheromone. But making pictureboxes more than 4000 pixels wide gives the dreaded “Error ‘480’ - Can’t create AutoRedraw” memory failure. <-- Is there an easy API way to allocate more memory; will VB try and make it as one consecutive chunk and crash?
A solution that kind of worked: The ants store their pheromone values in a set of arrays (which have to be allocated in smaller chunks to prevent problems with oversized blocks of memory) and then have them also leave their pheromone value on a small picture box just for the visual representation (since the picture only has to be visually accurate, not numerically accurate).
So, the main questions:
1) Can this be done using picture boxes? (So far I’m not sure if it isn’t working because of basic limitation of VB or just because of memory allocation problems that could be fixed)
2) Is there a better or faster way?
This is a big question, so I’m mainly looking for semi-specific suggestions of directions to take and answers to the last two questions.