Functional-Structural Plant Modelling with GroIMP and XL Tutorial and Workshop at Agrocampus Ouest, Angers, 5-7 May, 2015 Winfried Kurth University of.

Slides:



Advertisements
Similar presentations
Pointers.
Advertisements

Translator Architecture Code Generator ParserTokenizer string of characters (source code) string of tokens abstract program string of integers (object.
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.
From Molecules To Landscapes: Rule-based FSPMs in the Language XL Winfried Kurth Brandenburg University of Technology at Cottbus, Chair for Graphics Systems.
Grammars, constituency and order A grammar describes the legal strings of a language in terms of constituency and order. For example, a grammar for a fragment.
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.
Session 14 (DM62) / 15 (DM63) Recursive Descendent Parsing.
Chapter3: Language Translation issues
Simulating Trees with Fractals and L-Systems Eric M. Upchurch CS 579.
PZ02A - Language translation
Slide 1 Chapter 2-b Syntax, Semantics. Slide 2 Syntax, Semantics - Definition The syntax of a programming language is the form of its expressions, statements.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 13 Pointers and Linked Lists.
79 Regular Expression Regular expressions over an alphabet  are defined recursively as follows. (1) Ø, which denotes the empty set, is a regular expression.
Lesson 6. Refinement of the Operator Model This page describes formally how we refine Figure 2.5 into a more detailed model so that we can connect it.
Syntactic Pattern Recognition Statistical PR:Find a feature vector x Train a system using a set of labeled patterns Classify unknown patterns Ignores relational.
(2.1) Grammars  Definitions  Grammars  Backus-Naur Form  Derivation – terminology – trees  Grammars and ambiguity  Simple example  Grammar hierarchies.
CSC 8310 Programming Languages Meeting 2 September 2/3, 2014.
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.
Problem of the DAY Create a regular context-free grammar that generates L= {w  {a,b}* : the number of a’s in w is not divisible by 3} Hint: start by designing.
XL as an extension of the L-system formalism Tutorial "Modelling Plants with GroIMP", Cottbus, March 11-12, 2008 Winfried Kurth Ole Kniemeyer Reinhard.
Chapter 2 Syntax A language that is simple to parse for the compiler is also simple to parse for the human programmer. N. Wirth.
1 Syntax and Semantics The Purpose of Syntax Problem of Describing Syntax Formal Methods of Describing Syntax Derivations and Parse Trees Sebesta Chapter.
Functional-Structural Plant Modelling with GroIMP and XL Tutorial and Workshop at Agrocampus Ouest, Angers, 5-7 May, 2015 Winfried Kurth University of.
CS 2104 Prog. Lang. Concepts Dr. Abhik Roychoudhury School of Computing Introduction.
Summer School „Modelling and Simulation with GroIMP“ / Tutorial for beginners University of Göttingen (Germany), September, 2010 Winfried Kurth Some.
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
L-Systems and Procedural Plants CSE 3541 Matt Boggus.
The Artificial Life of Plants Przemyslaw Prusinkiewicz, Mark Hammel, Radom´ır Mˇech Department of Computer Science University of Calgary Calgary, Alberta,
Tutorial and workshop „Modelling with GroIMP and XL“ / Tutorial for beginners University of Göttingen, 27 February, 2012 Winfried Kurth Basic examples.
Week 11 - Wednesday.  What did we talk about last time?  Graphs  Euler paths and tours.
A sentence (S) is composed of a noun phrase (NP) and a verb phrase (VP). A noun phrase may be composed of a determiner (D/DET) and a noun (N). A noun phrase.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 2 Syntax A language that is simple to parse.
Summer School „Modelling and Simulation with GroIMP“ / Tutorial for beginners University of Göttingen (Germany), September, 2010 Winfried Kurth Some.
Summer School „Modelling and Simulation with GroIMP“ / Tutorial for beginners University of Göttingen (Germany), September, 2010 Winfried Kurth Some.
Copyright © by Curt Hill Grammar Types The Chomsky Hierarchy BNF and Derivation Trees.
1 10/27/ :26 UML Simplicity in Complexity. 2 10/27/ :26 UML Rewriting Systems Classic Example: Koch 1905 Initiator Generator.
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.
CMSC 330: Organization of Programming Languages Context-Free Grammars.
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.
Adding functionality to a growth model; A tutorial on queries in GroImp Basic plant.gsz Adding function using queries.
1 Language translation Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Sections
LESSON 04.
The Interpreter Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 2 Syntax A language that is simple to parse.
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.
Overview of Previous Lesson(s) Over View 3 Model of a Compiler Front End.
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.
Copyright © Curt Hill Other Trees Applications of the Tree Structure.
LECTURE 10 Semantic Analysis. REVIEW So far, we’ve covered the following: Compilation methods: compilation vs. interpretation. The overall compilation.
Automata and Languages What do these have in common?
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
Thinking about grammars
Dynamic Data Structures and Generics
Interpretive rules and instantiation rules
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Dynamic Data Structures and Generics
OBJ first-order functional language based on equational logic
Thinking about grammars
Language translation Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Sections
Language translation Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Sections
COMPILER CONSTRUCTION
Visual Programming Languages ICS 539 Icon System Visual Languages & Visual Programming, Chapter 1, Editor Chang, 1990 ICS Department KFUPM Sept. 1,
Presentation transcript:

Functional-Structural Plant Modelling with GroIMP and XL Tutorial and Workshop at Agrocampus Ouest, Angers, 5-7 May, 2015 Winfried Kurth University of Göttingen, Department Ecoinformatics, Biometrics and Forest Growth Graph rewriting, interpretive rules, instantiation rules

The formal background of the programming language XL: Relational Growth Grammars (RGG) = a special form of parallel graph grammars see Ole Kniemeyer: Design and Implementation of a Graph Grammar Based Language for Functional-Structural Plant Modelling. Ph.D. thesis, University of Technology at Cottbus (2008); chapters 4 and 5 [

The step towards graph grammars Drawback of L-systems: in L-systems with branches (by turtle commands) only 2 possible relations between objects: "direct successor" and "branch" extensions: to permit additional types of relations to permit cycles  graph grammar

a string: a very simple graph  a string can be interpreted as a 1-dimensional graph with only one type of edges  successor edges (successor relation) A B A A A C C A B

in GroIMP, all is represented in a graph: (Smoleňová 2010)

graph grammars example rule: to make graphs dynamic, i.e., to let them change over time:

A relational growth grammar (RGG) (special type of graph grammar) contains:  an alphabet –the definition of all allowed node types edge types (types of relations)  the axiom –an initial graph, composed of elements of the alphabet  a set of graph replacement rules.

How an RGG rule is applied  each left-hand side of a rule describes a subgraph (a pattern of nodes and edges, which is looked for in the whole graph), which is replaced when the rule is applied.  each right-hand side of a rule defines a new subgraph which is inserted as substitute for the removed subgraph.

Example: rule: application:

a complete RGG rule can have 5 parts: (* context *), left-hand side, ( condition ) ==> right-hand side { imperative XL code }

in text form we write (user-defined) edges as -edgetype-> edges of the special type "successor" are usually written as a blank (instead of -successor-> ) also possible: > Further special edge types with special notation: "branch" edge: +> (also generated after " [ " ) "decomposition" edge: />

example: graph grammar in XL for the Koch curve public void derivation() [ Axiom ==> RU(90) F(10); F(x) ==> F(x/3) RU(-60) F(x/3) RU(120) F(x/3) RU(-60) F(x/3); ] L-systems as a special case of graph grammars: ● the symbols of the L-system alphabet become vertices ● concatenation of symbols corresponds to successor edges vertex of the graph edge (type „successor“)

a “proper“ graph grammar (not expressible as L-system): rule: application: rule in text form: i -b-> j -a-> k -a-> i = => j

a “proper“ graph grammar (not expressible as L-system): rule: application: what happens if there are two nodes on the right-hand side instead of one?

2 types of rules for graph replacement in XL: ● L-system rule, symbol: ==> provides an embedding of the right-hand side into the graph (i.e., incoming and outgoing edges are maintained) ● SPO rule, symbol: ==>> incoming and outgoing edges are deleted (if their maintenance is not explicitely prescribed in the rule) „SPO“ from „single pushout“ – a notion from universal algebra

a:A ==>> a C (SPO rule) B ==> D E (L-system rules) C ==> A start graph: ABC example:

a:A ==>> a C (SPO rule) B ==> D E (L-system rules) C ==> A ABC DEA

a:A ==>> a C (SPO rule) B ==> D E (L-system rules) C ==> A ABC DEA a:

a:A ==>> a C (SPO rule) B ==> D E (L-system rules) C ==> A AADE a: C = final result

test the example sm09_e27.rgg : module A extends Sphere(3); protected void init() [ Axiom ==> F(20, 4) A; ] public void runL() [ A ==> RU(20) F(20, 4) A; ] public void runSPO() [ A ==>> ^ RU(20) F(20, 4, 5) A; ] ( ^ denotes the root node in the current graph)

Representation of graphs in XL ● vertex types must be declared with „ module “ ● vertices can be all Java objects ● notation for vertices in a graph: Node_type, optionally preceded by: label: Examples: A, Meristem(t), b:Bud ● notation for edges in a graph: - edgetype -> (forward), <- edgetype - (backward), - edgetype - forward or backward, forward and backward ● special edge types: successor edge: -successor->, > or (blank) branch edge: -branch->, +> or [ refinement edge: />

Notations for special edge types > successor edge forward < successor edge backward --- successor edge forward or backward +> branch edge forward <+ branch edge backward -+- branch edge forward or backward /> refinement edge forward </ refinement edge backward --> arbitrary edge forward <-- arbitrary edge backward -- arbitrary edge forward or backward (cf. Kniemeyer 2008, p. 150 and 403)

Notations for special edge types (overview) forward backward forward or backward forward and backward successor branch refinement arbitrary

user-defined edge types const int xxx = EDGE_0; // oder EDGE_1,..., EDGE_14... usage in the graph: -xxx->, Notation of graphs in XL example: is represented in programme code as (the representation is not unique!) ( >: successor edge, +: branch edge)

how can the following graph be described in XL code? (the solution is not unique) X Bud Leaf + > 01

Interpretive rules insertion of a further phase of rule application directly preceding graphical interpretation (without effect on the next generation) application of interpretive rules interpretation by turtle

Example: { interpretive rule

Each occurrence of the interpreted vertex (here: Flower) is individually represented in the graph. A special (internal) edge type and special vertices are used to link the interpretation results with the rest of the graph:

public void run() { [ Axiom ==> A; A ==> Scale(0.3333) for (int i:(-1:1)) for (int j:(-1:1)) if ((i+1)*(j+1) != 1) ( [ Translate(i, j, 0) A ] ); ] applyInterpretation(); } public void interpret() [ A ==> Box; ] further example: generates the so-called „Menger sponge“ (a fractal)

public void run() { [ Axiom ==> A; A ==> Scale(0.3333) for (int i:(-1:1)) for (int 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); Development:

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

a very similar type of rules in XL: instantiation rules purpose: replacement of single modules by more complicated structures, only for visual representation (similar as for interpretive rules) but: less data are stored (less usage of memory) only one vertex in the graph for the instantiated structure in contrast to interpretive rules, no turtle commands with effect on other nodes can be used further, arising possibility: “replicator nodes“ for copying and relocation of whole structures

instantiation rules: syntax no new sort of rule arrow specification of the instantiation rule directly in the declaration of the module which is to be replaced module A ==> B C D; replaces (instantializes) everywhere A by B C D

the flower example again: { instantiation rule

the resulting graph:

const int multiply = EDGE_0; /* user-defined edge type */ module Johnny ==> F(20, 1) [ M(-8) RU(45) F(6, 0.8) Sphere(1) ] [ M(-5) RU(-45) F(4, 0.6) Sphere(1) ] Sphere(2); Johnny is instantiated with the red structure another example: Usage of instantiation rules for multiplyer objects sm09_e43.rgg

const int multiply = EDGE_0; /* user-defined edge type */ module Johnny ==> F(20, 1) [ M(-8) RU(45) F(6, 0.8) Sphere(1) ] [ M(-5) RU(-45) F(4, 0.6) Sphere(1) ] Sphere(2); module Replicator ==> [ getFirst(multiply) ] Translate(10, 0, 0) [ getFirst(multiply) ]; inserts all what comes after the „multiply“ edge Johnny is instantiated with the red structure another example: Usage of instantiation rules for multiplyer objects sm09_e43.rgg

const int multiply = EDGE_0; /* user-defined edge type */ module Johnny ==> F(20, 1) [ M(-8) RU(45) F(6, 0.8) Sphere(1) ] [ M(-5) RU(-45) F(4, 0.6) Sphere(1) ] Sphere(2); module Replicator ==> [ getFirst(multiply) ] Translate(10, 0, 0) [ getFirst(multiply) ]; public void run() [ Axiom ==> F(2, 6) P(10) Replicator -multiply-> Johnny; ] inserts all what comes after the „multiply“ edge Johnny is instantiated with the red structure another example: Usage of instantiation rules for multiplyer objects sm09_e43.rgg

result:

Example: Inflorescence architecture XL code

Example: Inflorescence architecture generated graph and 3-d result

Example: Inflorescence architecture Frangipani example (by M. Henke)

Suggestions for team session 1. Generate a plant with parameterized leaves (parameters: length, width, ratio petiole/blade length,...) - with interpretive rules, - with instantiation rules. 2. Create a model for a circular arrangement of mushrooms (“witches ring“). Use an instantiation rule for the multiplication and arrangement.