XL as an extension of the L-system formalism Tutorial "Modelling Plants with GroIMP", Cottbus, March 11-12, 2008 Winfried Kurth Ole Kniemeyer Reinhard.

Slides:



Advertisements
Similar presentations
Jason Stredwick, MSU 2004 L-Systems Lindenmayer Systems algorithmicbotany.org.
Advertisements

C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
Chapter 2: Using Objects Part 1. To learn about variables To understand the concepts of classes and objects To be able to call methods To learn about.
ATEC Procedural Animation Introduction to Procedural Methods in 3D Computer Animation Dr. Midori Kitagawa.
L-System Aristid Lindenmayer (1968), biologist. L-System A method of constructing a FRACTAL that is also a MODEL for plant growth. The Computational Beauty.
Instruction Set Architecture & Design
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Defining practical programming languages Carlos Varela RPI.
L-systems Presented by Luv Kohli COMP258 October 30, 2002 Images copyright © 1992 D. Fowler, P. Prusinkiewicz, and J. Battjes.
Procedural Modeling L-Systems Procedural Terrain Procedural Behavior Based on the slides from Spring 2007.
Simulating Trees with Fractals and L-Systems Eric M. Upchurch CS 579.
Fractos ● Is a parser and visualizer for L-Systems ● Objectoriented, C++ ● Uses OpenGL for visualization ● Adopts LinSys3D's syntax ● Allows freely definable.
WSN Simulation Template for OMNeT++
LANGUAGE AND GRAMMARS © University of LiverpoolCOMP 319slide 1.
Synthetic Topiary. Premislaw Prunsinkiewicz (Prof. P) Mark James Radomír Měch.
Functional-Structural Plant Modelling with GroIMP and XL Tutorial and Workshop at Agrocampus Ouest, Angers, 5-7 May, 2015 Winfried Kurth University of.
IlliDOL: A Framework for Exploration of L- Systems in Three Dimensions Vilas Dhar Math 198 Spring 2003.
Summer School „Modelling and Simulation with GroIMP“ / Tutorial for beginners University of Göttingen (Germany), September, 2010 Winfried Kurth Modelling.
Chapter 2 Syntax A language that is simple to parse for the compiler is also simple to parse for the human programmer. N. Wirth.
Dragon Curve Drawn in Project 4… How to generate the string of drawing commands? How does the dragon curve come about? 1.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 7 Mälardalen University 2010.
Summer School „Modelling and Simulation with GroIMP“ / Tutorial for beginners University of Göttingen (Germany), September, 2010 Winfried Kurth Some.
Introduction to Data Structures. Definition Data structure is representation of the logical relationship existing between individual elements of data.
Tutorial „Modelling in the language XL“ University of Göttingen (Germany), September 21/22, 2009 Winfried Kurth Some basic examples in XL (part 1) related.
Modelling of Ecosystems by Tools from Computer Science Summer School at Czech University of Life Sciences, Prague, September, 2013 Winfried Kurth.
Functional-Structural Plant Modelling with GroIMP and XL
Programming Paradigms Procedural Functional Logic Object-Oriented.
L-Systems and Procedural Plants CSE 3541 Matt Boggus.
College of Computer and Information Science, Northeastern UniversityOctober 13, CS U540 Computer Graphics Prof. Harriet Fell Spring 2007 Lecture.
The Artificial Life of Plants Przemyslaw Prusinkiewicz, Mark Hammel, Radom´ır Mˇech Department of Computer Science University of Calgary Calgary, Alberta,
Pushdown Automata (PDAs)
Tutorial and workshop „Modelling with GroIMP and XL“ / Tutorial for beginners University of Göttingen, 27 February, 2012 Winfried Kurth Basic examples.
PART I: overview material
L-Systems Lindenmayer Systems Prusinkiewicz and Lindenmayer
Summer School „Modelling and Simulation with GroIMP“ / Tutorial for beginners University of Göttingen (Germany), September, 2010 Winfried Kurth Some.
Lindenmayer systems Martijn van den Heuvel May 26th, May 26th, 2011.
Evolutionary Robotics Using A Formal Grammar To Evolve Robot Bodies and Brains Hornby, G.S., Pollack, J. (2001) Creating high-level components with a generative.
How to Draw a Tree L-Systems in Computer Graphics Steven Janke.
What does a computer program look like: a general overview.
Summer School „Modelling and Simulation with GroIMP“ / Tutorial for beginners University of Göttingen (Germany), September, 2010 Winfried Kurth Some.
1 10/27/ :26 UML Simplicity in Complexity. 2 10/27/ :26 UML Rewriting Systems Classic Example: Koch 1905 Initiator Generator.
Modelling of Ecosystems by Tools from Computer Science Summer School at Czech University of Life Sciences, Prague, September, 2013 Winfried Kurth.
Functional-Structural Plant Modelling with GroIMP and XL Tutorial and Workshop at Agrocampus Ouest, Angers, 5-7 May, 2015 Winfried Kurth University of.
Summer School „Modelling and Simulation with GroIMP“ / Tutorial for beginners University of Göttingen (Germany), September, 2010 Winfried Kurth Some.
Functional-Structural Plant Modelling with GroIMP and XL Tutorial and Workshop at Agrocampus Ouest, Angers, 5-7 May, 2015 Winfried Kurth University of.
Modelling of Ecosystems by Tools from Computer Science Summer School at Czech University of Life Sciences, Prague, September, 2013 Winfried Kurth.
Tutorial and workshop „Modelling with GroIMP and XL“ / Tutorial for beginners University of Göttingen, 27 February, 2012 Winfried Kurth Introduction to.
CPS 506 Comparative Programming Languages Syntax Specification.
LINDFERN Lindenmayer Systems in VPython Nick Langhammer.
Modelling above- and below-ground competition together Winfried Kurth University of Göttingen Chair for Computer Graphics and Ecological Informatics wk.
Graph-oriented modelling of multiscaled dynamical systems with a dynamical structure: Challenges to the "Relational Growth Grammar" approach Winfried Kurth.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
ATEC Procedural Animation Introduction to Procedural Methods in 3D Computer Animation Dr. Midori Kitagawa.
11 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 7 School of Innovation, Design and Engineering Mälardalen University 2012.
Modelling of Ecosystems by Tools from Computer Science Summer School at Czech University of Life Sciences, Prague, September, 2013 Winfried Kurth.
Modelling of Ecosystems by Tools from Computer Science Summer School at Czech University of Life Sciences, Prague, September, 2013 Winfried Kurth.
Tutorial „Modelling in the language XL“ University of Göttingen (Germany), September 21/22, 2009 Winfried Kurth Some basic examples in XL (part 2) related.
Functional-Structural Plant Modelling with GroIMP and XL Tutorial and Workshop at Agrocampus Ouest, Angers, 5-7 May, 2015 Winfried Kurth University of.
1 Section 13.1 Turing Machines A Turing machine (TM) is a simple computer that has an infinite amount of storage in the form of cells on an infinite tape.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
1 Turing Machines and Equivalent Models Section 13.1 Turing Machines.
Experimenting with Grammars to Generate L-Systems – in JFLAP March 31, 2011 Prof. Susan Rodger Computer Science Dept.
Grammars, L-Systems Jim Whitehead UC Santa Cruz School of Engineering courses.soe.ucsc.edu/courses/cmps265/Spring14/01 23 Apr 2014.
Formal Languages, Automata and Models of Computation
G. Pullaiah College of Engineering and Technology
ATCM 3310 Procedural Animation
Turing Machines 2nd 2017 Lecture 9.
Chapter 9 TURING MACHINES.
Interpretive rules and instantiation rules
Trees and Colored Edge Detection
Java Programming Function Introduction
Presentation transcript:

XL as an extension of the L-system formalism Tutorial "Modelling Plants with GroIMP", Cottbus, March 11-12, 2008 Winfried Kurth Ole Kniemeyer Reinhard Hemmerling Gerhard Buck-Sorlin Chair for Graphics Systems, BTU Cottbus

Roots of the language XL: - object-oriented programming (Java) - imperative programming (Java) - rule-based programming (L-systems, graph grammars) - chemical programming

Roots of the language XL: - 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, ) 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) ]

part of the alphabet: 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

example: 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 word L(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 word L(10) A ? equivalent rule: A ==> [ LMul(0.25) RU(-45) F0 ] F0 RH(180) A;

a space-filling curve: 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 ;

which structure is given by 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)

Stochastic L-systems 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)"

context sensitivity 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 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) ];

Transition to graph grammars: 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 Kniemeyer's dissertation for mathematical foundations) "relational": different edge types of the graph can stand for different relations

an RGG rule and its application in graphical form: rule: application:

critical point here: 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 ==>> RSPO 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)

Extended L-Systems (XL) Example for execution rules given: a graph with cycles Spreading rule for a signal in the network: XL representation: (* Cell(1) *) c:Cell(0) ::> c[state] := 1;

Extended L-Systems (XL) spreading of signal output: 1 23

Extended L-Systems (XL) The Game of Life XL code: 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 Graphical output (a period-8 oscillator):

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

Interpretive rules Insertion of an extra rule application immediately before graphical interpretation takes place (without effect on the next generation) application of interpretive rules Turtle interpretation 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; ] 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; ] (a) (b)(c) A ==> Sphere(0.5); A ==> Box(0.1, 0.5, 0.1) Translate(0.1, 0.25, 0) Sphere(0.2);

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); ]

Extended L-Systems (XL) simple example: railway simulation Modules: Train TrackSwitch Excerpt of the data structure: Train standing before a switch

Extended L-Systems (XL) simple example: railway simulation Rule 1 Rule 2 r1:Rail[t:Train] r2:Rail ==>> r1 r2[t]; r:Rail[t:Train] s:Switch[r2:Rail] r1:Rail ==>> r s[r1[t]] r2;

Extended L-Systems (XL) Artificial Chemistry: Prime number generator A multiset of random integers reacts according to the following rule, thereby distilling prime numbers. int Rule: ab int ab/a inta divides b textual output: * Concentration: 1 / * * Concentration: 2 / * * * 37* 11* Concentration: 5 / * * 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 b:int, (* a:int *), (a != b && (b % a) == 0) ==> `b / a`;

Extended L-Systems (XL) 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 a)it has reached maximum age or b)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 plants 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 */

protected void init() { 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(); derive(); growPlants(); } public void growAnimals() [ Animal(t, e), (t Animal(t+1, e); /* start lag */ Animal(t, e), (e ; 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) 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); ]

public void growPlants() [ Plant(t, r), (t > pmaxage) ==> ; Plant(t, r), (r ; p:Plant, (* q:Plant *), (distance(p, q) < q[radius] && p[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); ]

Extended L-Systems (XL) Herbivore model: output