Tutorial and workshop „Modelling with GroIMP and XL“ / Tutorial for beginners University of Göttingen, 27 February, 2012 Winfried Kurth Basic examples.

Slides:



Advertisements
Similar presentations
Chapter 2 Revision of Mathematical Notations and Techniques
Advertisements

Semantics Static semantics Dynamic semantics attribute grammars
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.
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.
FUNCTIONS AND MODELS Chapter 1. Preparation for calculus :  The basic ideas concerning functions  Their graphs  Ways of transforming and combining.
Trees. 2 Definition of a tree A tree is like a binary tree, except that a node may have any number of children Depending on the needs of the program,
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
CS 330 Programming Languages 09 / 13 / 2007 Instructor: Michael Eckmann.
Trees. Definition of a tree A tree is like a binary tree, except that a node may have any number of children –Depending on the needs of the program, the.
Chapter 3 Program translation1 Chapt. 3 Language Translation Syntax and Semantics Translation phases Formal translation models.
Syntactic Pattern Recognition Statistical PR:Find a feature vector x Train a system using a set of labeled patterns Classify unknown patterns Ignores relational.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 20: Binary Trees.
(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.
Summer School „Modelling and Simulation with GroIMP“ / Tutorial for beginners University of Göttingen (Germany), September, 2010 Winfried Kurth Modelling.
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.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Trees. Tree Terminology Chapter 8: Trees 2 A tree consists of a collection of elements or nodes, with each node linked to its successors The node at the.
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.
Lecture 10 Trees –Definiton of trees –Uses of trees –Operations on a tree.
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
1 Chapter Elementary Notions and Notations.
Languages, Grammars, and Regular Expressions Chuck Cusack Based partly on Chapter 11 of “Discrete Mathematics and its Applications,” 5 th edition, by Kenneth.
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.
TextBook Concepts of Programming Languages, Robert W. Sebesta, (10th edition), Addison-Wesley Publishing Company CSCI18 - Concepts of Programming languages.
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.
Tutorial and workshop „Modelling with GroIMP and XL“ / Tutorial for beginners University of Göttingen, 27 February, 2012 Winfried Kurth Introduction to.
Applications Development
Language Translation A programming language processor is any system that manipulates programs expressed in a PL A source program in some source language.
Adding functionality to a growth model; A tutorial on queries in GroImp Basic plant.gsz Adding function using queries.
Mathematical Preliminaries
CE 221 Data Structures and Algorithms Chapter 4: Trees (Binary) Text: Read Weiss, §4.1 – 4.2 1Izmir University of Economics.
Tutorial and workshop „Modelling with GroIMP and XL“ / Tutorial for beginners University of Göttingen, 27 February, 2012 Gerhard Buck-Sorlin and Winfried.
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.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 2 Syntax A language that is simple to parse.
Concepts and Realization of a Diagram Editor Generator Based on Hypergraph Transformation Author: Mark Minas Presenter: Song Gu.
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.
Haskell Basics CSCE 314 Spring CSCE 314 – Programming Studio Using GHC and GHCi Log in to unix.cse.tamu.edu (or some other server) From a shell.
Copyright © Curt Hill Other Trees Applications of the Tree Structure.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Overview of Previous Lesson(s) Over View  A token is a pair consisting of a token name and an optional attribute value.  A pattern is a description.
Computer Fundamentals Muhammadamin Daneshwar And Masoud Aras Computer Engineering Department Soran University Lecture 6.
Grammars, L-Systems Jim Whitehead UC Santa Cruz School of Engineering courses.soe.ucsc.edu/courses/cmps265/Spring14/01 23 Apr 2014.
Chapter 1 INTRODUCTION TO THE THEORY OF COMPUTATION.
Chapter 3 – Describing Syntax
Describing Syntax and Semantics
Graph-Based Operational Semantics
Introduction to the C Language
CSE 3302 Programming Languages
Interpretive rules and instantiation rules
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:

Tutorial and workshop „Modelling with GroIMP and XL“ / Tutorial for beginners University of Göttingen, 27 February, 2012 Winfried Kurth Basic examples in XL (part 2)

Context sensitivity Query for a context which must be present to make a rule 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); // 2 = green A(t), (t == 5) ==> B(10, 4); // 4 = red 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) ]; // 3 = blue

test the examples sm09_e14.rgg usage of a left context sm09_e15.rgg usage of a right context

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

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.

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

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)

Mathematical background: Chapter 4 of Ole Kniemeyer‘s doctoral dissertation ( opus-5937 ).

The language XL  extension of Java  allows also specification of L-systems and RGGs (graph grammars) in an intuitive rule notation procedural blocks, like in Java: {... } rule-oriented blocks (RGG blocks): [... ]

example: XL programme for the Koch curve (see part 1) 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); ] Features of the language XL: ● nodes of the graph are Java objects (including geometry objects) nodes of the graph edges (type „successor“)

special nodes: geometry objects Box, Sphere, Cylinder, Cone, Frustum, Parallelogram... access to attributes by parameter list: Box(x, y, z) (length, width, height) or with special functions: Box(...).(setColor(0x007700)) (colour)

special nodes: geometry objects Box, Sphere, Cylinder, Cone, Frustum, Parallelogram... transformation nodes Translate(x, y, z), Scale(cx, cy, cz), Scale(c), Rotate(a, b, c), RU(a), RL(a), RH(a), RV(c), RG,... light sources PointLight, DirectionalLight, SpotLight, AmbientLight

Features of the language XL: ● rules organized in blocks [...], control of application by control structures example: rules for the stochastic tree Axiom ==> L(100) D(5) A; A ==> F0 LMul(0.7) DMul(0.7) if (probability(0.5)) ( [ RU(50) A ] [ RU(-10) A ] ) else ( [ RU(-50) A ] [ RU(10) A ] );

Features of the language XL: ● parallel application of the rules (can be modified: sequential mode can be switched on, see below)

Features of the language XL: ● parallel execution of assignments possible special assignment operator := besides the normal = quasi-parallel assignment to the variables x and y: x := f(x, y); y := g(x, y);

Features of the language XL: ● operator overloading (e.g., „+“ for vectors as for numbers) (see later presentation by Reinhard Hemmerling)

Features of the language XL: ● set-valued expressions (more precisely: producer instead of sets) ● graph queries to analyze the actual structure

example for a graph query: binary tree, growth shall start only if there is enough distance to other F objects 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 „if“ condition with the „if“ condition

query syntax: a query is enclosed by (* *) The elements are given in their expected order, e.g.: (* A A B *) searches for a subgraph which consists of a sequence of nodes of the types A A B, connected by successor edges. Queries as generalized contexts: test the examples sm09_e28.rgg, sm09_e29.rgg, sm09_e30.rgg

Features of the language XL: ● aggregating operators (e.g., „sum“, „mean“, „empty“, „forall“, „selectWhereMin“) can be applied to set-valued results of a query

Queries and aggregating operators provide possibilities to connect structure and function example: search for all leaves which are successors of node c and sum up their surface areas transitive closure aggregation operator result can be transferred to an imperative calculation query

Queries in XL test the examples sm09_e31.rgg, sm09_e35.rgg, sm09_e36.rgg

for light interception / photosynthesis: a simple model of overshadowing using a query referring to a geometric region in space model approach (strongly simplifying): overshadowing of an object occurs when there are further objects in an imagined cone with its apex in the object, opened into z direction (to the sky). example: sm09_e42.rgg competition of three 2-dimensional model plants for light

module Segment(int t, int ord) extends F0; module TBud(int t) extends F(1, 1, 1); module LBud extends F(0.5, 0.5, 1); Vector3d z = new Vector3d(0, 0, 1); protected void init() [ Axiom ==> P(2) D(5) V(-0.15) [ TBud(-4) ] RU(90) M(600) RU(-90) [ TBud(0) ] RU(-90) M(1200) RU(90) [ TBud(-8) ]; ] public void run() [ TBud(t), (t TBud(t+1); x:TBud(t), (t >= 0 && empty( (* s:Segment, (s in cone(x, z, 45)) *) ) ) ==> L(random(80, 120)) Segment(0, 0) [ MRel(random(0.5, 0.9)) RU(60) LBud ] [ MRel(random(0.5, 0.9)) RU(-60) LBud ] TBud(t+1); y:LBud, (empty( (* s:Segment, (s in cone(y, z, 45)) *) ) ) ==> L(random(60, 90) Segment(0, 1) RV0 LBud; Segment(t, o), (t Segment(t+1, o); Segment(t, o), (t >= 8 && o == 1) ==>> ; /* removal of the whole branch */ ]

Representation of graphs in XL ● node types must be declared with „ module “ ● nodes can be all Java objects. In user-made module declarations, methods (functions) and additional variables can be introduced, like in Java ● notation for nodes in a graph: Node_type, optionally preceded by: label: Examples: A, Meristem(t), b:Bud ● notation for edges in a graph: - edgetype ->, <- edgetype - ● 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)

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

derived relations relation between nodes connected by several edges (one after the other) of the same type: „transitive hull“ of the original relation (edge)

Notation for the transitive hull in XL: (-edgetype->)+ reflexive-transitive hull („node stands in relation to itself“ also permitted): (-edgetype->)* e.g., for the successor relation: (>)* common transitive hull of the special relations „successor“ and „branch“, in reverse direction: -ancestor-> interpretation: this relation is valid to all „preceding nodes“ in a tree along the path to the root. nearest successors of a certain node type: -minDescendants-> (nodes of other types are skipped)

successor edge branch edge relation „ancestor“ minDescendants

The current graph GroIMP maintains always a graph which contains the complete current structural information. This graph is transformed by application of the rules. Attention: Not all nodes are visible objects in the 3-D view of the structure! - F0, F(x), Box, Sphere : yes - RU(30), A, B : normally not (if not derived by „ extends “ from visible objects) The graph can be completely visualized in the 2-D graph view (in GroIMP: Panels - 2D - Graph).

Load an example RGG file in GroIMP and execute some steps (do not work with a too complex structure). Open the 2-D graph view, fix the window with the mouse in the GroIMP user interface and test different layouts (Layout - Edit). Keep track of the changes of the graph when you apply the rules (click on „redraw“)!

which parts of the current graph of GroIMP are visible (in the 3-d view) ? all geometry nodes which can be accessed from the root (denoted ^) of the graph by exactly one path, which consists only of "successor" and "branch" edges How to enforce that an object is visible in any case: ==>> ^ Object

a further type of rules: actualization rules often, nothing at the graph structure has to be changed, but only attributes of one single node are to be modified (e.g., calculation of photosynthesis in one leaf). For this purpose, there is an extra rule type: A ::> { imperative code }; Test the examples sm09_e25.rgg, sm09_e16.rgg, sm09_e17.gsz, sm09_e18.rgg and concerning the access to node attributes: sm09_e26.rgg

Suggestions for team session: Create the following simple branching patterns with XL

Suggestions for team session: Create the following patterns as textured structures with XL make queries in the generated structures