Jon’s PhD Journal

November 28, 2008

Thursday: code …

Filed under: Notes — JDE @ 12:33 am

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 24, 2008

Monday: saving images from Python …

Filed under: Notes — JDE @ 7:53 pm

November 23, 2008

Sunday: more area …

Filed under: Notes — JDE @ 11:43 pm

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 ….

Filed under: Notes — JDE @ 9:39 pm

Calculating the area and centroid of a polygon – http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/

November 19, 2008

Wednesday: breaking Excel …

Filed under: Notes — JDE @ 7:56 pm

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 …

Filed under: Notes — JDE @ 7:48 pm

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 …

Filed under: Notes — JDE @ 9:48 am

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 …
  • 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 ….

Filed under: Notes — JDE @ 7:59 pm

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 …

Filed under: Notes — JDE @ 7:24 pm

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!!!

Blog at WordPress.com.