Presentation is loading. Please wait.

Presentation is loading. Please wait.

Modeling and Visualization in Object Oriented Languages*

Similar presentations


Presentation on theme: "Modeling and Visualization in Object Oriented Languages*"— Presentation transcript:

1 Modeling and Visualization in Object Oriented Languages*
Bharat Jayaraman Amrita Vishwa Vidyapeetham Professor and Chair Department of Computer Science & Engineering University at Buffalo, NY 14260 Joint work with Pallavi Tambay and Paul Gestwicki (PhD students) and several MS students at Buffalo

2 Programming Languages
Imperative Declarative Procedural Data Abstraction Relational Functional Modules Objects Constraints Logic C …Fortran ML … … … Ada … Java … CLP … Prolog …

3 Two Research Projects Modeling Complex Systems
Interactive Visualization

4 Modeling Complex Systems
Motivating Domains Engineering Organizational Biological Common Characteristics Assembly of components Laws of behavior Natural visual representations Complex systems consist of several interconnected, interdependent components And examples of such systems occur in several engineering disciplines e.g. electrical, civil, chemical, environmental engg In structured documents, in biological sciences, ecological systems Our focus is on complex systems that have the following characs – A complex system can be broken down into subcomponents, i.e., its an assembly of components The behavior of each component by itsel and in relation to other components is governed by certain laws or rules & a each component and assembly can be associated with a visual representation. CS – as an example of a complex system, consider a truss

5 Building Elements (Kalay et al 1998)

6 Examples of Laws “The load on a wall ≤ its load bearing capacity.” …
“The sum of the currents at a node should be zero.” “The sum of the forces at a joint should be zero.” “The temp at a cell is the average of its neighbours.”

7 Our Principles of Modeling
compositional specification of structure  objects declarative specification of behavior  constraints visual specification of assembly  diagrams

8 I. Constrained Objects An object is a container of data that is accessed via a well-defined interface of procedures. (Imperative) A constrained object contains data that is governed by laws, or constraints. (Declarative) Examples: resistor in a circuit a joint in a truss a cell in a spreadsheet

9 Constraints A constraint is a declarative relation among variables, e.g., F = *C Constraints are additive, and collectively enforce the conditions among variables D ≥ 1 D ≤ 31 D ≤ 29 ← M = 2 /\ leapyear(Y) Many algorithms for constraint satisfaction

10 1. Circuits as Constrained Objects
V1 = I1 * R1 V = I * R V2 = I2 * R2 V3 = I3 * R3 V1 = V2 = V3 = V I1 + I2 + I3 = I 1/R /R /R3 = 1/R

11 Overview of Cob Programs
class class_id [ extends class_id ] { attributes constraints constructor constructor_clauses } Class inheritance equations, inequations, conditional, quantified, aggregate

12 Cob Class Definitions class component { attributes Real V, I, R;
constraints V = I * R; constructor component(V1, I1, R1) V = V1; I = I1; R = R1; } class parallel extends component { attributes component [ ] C; constraints forall X in C: (X.V = V); (sum X in C: X.I) = I; (sum X in C: 1/X.R) = 1/R; constructor parallel(P) { C = P; }} Ohm’s Law

13 2. Truss as Constrained Object
Load Load Joint Beam

14 class joint { attributes bar [ ] Bars; load [ ] Loads; constraints (sum X in Bars : X.B.F * sin(X.A)) + (sum L in Loads : L.F * sin(L.A)) = 0; (sum Y in Bars : Y.B.F * cos(Y.A)) + (sum M in Loads : M.F * cos(M.A)) = 0; constructor joint(B1, L1) { Bars = B1; Loads = L1; } } Law of Equilibrium of Forces

15 class bar { attributes beam B; real A; constraints 0  A; A  360; constructor bar (B1, A1) { B = B1; A = A1; } } class load { real F, A; 0  A; A  360; constructor load (F1, A1) { F = F1; A = A1; }

16 class beam { attributes real E, Sy, L, W, H, F_bn, F_bk, F_t, Sigma, I, F; constraints Pi = 3.141; I = F_bk * L* L / (Pi * Pi * E) ; I = W * H * H * H / 12; F_t = Sy * W * H; Sigma = H * I * F_bn / (8 * I); F = F_t :- F > 0; F = F_bk :- F < 0; constructor beam(E1, Sy1, L1, W1, H1,F1) { E = E1; L = L1; H=H1; W=W1; F = F1; } Conditional Constraint

17 Overall Modeling Scenario
modeling ::= define_classes ; build_instance ; solve_instance ; [ [ modify ; re_solve ] +; query * ] +

18 Modeling Tools Constrained Object Language (Cob) Text-based language
Constraint-Based UML (CUML) Domain-independent graphical modeling language Domain-Specific Visual Programming Diagrammatic notations customized for specific application domains, e.g., circuits, trusses, etc. (Draw & execute circuits, trusses).

19 CUML: Constraint-based UML
(with R. Jotwani)

20 CUML  Cob

21 Domain-Specific Visual Language
` (with A. Dev and N. Menon)

22 resistor value extra constraint change resistor behavior

23 R1 is unknown output constraint

24 Compiled CUML Code Compiled Circuit Diagram Code Answers Cob Compiler Diagram Manager Constraint Engine CLP® Code Optimized Code Optimizer

25 CUML Class Diagram Textual Cob Code Compiler
By Chinchani, Pramanik, Dutta

26 Circuit Diagram Compiler Textual Code

27 Optimized Code (by partial evaluation of generated code)
V1 = V2 = I1 * 10 = I2 * 20 V3 = V4 = I3 * 20 = I4 * 20 S.I = I1 + I2 = I3 + I4 1/P1.R = 1/10 + 1/ 20 V3 = S.I * P2 .R 1/P2.R = 1/20 + 1/20 30 = S.I + S.R 30 = V1 + V3 S.R = P1.R + P2.R

28 3. ‘Intelligent’ Building Representations
Kalay et al (1998) propose explicit representation of architectural and structural concepts. Constrained objects can represent individual building elements as well as their composition: Objects capture building structure Constraints capture internal as well as interface conditions between building elements

29 Building Elements (Kalay 1998)

30 Overall Class Diagram

31 ‘Cobifying’ Building Elements
One Cob class for each type of building element, such as level, space, surface, … wall, slab, … edge, vertex. One Cob class which integrates all the components in that building. Many different analyses can be carried out. We just illustrate a very simple calculation – the volume of the house.

32 Class Building class building { attributes level[] Ls; real Area;
constraints Area = sum X in Ls: X.Area; constructor building(L) { Ls = L; } Area of the building is the sum of areas of each level

33 Class Slab class slab { attributes level Pl; beam[ ] Peripheralbeams;
real Z; constraints forall B in Peripheralbeams: B.Z = Z; constructor slab(L,B) { Pl = L; Peripheralbeams = B; } The height of all beams surrounding the slab must be the same

34 Two-level House (Kalay et al)

35 Cob Representation for a Space
space Spaces00; slab[] Slabs0; slab[] Slabs1; surface[] Surfaces00; beam[] Beams01; slab Slabs00; surface Surfaces003, Surfaces002; surface Surfaces001, Surfaces000; horizontalSurface Ceiling00; horizontalSurface Floor00; beam B014, B013,B012, B011 ; edge Edge003, Edge002; edge Edge001, Edge000; wall Wall007, Wall002; wall Wall001, Wall000; column C8,C4, C6, C2; vertex V8, V7, V6, V5; vertex V26, V30, V36, V31; level Level0; All the elements needed to depict Spaces00 (green)

36 Cob Representation (cont)
Wall007 = new wall( V7, V8, 3.0, B014 ); Wall002 = new wall( V6, V7, 3.0, B013 ); Wall001 = new wall( V5, V6, 3.0, B012 ); Wall000 = new wall( V8, V5, 3.0, B011 ); Slabs10 = new slab( Level1, Beams10 ); Slabs00 = new slab( Level0, Beams00 ); B012 = new beam( V5, V6, B014, _ ); B011 = new beam( V8, V5, B013, _ ); B014 = new beam( V7, V8, B012, _ ); B013 = new beam( V6, V7, B011, _ ); C4 = new column( V6, V50 ); C6 = new column( V8, V51 ); C2 = new column( V5, V46 ); C8 = new column( V7, V55 ); Edge003 = new edge( Surfaces003, V7, Edge011 ); Edge002 = new edge( Surfaces002, V6, _ ); Edge001 = new edge( Surfaces001, V5, _ ); Edge000 = new edge( Surfaces000, V8, _ ); V36 = new vertex( V55, C8, 5.0, 5.0, 3.0 ); V8 = new vertex( V31, _, 5.0, 0.0, 0.0 ); V31 = new vertex( V51, C6, 5.0, 0.0, 3.0 ); V7 = new vertex( V36, _, 5.0, 5.0, 0.0 ); V30 = new vertex( V50, C4, 0.0, 5.0, 3.0 ); V6 = new vertex( V30, _, 0.0, 5.0, 0.0 ); V5 = new vertex( V26, _, 0.0, 0.0, 0.0 ); V26 = new vertex( V46, C2, 0.0, 0.0, 3.0 ); dump([Level0 .Vol]);

37 Observations Constrained objects represent nicely the structure and constraints arising in intelligent building representations. The model described in this presentation has been implemented and works in a predictable way. The current approach, even when applied to a simple two-level house with five spaces, is still tedious and error prone. There is a need for a higher-level specification from which Cob code can be generated  Component-based Design Inconsistency analysis and debugging are very important

38 Conclusions and Further Work
Constrained Objects ≥ Constraints + Objects Applicable in many domains Facilitates true visual programming Model Analysis and Fault Detection Dynamic and Evolving Systems Preferences and Constraints

39 II. Interactive Visualization of OO Programs
Conventional Execution Model: data objects and procedure activations are in separate spaces. Object-Oriented Execution Model: procedure activations occur inside data objects, i.e., objects are execution environments Several more criteria for a good visualization system for OOPs …

40 Binary Search Tree in Java
class Tree { public Tree(int n) { value = n; left = null; right = null; } protected int value; protected Tree left; protected Tree right; public void insert(int n) { if (value == n) return; if (value < n) if (right == null) right = new Tree(n); else right.insert(n); else if (left == null) left = new Tree(n); else left.insert(n); }

41 1 Tree 2 Tree 3 Tree 5 6 7 4 Tree Tree Tree Tree

42 Tree Tree Tree Tree Tree Tree Tree insert insert insert 1 2 3 5 6 7 4

43 Tree Tree i value int left Tree i right Tree Tree const insert proc
j insert n int rpdl k n insert in Tree

44 Visualization Criteria
Object as environments Multiple View of Objects Aesthetic Drawing Forward and Reverse Execution History of Execution Support Run-time Queries Use Existing Compiler and Run-time System

45 JIVE: Java Interactive Visualization Environment

46 JIVE supports Source Code Highlighting, Break Points, and Forward as well as Reverse Stepping of Programs

47 JIVE Interaction Controls
Reverse and Fast Reverse Buttons Forward and Fast Forward Buttons Minimize, Maximize,Compact View Call Path View

48

49 Displaying only the ‘Call Path’

50

51 Object Diagram without Inherited Objects

52 Minimized Object Diagram

53 Final Object Diagram

54 Final Minimized Diagram

55 Time Sequence Diagram to capture the history of method calls between objects

56 Tree Program with GUI front-end

57 Tree Program with Graphical User Interface

58

59 Selective Expansion of Object Diagram

60 Querying the Runtime State
Answer to Query “Which variable has the value 50?”

61 Visual Display of Query Result
Object BST:2 has the answer Exact point of assignment

62 Visual Display of Query Result
“Variable V in Object BST:2 has the value 50!”

63 Show all changes to variable ‘left’

64 Concluding Remarks Diagrams clarify Java semantics
handles advanced features Visualization environment pedagogic tool visual debugger JPDA is key to the implementatio Some research issues Aesthetic drawing Efficient reverse stepping

65 Current and Future Work
Reverse execution and efficient state-saving Drawing algorithms Relationship between programs and diagrams Multithreaded programs


Download ppt "Modeling and Visualization in Object Oriented Languages*"

Similar presentations


Ads by Google