import fileinput
lines = []
# append each line to a list
for l in fileinput.input([filename]):
lines.append(l)for i in range(len(lines)):
string = lines[i]
words = []
words = string.split(“,”)
November 28, 2008
Thursday: code …
November 24, 2008
November 23, 2008
Sunday: more area …
See http://www.mathwords.com/a/area_convex_polygon.htm and http://mathworld.wolfram.com/PolygonArea.html for details on calculating area from coordinates.
2 issues remain:
- - how to order the coordinates in a counter clockwise fashiong, for the above formula
- - how to calc. the correct area — i.e. the minimum available
Now something like convex or concave hull approach looks like a reasonable method to calculate the points that I am interested in using to calculate the area of the flock. Graham’s scan seems to be a reasonable method to calculate the convex hull: http://code.activestate.com/recipes/117225/ — plus may show how to sort the coordinates also.
These links may be useful: sorting vertices (http://www10.dcccafe.com/ng/article.php?id=128730&group=comp.graphics.algorithms) and areas of polygons (http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/).
November 20, 2008
Thursday: principle component analysis + links ….
Calculating the area and centroid of a polygon – http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/
November 19, 2008
Wednesday: breaking Excel …
Okay, things we have learnt today: Excel doesn’t like big array calculations. A good way to break it, it seems.
Still trying to work out a good way to measure the density of boids. Now, density = number / area. The number of birds in the simulation will remain the same. And the area of the simulation will remain same, e.g. 800W x 600H, assuming non-toroidal environment. However, area that the birds exist in will change. Therefore, plan is to:
- identify min X, min Y, max X, max Y and respective coordinates
- this 4-sided polygon should contain all other coordinates
- apply Surveyor’s formula to work out the area that all coordinates are within. See http://www.codeproject.com/KB/scripting/SurveyorsFormula.aspx
- calculate density using newly calculated area.
There could be issues with this approach, but will need external guidance to see if there is a horrific mistake somewhere.
November 17, 2008
Monday: thinking about density …
Did some playing around with sim. to generate data. Have reached out to Statistics Support func. @ Rdg to get some support — e.g. how to show effect, etc.
There are 5 characteristics of animal aggregations. How can each one be measured?:
- edges: require a definition of an edge, or a way to measure “edg-i-ness”
- uniform density: divide entire area that 2D flock is in, into quadrants. How does the density of each quadrant compare.
- polarisation: evaluate the polarisation of flock members. How similar are the polarisations?
- freedome to move within own volume: considered less of a continuous measurement, more of a binary yes/no
- coordinated movement: is this derived from polarisation over time?
So 2 things appear to be relatively straight forward to measure. Let’s start with those.
splines b splines, supoort vector machines* – lo # birds define support vector with few birds near it => unclear edge. Looked at SVM — understand what’s going on, not sure how to apply currently.
Unit testing in Python
- animal behaviour: how to inhibit flocking ability of birds? E.g. cf. severing lateral line of fish
How to measure density
- split area into grids
- in the non-empty areas, how many boids are in them
November 13, 2008
Thursday: reading and thinking …
Today trying to turn Parrish’s aggregation characteristics into quantities — let’s try and quantify a flock. Here’s the literature found:
- Quera V, Herrando S, Beltran FS, Salas L, Miñano M.An index for quantifying flocking behavior.Percept Mot Skills. 2007 Dec;105(3 Pt 1):977-87. (Not available online)
- NB Look at Hamilton’s selfish herd theory
- went through who cited Parrish’s book, to see if anything interesting appears …
- Optimal group positioning after a predator attack: the influence of speed, sex, and satiation within mobile whirligig swarms. Behavioral Ecology. 19(2):338-343, March/April 2008. Romey, William L. a; Galbraith, Emily b http://pt.wkhealth.com/pt/re/beec/pdfhandler.00008874-200803000-00015.pdf;jsessionid=JbfQy1bJkYgp2KN4FYSTNnMKrQhVTpMQg4nGB40L7WRphGNrXQD3!-1327505820!181195628!8091!-1
- EcoPS: a particle swarm algorithm to model group-foraging Genetic And Evolutionary Computation Conference archive Proceedings of the 9th annual conference on Genetic and evolutionary computation table of contents, Pages: 230 – 237, 2007, Cecilia Di Chio, Riccardo Poli, Paolo Di Chio http://portal.acm.org/ft_gateway.cfm?id=1277008&type=pdf&coll=GUIDE&dl=GUIDE&CFID=10590143&CFTOKEN=20400888
- Mathematical models of swarming and social aggregation Leah Edelstein-Keshet http://www.math.ubc.ca/people/faculty/keshet/pubs/nolta2001.pdf
- Alignment in a fish school: a mixed Lagrangian–Eulerian approach M. Adioui, J. P. Treuil and O. Arino
- Complexity, Pattern, and Evolutionary Trade-Offs in Animal Aggregation Julia K. Parrish, Leah Edelstein-Keshet
- Optimal individual positions within animal groups. L. J. Morrell and W. L. Romey (2008) Behav. Ecol. 19, 909-919
- not of apparent relevance:
- Modeling Self-Organized Aggregation in a Swarm of Miniature Robots Nikolaus Correll and Alcherio Martinoli — don’t this is of relevance
- Complexity, robustness, self-organization, swarms, and system thermodynamics Haddad, W.M. Qing Hui
November 10, 2008
Mo.: debugging ….
Finished going through the code: there are 7 variables to play with.
Wonder if an Excel model / Freemat model could be used to better iterate through everything ….?
November 6, 2008
Thursday: debugging …
Running boids code found on www through Eclipse debugger, to understand what’s happening.
V. impressed with Pydev debugger in Eclipse — float over of vars to directly interogate would be nice, but what is there is cool.
I want another screen though!!!