1
Pallavi Tambay, Yang Zhang, Prof. Bharat Jayaraman Compositional specification of structure objects Declarative specification of behavior constraints Visual specification of structure smart diagrams Principles underlying 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, etc. Cob is a programming language combining Java-like classes with declarative constraints instead of methods. What is a Constrained Object? Constrained Objects > Constraints + Objects modeling ::= define_Cob_classes; build_object_structure; solve_structure ; [ [ modify_structure ; re_solve_structure ] + ; query_structure * ] + Typical Modeling Scenario Constraint languages + Constraints model behavior - No resemblance to structure - Complex system is a flat collection of constraints - Constraints cannot be visualized Object-oriented languages + Objects model structure - Methods not appropriate for modeling behavior of complex systems Visualization tools + Natural, intuitive geometric representation - No representation of semantics or behavior of system - Modeler may not understand underlying representation Truss as Constrained Object class joint { attributes bar [] Bars; load [] Loads; constraints (sum X in Bars: X.B.F* sin(X.A)) + (sum L in Load: 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; } } R1 is unknow n R1 is unknow n output constraint output constraint output constraint Constraint Object Computational Engine Domain Specific User interface constraint solvers for different domains Domain Specific User interface Constrained Object Database Management System Model Analyzer Revision System ....... Compiler, Debugger ......... Overall architecture of Cob environment Domain-Specific Visual Language (with A. Dev & N. Menon) Building Elements (Kalay et al 1998) CUML: Constraint-based UML (with R. Jyotwani) Complex Compositional Systems Engineering Modeling Constraints for imperative prg. GUI development, Constraints for imperative prg. Physics & geometry experiments Applications CLP(R), Maple Arithmetic, Boolean, Symbolic Cob (2001) Constraint Solving Constraints Constraints + Objects Matlab Arithmetic, Boolean Modelica(1998) Fritzson , et. al. Term rewriting Arithmetic & Symbolic Siri(1992) Horn Delta-blue, Indigo Arithmetic Kaleidoscope(1992) Freeman - Benson, et. al. User- defined methods Arithmetic ThingLab(1980) Borning,et . al. Complex Compositional Systems Engineering Modeling Constraints for imperative prg. GUI development, Constraints for imperative prg. experiments Applications CLP(R), Maple Arithmetic, Boolean, Symbolic Cob (2001) Constraint Solving Constraints Constraints + Objects Matlab Arithmetic, Boolean Modelica(1998) Fritzson , et. al. Term rewriting Arithmetic & Symbolic Siri(1992) Horn Delta-blue, Indigo Arithmetic Kaleidoscope(1992) Freeman - Benson, et. al. User- defined methods Arithmetic ThingLab(1980) Borning,et . al. Comparison with Related Approaches Overall Class Diagram Constrained Objects for Dynamical Systems Support Numerical Libraries and Constrant Solvers Future Work B. Jayaraman and P. Tambay, Constrained Objects for Modeling Complex Structures, Conference on Object-Oriented Prgramming Languages Systems and Applications, 2000. B. Jayaraman and P. Tambay, Compositional Semantics for Diagrams using Constrained Objects, Intl. Conf. on Theory and Application of Diagrams, 2002 B. Jayaraman and P. Tambay, Modeling Engineering Structures using Constrained Objects, Symp. on Practical Aspects of Declarative Languages, 2002. P. Tambay, Constrained Objects for Modeling Complex Systems, Ph.D. Dissertation, University at Buffalo, 2003 B. Jayaraman and Y. Zhang, Constrained Object for Intelligent Building Design, CSE TR, University at Buffalo, 2004 Papers on Constrained Objects class beam { attributes real E, Sy , L, W, H, F, I, Sigma; constraints Pi = 3.141; L > 0; W > 0; H > 0; I > 0; I = W * H * H * H / 12; (I = ( - F * L* L) / (Pi * Pi * E)) : - F < 0; F = Sy* W * H : - F > 0; constructor beam(E1, Sy1, L1, W1, H1,F1) { E = E1; L = L1; H=H1; W=W1; F = F1; } } Conditional Constraint Support for SolvingNonlinear Constraints Find the size ofthebeam s given the load ofthe truss. Thisproblem requiresnonlinear constraintsto be solved. Cob isinterfaced w ith M aple to solve nonlinearconstraints. class slab { attributes level Pl; beam[] Peripherialbeams; real Z; constraints forall B in Peripheralbeams: B.Z = Z; constructor slab(L,B) { Pl = L; Peripherialbeams = B; } } Load Load Beam Joint Com piled CU M L Code Com piled D iagram Code Cob Com piler CLP® Code PartialEvaluator Optimized Code Constraint Engine A nsw ers D iagram M anager Compilation and Execution What is Partial Evaluator o Input P : CCLP - translation of a Cob Program G : CCLP - translation of a Cob Query o Evaluate parEval( G , [ ], C ) o Output C : Set of constraints P C G parEval(true, C, C). parEval((A,B), Cin, Cout) :- parEval(A, Cin, Cout1), parEval(B, Cout1, Cout). parEval(G, C, C) :- (clp_built-in(G); unification(G); cob_builtin(G)), call(G). Partial Evaluator (PE) - Strategy

Pallavi Tambay, Yang Zhang, Prof. Bharat Jayaraman Compositional specification of structure objects Declarative specification of behavior constraints

  • View
    219

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Pallavi Tambay, Yang Zhang, Prof. Bharat Jayaraman  Compositional specification of structure  objects  Declarative specification of behavior  constraints

Pallavi Tambay, Yang Zhang, Prof. Bharat Jayaraman

Compositional specification of structure objects

Declarative specification of behavior constraints

Visual specification of structure smart diagrams

Principles underlying 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, etc.

Cob is a programming language combining Java-likeclasses with declarative constraints instead of methods.

What is a Constrained Object?Constrained Objects > Constraints + Objects

modeling ::= define_Cob_classes; build_object_structure; solve_structure ; [ [ modify_structure ;

re_solve_structure ] +; query_structure * ] +

Typical Modeling Scenario

Constraint languages+ Constraints model behavior- No resemblance to structure- Complex system is a flat collection of constraints- Constraints cannot be visualized

Object-oriented languages+ Objects model structure- Methods not appropriate for modeling behavior of complex

systems Visualization tools

+ Natural, intuitive geometric representation- No representation of semantics or behavior of system- Modeler may not understand underlying representation

Truss as Constrained Object

class joint { attributes bar [] Bars; load [] Loads; constraints (sum X in Bars: X.B.F* sin(X.A)) + (sum L in Load: 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; }}

R1 isunknown

R1 isunknown

outputconstraint

outputconstraint

outputconstraint

Constraint

Object

Computational

Engine

DomainSpecificUser interface

constraint solvers for different domains

DomainSpecificUser interface

ConstrainedObject DatabaseManagementSystem

Model AnalyzerRevision System .......

Compiler, Debugger .........

Overall architecture of Cob environment

Domain-Specific Visual Language

(with A. Dev & N. Menon)

Building Elements (Kalay et al 1998)

CUML: Constraint-based UML (with R. Jyotwani)

Complex Compositional Systems

Engineering Modeling

Constraints for imperative prg.

GUI development,Constraints for imperative prg.

Physics & geometry experiments

Applications

CLP(R),Maple

Arithmetic, Boolean, Symbolic

Cob (2001)

ConstraintSolving

ConstraintsConstraints + Objects

MatlabArithmetic, Boolean

Modelica (1998)Fritzson, et. al.

Term rewritingArithmetic & Symbolic

Siri (1992)Horn

Delta-blue,Indigo

ArithmeticKaleidoscope(1992)Freeman-Benson, et. al.

User-defined methods

ArithmeticThingLab (1980)Borning,et. al.

Complex Compositional Systems

Engineering Modeling

Constraints for imperative prg.

GUI development,Constraints for imperative prg.

experiments

Applications

CLP(R),Maple

Arithmetic, Boolean, Symbolic

Cob (2001)

ConstraintSolving

ConstraintsConstraints + Objects

MatlabArithmetic, Boolean

Modelica (1998)Fritzson, et. al.

Term rewritingArithmetic & Symbolic

Siri (1992)Horn

Delta-blue,Indigo

ArithmeticKaleidoscope(1992)Freeman-Benson, et. al.

User-defined methods

ArithmeticThingLab (1980)Borning,et. al.

Comparison with Related Approaches

Overall Class Diagram

Constrained Objects for Dynamical Systems Support Numerical Libraries and Constrant Solvers

Future Work

B. Jayaraman and P. Tambay, Constrained Objects for Modeling Complex Structures, Conference on Object-Oriented Prgramming Languages Systems and Applications, 2000.B. Jayaraman and P. Tambay, Compositional Semantics for Diagrams using Constrained Objects, Intl. Conf. on Theory and Application of Diagrams, 2002 B. Jayaraman and P. Tambay, Modeling Engineering Structures using Constrained Objects, Symp. on Practical Aspects of Declarative Languages, 2002. P. Tambay, Constrained Objects for Modeling Complex Systems, Ph.D. Dissertation, University at Buffalo, 2003B. Jayaraman and Y. Zhang, Constrained Object for Intelligent Building Design, CSE TR, University at Buffalo, 2004

Papers on Constrained Objects

class beam {

attributes

real E, Sy, L, W, H, F, I, Sigma;constraints

Pi = 3.141;L > 0; W > 0; H > 0; I > 0;I = W * H * H * H / 12;

(I = (-F * L* L) / (Pi * Pi * E)) :- F < 0;F = Sy * W * H :- F > 0;

constructor beam(E1, Sy1, L1, W1, H1,F1) {

E = E1; L = L1; H=H1; W=W1; F = F1;}

}

ConditionalConstraint

Support for Solving Nonlinear Constraints

Find the size of the beams given the load of the truss.

This problem requires nonlinear constraints to be solved.

Cob is interfaced with Maple to solve nonlinear constraints.

class slab {

attributeslevel Pl;beam[] Peripherialbeams;

real Z;

constraints forall B in Peripheralbeams:

B.Z = Z;

constructorslab(L,B) { Pl = L; Peripherialbeams = B;

}

}

Load Load

Beam Joint

Compiled CUMLCode Compiled Diagram Code

Cob Compiler

CLP® Code

Partial Evaluator

Optimized Code

ConstraintEngine

Answers

DiagramManager

Compilation and Execution

What is Partial Evaluator

o Input• P : CCLP - translation of a Cob Program• G : CCLP - translation of a Cob Query

o Evaluate parEval( G , [ ], C )

o Output• C : Set of constraints • P ╞ C → G

parEval(true, C, C).

parEval((A,B), Cin, Cout) :- parEval(A, Cin, Cout1), parEval(B, Cout1, Cout).

parEval(G, C, C) :- (clp_built-in(G); unification(G); cob_builtin(G)), call(G).

Partial Evaluator (PE) - Strategy