MakerLab Blog » code http://blog.makerlab.com Go on, be curious Thu, 14 Mar 2013 06:30:21 +0000 en-US hourly 1 http://wordpress.org/?v=3.9.15 Riffing on modeling ecosystems http://blog.makerlab.com/2009/01/riffing-on-modeling-ecosystems/ http://blog.makerlab.com/2009/01/riffing-on-modeling-ecosystems/#comments Sat, 03 Jan 2009 02:10:52 +0000 http://blog.makerlab.com/?p=523 How can we build tools that help people make better decisions about the kind of large scale civic planning issues that affect them and their communities?

Over the last week I had a chance to do some more thinking on the issue and did code tests to build small implementation sketches.  I’ve recruited Mikel‘s assistance and grabbed http://openecosim.org – which has nothing on it yet but will hopefully have something soon.  As usual I like to use the praxis of spending half the time on thinking and half the time on actual test code.

The Thinking Part

To use the hoary old example I usually pull out: consider a decision to cut an old growth forest.  There are ownership issues, watershed buffer issues, true cost issues, longer terms repercussions and non-obvious vested interests. Sometimes we arrive at conclusions through force of will rather than through an an audit of our actual group understanding. There’s an unbounded rationalism fueled by a kind of technoglossia babble speak that doesn’t really bring grounded interests to the table.  It leads to a kind of Monsanto-ish approach to problem solving; using bigger sledge-hammers, spending down natural resources, and kind of “cashing out” on the present at the cost of the future.  Basically it is a kind of naivete conflated with power.

To use another example – just today there was a great link posted to geowanking.org on the “The Venus Project”:

Here the authors present a vision of a future city; one that is optimized using the best technology – where buildings are built more cheaply and goods and services can be moved around more cheaply – all to the totem of consumption.

Although framed as a utopia it’s completely dystopic – humans couldn’t walk these broad boulevards; and humans couldn’t maintain the buildings themselves without access to some kind of corporate sponsored machinery.  It shows how inhuman design can be; how the pursuit of efficiency can let people rationalize things that are horrific.  Especially amusing is that anything that they built would be obsolete by the time it was done.

I pretty much need to just include Paul Ramsey‘s comments here because he succinctly makes very point that underscores the problem with a kind of Ayn Rand rationalism unchained:

That’s hilarious! A modern vision of the future (the video is (c)
2006), that looks basically like Disney’s tomorrow-land.  It makes
sense that the ideas in the video are so shopworn — the guy behind it
is 92 years old! <http://en.wikipedia.org/wiki/Jacque_Fresco>

For precursors to this silly stuff, see the works of Corbusier
<http://en.wikipedia.org/wiki/Le_Corbusier>. He died in 1965, but was
pushing his “Contemporary City”
<http://en.wikipedia.org/wiki/Ville_Contemporaine> basically his whole life.  Like the lunacy in the video, it envisioned a “from scratch”
city, though Corbu was crazy enough to propose bulldozing much of
Paris (Paris!!!!) to make room for his new design.  A good deal of the
“urban renewal” schemes <http://en.wikipedia.org/wiki/Urban_renewal> of the 50s and 60s were based on the urban design ideas presented in the video (get rid of “inefficient” old urban fabric, replace with new vertical, efficiently-built fabric) and boy, that turned out great.

Some folks were so taken in by the modernist urban concept, they
actually followed up on it. The capital of Brazil, Brasilia,
<http://en.wikipedia.org/wiki/Brasilia> is designed on a circular
plan, with strict separation of uses (work here, live there, play over
there). Like Corbusier’s design, it is optimized for non-human
variables, things like transportation efficiency and separated land
use.  It too pre-dates this video by decades.  I has a lot of
modernist masterpieces, set (of course) in solitude in vast parking
lots, away from distracting, messy people.

There is a satellite development of Rome, EUR, planned by Mussolini,
that had similar “from scratch” modernist design pretensions, and it
too is a bit of a wasteland.
<http://en.wikipedia.org/wiki/Esposizione_Universale_Roma>

Jane Jacobs <http://en.wikipedia.org/wiki/Jane_Jacobs> wrote a couple good books about how *people* use urban spaces, which are good primer for understanding why “from scratch” cities just won’t ever work: “The Death and Life of Great American Cities” and “The Economy of Cities”.

I remain blown away by that video, truly, it’s like a time-warp –
better life through engineering.  It’s true though, as the video says,
that having a vision of the future is helpful if you want to maintain
consistent progress towards betterment (assuming your vision is
actually “better”). However, if I were to import and reuse an “vision
of the future from the past”, I’d choose Callenbach’s “Ecotopia”
<http://en.wikipedia.org/wiki/Ecotopia> over this tomorrow-land stuff
any day.

Sometimes seeing nightmarish design like this creates uncertainty and doubt over ever actually doing a better job.  If people put so much thought into such mediocre products; then how could we dare do any better? But I think there’s a convergence that happens.  And I think we just have to have the hubris to assume that we are slightly less stupid – having seen their mistakes?

I wouldn’t really try do a clean slate approach; there’s so much richness in what is there and so much could be tuned and reclaimed…  As a thought exercise it could be interesting but I actually like the organically driven approach; seeded by people’s habits – even say for a moon city – an organic approach would be most human.

If I was going to try something like this I’d build on the idea of “place making” and working landscapes: http://www.amazon.com/Working-Landscape-Preservation-Industrial-Environments/dp/026203364X .  Yes some kind of specialization is good: you do want high density urban areas which may not be farmable in order to have enough people in one place that they can actually talk and explore new ideas more quickly.  But for me a new style city would be mixed use; mixing light industry, residential, agricultural and the like; in some parts tending more towards being like a forest with homes tucked away within it.  I’d model it by flowing people through it; playing with different demographics, different age groups, and I’d try score different city models by how well they satisfied needs of diverse populations; aged, young, entrepreneurial and the like. I’d score it against real world feedback and I’d look at ancient city patterns for ideas. Also I’d probably look more at the laws – like get rid of most of them and put in edicts that for any new law added you had to remove two others.  Ownership, fences and land use laws in general create a lot of needless annoyance. I’d ask how we could recolonize existing urban areas away from bad zoning. Then I’d look at technology specialization; half of all cities are basically paved flat dead; there has to be a way to reclaim some of that – it sounds silly but I think we’re almost at the age where power density is high enough that we could have ourselves some flying cars (or at least things that could hop from point to point); and perhaps funding that could be useful.

The Code Part

The proposition to simulate ecosystems seems to best be modeled using a cellular automata approach.  But since these terrains can be so large – and so self-similar – some kind of sparse matrix or spatial compression technique seems to be required.  There has to be some kind of trade-off between performance ( being able to index each cell in linear time and in as few clock cycles as possible ) and scaleability ( being able to manage large datasets ).

I also wanted to use a language that is easy for others to use.  Java seems to be the obvious language of choice – the guy who wrote it is basically wanted to avoid any complex features.  However there are some very serious language defects.  The most serious is that since memory can’t be managed directly, it becomes very hard to build efficient sparse matrix implementations ( which would be required for performance ).  This however can be circumvented by using tools like MTJ :

So Java can be used; and in general I think I’ll stay in the family of languages that are Java like at least – such as perhaps C# (which has better direct memory management support).

However – aside from an industrial strength implementation – what I want as a first step is something that is more of a thumbnail sketch and something that other people can play with as well.

Processing is a nice Java based framework that seems to meet the criteria. One key choice for a processing based approach was to literally just use images as the cellular automata layers. This throws away the sparse matrix approach for now but gives us something we can play-test faster.

This brings us to the actual data models. I am thinking that I would have a base concept of a “feature” – and that I would distinguish (in code) between a concept of a “layer” and a concept of a “relation”.  Layers would embody the state of the world, such as soil, water, elevation, water temperature, air temperature, suspensions in water and the like – and relations would specify how layers act on each other.  A water and soil relationship would be one that computes forward how water acts on soil and visa versa given gravity, sunlight, evaporation, humidity, rain, erosion, compactness, geography and other factors.

Overall I think the next steps now will be to take the rough draft and actually try simulate some behavior across it. I’d like to just be able to simulate land, waterfall and water flow.

I don’t like to speculate too far ahead but I do think that when it comes time to simulate salmon or living creatures that I am going to simulate them using “stand in’s” where I have just a few – on the order of 1/10000th as many as truly exist – and simply have their effects be magnified. The reasoning here is that if I build a 3d interactive simulation of the environment I’d like to let a kid (or an adult) actually follow a single salmon through it’s entire life cycle – to personalize the simulation a bit.

Below I’ve included the small code test that I wrote – this doesn’t do much yet. There’s no real conclusion yet because this is a work in progress – I simply wanted to share some of the thinking I’ve been doing.

class Feature {
  public String name;
  public String get_name() { return name; }
  public Feature set_name(String name) { this.name = name; return this; }
  public Feature() {}
  public Feature(String name) {
    set_name(name);
  }
}

class Layer extends Feature {
  public Layer set_name(String name) { this.name = name; return this; }
  public PImage image;
  public Layer load(String filename) {
    image = loadImage(filename);
    return this;
  }
}

class Relation extends Feature {
  public Relation set_name(String name) { this.name = name; return this; }
  public void eval(int seconds) {}
}

class SoilWindWater extends Relation {
  public void eval(int seconds) {
	//	
	// for just this cell
	// or for all cells 
	//	 a = a.get(x,y);
	//   b = b.get(x,y);
	//	 - decide on time of day
	//   - set soil stuff
	//	 - set wind
	//	 - set water
	//   a.set(x,y) = a;
	//   b.set(x,y) = b;
	//   could set points around this one too
	//
  }
  public SoilWindWater set_name(String name) { this.name = name; return this; }
  public Layer soil;
  public Layer water;
  public SoilWindWater set_soil(Feature soil) { this.soil = (Layer)soil; return this; }
  public SoilWindWater set_water(Feature water) { this.water = (Layer)water; return this; }
}

class WaterSalmon extends Relation {
  public void eval(int seconds) {
	// perhaps just for cells with salmon
	// evaluate impacts
	// need to model time of year
	// need to model salmon run points; layer needs an idea of 'home'?
	// or we can have another concept of spawning grounds that we can supply
	// or salmon could find their way back by smell?
	// or?
  }
}

class World {
  Feature features[];
  public World() {}
  public void sample() {
    features = new Feature[6];
    features[0] = (new Layer()).set_name("soil").load("soil.png");
    features[1] = (new Layer()).set_name("water").load("water.png");
    features[2] = (new Layer()).set_name("wind");
    features[3] = (new Layer()).set_name("salmon");
    features[4] = (new SoilWindWater()).set_name("soilwindwater").set_soil(features[0]).set_water(features[1]); // xxx be explicit or use detection?
    features[5] = (new WaterSalmon()).set_name("watersalmon");
  }
}

World world = new World();

void setup() {
  size(512, 512);
  world.sample();
  noLoop();
}

void draw() {
  Layer water = (Layer)world.features[1];
  image(water.image, 0, 0); 
  // now with a scaffolding up - the next step would be to actually do something!
}
]]>
http://blog.makerlab.com/2009/01/riffing-on-modeling-ecosystems/feed/ 0