Loading in 2 Seconds...

XL as an extension of the L-system formalism Tutorial "The language XL and the platform GroIMP as tools in plant mo

Loading in 2 Seconds...

- By
**lotus** - Follow User

- 281 Views
- Uploaded on

Download Presentation
## XL as an extension of the L-system formalism Tutorial "The language XL and the platform GroIMP as tools in plant mo

**An Image/Link below is provided (as is) to download presentation**

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

XL as an extension of the L-system formalism

Tutorial "The language XL and the platform GroIMP as tools in plant modelling", Cottbus, December 19-20, 2007

Winfried Kurth Ole Kniemeyer

Reinhard Hemmerling Gerhard Buck-Sorlin

Chair for Graphics Systems, BTU Cottbus

- object-oriented programming (Java)
- imperative programming (Java)
- rule-based programming (L-systems, graph grammars)
- chemical programming

- object-oriented programming (Java)
- imperative programming (Java)
- rule-based programming (L-systems, graph grammars)
- chemical programming

Rule-based programming(van Wijngaarden, Lindenmayer)

Computer = transformation machine for structures (or for states).

There exists always a current structure, which is transformed as long as possible.

Working process: Search and application.matching: search for a rule which is applicable to the current structure,

rewriting: application of the rule in order to rewrite the current structure.

programme = a set of transformation rules.

finding a programme: specification of the rules.

programming languages: Prolog, L-system languages, Intran

Lindenmayer-Systems (L-Systems)

- named after Aristid Lindenmayer

(Dutch-Hungarian biologist, 1925-1989)

- Data structure and language inseparably connected to each

other

- Data structure is a sequence of (parameterized) symbols,

e.g.: F(1) [ + A(1) ] [ - A(1) ]

- Every L-system consists of:
- an alphabet (a set of symbols)
- a start word (axiom) (in XL: Axiom)
- a set of replacement rules (applied in parallel to the

developing string), e.g.:

A(x) ==> F(x/2) [ + A(x/2) ] [ - A(x/2) ]

Turtle commands (imperative programming style)

F0 "Forward", including construction of a cylinder,

uses the current step width for length

(the zero stands for "no explicit specification of length")

M0 forward without construction (Move command)

L(x) change the current step width (length) to x

LAdd(x) increment the current step width by x

LMul(x) multiply the current step width by x

D(x), DAdd(x), DMul(x) analogously for current

thickness

RU(45) Rotation of the turtle around "up" axis by 45°

RL(...), RH(...) analogously around "left" and "head" axis

up-, left- and head axis form an orthogonal, spatial coordinate system, which is always associated with the turtle

RV(x) Rotation "downwards" with a strength specified by x

L(100) D(3) RU(-90) F(50) RU(90) M0 RU(90) D(10) F0 F0

D(3) RU(90) F0 F0 RU(90) F(150) RU(90) F(140) RU(90)

M(30) F(30) M(30) F(30) RU(120) M0 Sphere(15)

generates

what is the result of the interpretation of the string

L(10) F0 RU(45) F0 RU(45) LMul(0.5) F0 M0 F0?

Repetition of parts of the command string with the keyword "for"

e.g. for ((1:3)) ( A B C )

yields A B C A B C A B C

what is the result of the interpretation of

L(10) for ((1:6))

( F0 RU(90) LMul(0.8) ) ?

Branching: realization with stack commands

[ put current turtle state on stack ("push")

] take current state from stack ("pop") and let this state be the current turtle state (this means: end of the branch, continue with main stem)

Example of interpreted L-system:

rules

A ==> F0 [ RU(45) B ] A ;

B ==> F0 B ;

start word (axiom) L(10)A

(A and B are normally not interpreted geometrically.)

what a structure is the result of the following L-system

A ==> [ LMul(0.25) RU(-45) F0 ] F0 B;

B ==> [ LMul(0.25) RU(45) F0 ] F0 A;

with start wordL(10)A ?

what a structure is the result of the following L-system

A ==> [ LMul(0.25) RU(-45) F0 ] F0 B;

B ==> [ LMul(0.25) RU(45) F0 ] F0 A;

with start wordL(10)A ?

equivalent rule:

A ==> [ LMul(0.25) RU(-45) F0 ] F0 RH(180) A;

module R extends RU(-45); /* inheritance */

module A extends F(10);

Axiom ==> L(100) R X R A R X;

X ==> X F0 X R A R X F0 X;

Branching, alternating phyllotaxy and shortening of branches:

Axiom ==> L(10) F0 A ;

A ==> LMul(0.5) [ RU(90) F0 ] F0 RH(180) A ;

Axiom ==> F(10) A ;

A ==> [ RU(-60) F(6) RH(180) A Sphere(3) ]

[ RU(40) F(10) RH(180) A Sphere(3) ];

Sphere ==> Z; ?

(F(n) yields line of the given length n,

Sphere(n)a sphere with radius n)

using pseudo-random numbers

example:

deterministic stochastic

float c = 0.7;

Axiom ==>

L(100) D(5) A;

A ==> F0 LMul(c) DMul(c)

[ RU(50) A ] [ RU(-10) A ];

float c = 0.7;

Axiom ==>

L(100) D(5) A;

A ==> F0 LMul(c) DMul(c)

if (probability(0.5))

( [ RU(50) A ] [ RU(-10) A ] )

else

( [ RU(-50) A ] [ RU(10) A ] );

Generating a random distribution on a plane:

Axiom ==> D(0.5) for ((1:300))

( [ Translate(random(0, 100), random(0, 100), 0)

F(random(5, 30)) ] );

view from above oblique view

Which structure is generated by the following L-system?

Axiom==> [ RU(90) M(1) RU(90) A(1) ] A(1);

A(n) ==> F(n) RU(90) A(n+1);

variant: replace "RU(90)" in the second rule by "RU(92)"

Query for a context which must be present in order for a rule to be applicable

Specification of the context in (* .... *)

example:

module A(int age);

module B(super.length, super.color) extends F(length, 3, color);

Axiom ==> A(0);

A(t), (t < 5) ==> B(10, 2) A(t+1);

A(t), (t == 5) ==> B(10, 4);

B(s, 2) (* B(r, 4) *) ==> B(s, 4);

B(s, 4) ==> B(s, 3) [ RH(random(0, 360)) RU(30) F(30, 1, 14) ];

Rewriting of graphs instead of strings

(strings remain a special case)

Relational growth grammars (RGG): parallel graph grammars with a special graph model

(see Ole's dissertation for mathematical foundations)

"relational": different edge types of the graph can stand for different relations

the connection of the inserted right-hand side with the rest of the graph

("embedding")

XL offers 3 standard types of rules with different solutions for embedding:

L ==> R L-system rules: embedding made

compatible with L-systems

L ==>> R SPO rules (single pushout rules, from

algebraic graph grammar theory):

after insertion, "dangling edges" are removed

L ::> C execution rules: no change of the graph

topology at all, only parameters are changed

(C: command sequence, imperative)

signal in the network:

XL representation:

(* Cell(1) *) c:Cell(0) ::> c[state] := 1;

Extended L-Systems (XL)

Example for execution rules

given: a graph with cycles

static Cell* context(Cell c1)

{

yield (* c2:Cell, ((c2 != c1) && (c2.distanceLinf(c1) < 1.1)) *);

}

public void transition()

[

x:Cell(1), (!(sum(context(x)[state]) in (2 : 3))) ::> x[state] := 0;

x:Cell(0), (sum(context(x)[state]) == 3) ::> x[state] := 1;

]

Extended L-Systems (XL)

The Game of Life

global sensitivity, graph queries

- Example: growth takes place only when there is enough distance to the next object in space
- module A(int s);
- Axiom ==> F(100) [ RU(-30) A(70) ] RU(30) A(100);
- a:A(s) ==> if ( forall(distance(a, (* F *)) > 60) )
- ( RH(180) F(s) [ RU(-30) A(70) ] RU(30) A(100) )
- without the condition with the condition

Insertion of an extra rule application immediately before graphical interpretation takes place (without effect on the next generation)

application of interpretive rules

Turtle interpretation

Example:

public void run()

{[

Axiom ==> A;

A ==> Scale(0.3333) for (i:(-1:1))

for (j:(-1:1))

if ((i+1)*(j+1) != 1)

( [ Translate(i, j, 0) A ] );

]

applyInterpretation();

}

public void interpret()

[

A ==> Box;

]

{[

Axiom ==> A;

A ==> Scale(0.3333) for (i:(-1:1))

for (j:(-1:1))

if ((i+1)*(j+1) != 1)

( [ Translate(i, j, 0) A ] );

]

applyInterpretation();

}

public void interpret()

[

A ==> Box;

]

(a)

(b)

(c)

A ==> Box(0.1, 0.5, 0.1)

Translate(0.1, 0.25, 0) Sphere(0.2);

A ==> Sphere(0.5);

what will be generated by this example?

public void run()

{

[

Axiom ==> [ A(0, 0.5) D(0.7) F(60) ] A(0, 6) F(100);

A(t, speed) ==> A(t+1, speed);

]

applyInterpretation();

}

public void interpret()

[

A(t, speed) ==> RU(speed*t);

]

Track

Switch

Train

Excerpt of the data

structure: Train standing

before a switch

Extended L-Systems (XL)

simple example: railway simulation

Extended L-Systems (XL)

simple example: railway simulation

Rule 1

r1:Rail[t:Train] r2:Rail ==>> r1 r2[t];

r:Rail[t:Train] s:Switch[r2:Rail] r1:Rail ==>> r s[r1[t]] r2;

20 65 68 46 74 53* 22 35 42 21

Concentration: 1 / 10

20 65 68 46 74 53* 22 35 21 2*

Concentration: 2 / 10

65 53* 35 21 2* 10 34 23* 37* 11*

Concentration: 5 / 10

65 53* 35 21 2* 23* 37* 11* 5* 17*

Concentration: 7 / 10

53* 21 2* 23* 37* 11* 5* 17* 13* 7*

Concentration: 9 / 10

53* 2* 23* 37* 11* 5* 17* 13* 7* 3*

Concentration: 10 / 10

Rule:

int

int

a divides b

int

int

a

b

a

b/a

Extended L-Systems (XL)

Artificial Chemistry: Prime number generator

A multiset of random integers reacts according to the following rule, thereby distilling prime numbers.

b:int, (* a:int *), (a != b && (b % a) == 0) ==> `b / a`;

A herbivore model

Model of a tree population being grazed upon by phytophagous animals.

- Plants with two parameters: age t and radius r, represented

by circles of radius r (proportional to energy budget of plant).

- Plants reproduce through seed
- at a certain age and
- above a certain energy (radius) threshold (number of offspring = f(r)).
- Plant dies when
- it has reached maximum age or
- when its energy budget is exhausted (r<0).
- If plant does not die it grows by fixed amount at each time step
- Animals with two parameters: age t and energy budget e,

represented by small circles.

- While not in contact with a plant (i. e. within its radius): animal moves

and consumes fixed amount of its stored energy.

- When in contact with a plant: animal’s radius of movement decreased,

starts "grazing"

behaviour of animals

/* phytophag.rgg: specification of a grazing and competition model

with circular-shaped plants and animals */

module Plant(int t, super.radius) extends Cylinder(1, radius)

{{setColor(0x00aa00);}}

module Animal(int t, super.radius) extends Cylinder(2, radius)

{{setColor(0xff0000); setBaseOpen(true); setTopOpen(true);}};

double pgrow = 0.9; /* regular growth increment per timestep */

double seed_rad = 0.1;/* initial radius of a plant */

int pmaxage = 30; /* maximal age of a plant */

int pgenage1 = 10; /* first reproductive age level */

int pgenage2 = 18; /* second reproductive age level */

double distmin = 15; /* minimal seed distance */

double distmax = 40; /* maximal seed distance */

double pminrad = 9; /* necessary plant radius for reproduction */

double pgenfac = 0.5; /* ratio #seeds/radius */

int lag = 15; /* sleeping time for animal at start */

double shortstep = 0.4;/* movement of animals inside plant canopy */

double longstep = 15; /* movement of animals outside */

double f_e = 0.2; /* ratio radius / energy of animals */

double init_e = 4; /* initial energy amount of animals */

double respi = 0.25; /* energy cosumed by animals' respiration */

double thr = 7.6; /* energy threshold for reproduction

of animals */

double eat = 1.1; /* energy transferred during grazing */

{

extent().setDerivationMode(PARALLEL_MODE | EXCLUDE_DELETED_FLAG);

[

Axiom ==> Plant(0, seed_rad) [ RH(random(0, 360))

RU(90) M(10) RU(-90) Animal(-lag, f_e*init_e) ];

]

}

public void make()

{ growAnimals(); passBoundary(); growPlants(); }

public void growAnimals()

[

Animal(t, e), (t < 0) ==> Animal(t+1, e); /* start lag */

Animal(t, e), (e <= 0) ==> ;

Animal(t, e), (e > f_e*thr) ==>

[ RH(random(0, 360)) RU(90) M(shortstep) RU(-90)

Animal(0, e/2 - f_e*respi) ]

RH(random(0, 360)) RU(90) M(shortstep) RU(-90)

Animal(0, e/2 - f_e*respi);

a:Animal(t, e), (* p:Plant(u, r) *),

(distance(a, p) < p[radius]) ==>

RH(random(0, 360)) RU(90) M(shortstep) RU(-90)

Animal(t+1, e + f_e*eat - f_e*respi) { p[radius] :-= eat; };

Animal(t, e) ==>

RH(random(0, 360)) RU(90) M(longstep) RU(-90)

Animal(t+1, e - f_e*respi);

]

[

Plant(t, r), (t > pmaxage) ==> ;

Plant(t, r), (r < 0) ==> ;

p:Plant, (* q:Plant *), (distance(p, q) < q[radius]

&& p[radius] <= q[radius]) ==> ;

Plant(t, r), ((t == pgenage1 || t == pgenage2) && r >= pminrad)

==> for ((1 : (int) (pgenfac*r)))

( [ RH(random(0, 360)) RU(90) M(random(distmin, distmax))

RU(-90) Plant(0, seed_rad) ] )

Plant(t+1, r);

Plant(t, r) ==> Plant(t+1, r+pgrow);

]

Download Presentation

Connecting to Server..