research in programming languages prof. bharat jayaraman language research group

27
Research in Programming Languages Prof. Bharat Jayaraman Language Research Group

Post on 21-Dec-2015

225 views

Category:

Documents


0 download

TRANSCRIPT

Research in Programming Languages

Prof. Bharat Jayaraman

Language Research Group

http://www.cse.buffalo.edu/LRG

Programming Languages

Imperative Declarative

Procedural Data Abstraction

C … ObjectsModules

Ada … Java …

Relational Functional

Constraints Logic ML …

CLP … Prolog …

… …

Current Research Projects1. Constrained Objects (with P. Tambay)

2. Visual Modeling and Execution of Object-Oriented Programs (joint work with P. Gestwicki)

3. CobWeb: Constraint-based Extension of XML (with S. Raghavan and S. Shanker)

4. Programming with Constraints and Preferences (with P. Tambay)

5. Set-Oriented Programming Languages (with Osorio)

Modeling Complex Structures

• Engineering Structures – Examples: circuits, trusses, mixers, gears, …

• Model a structure and execute it to obtain values• Modify specifications and re-execute• Design an artifact meeting constraints and preferences

• Desired Approach–compositional specification of structure–declarative specification of behavior (physical laws)

1. Constrained Objects

• Model = Structure + Behavior• Structure = Objects• Behavior = Constraints

• Domain-Specific Visual Programming• Diagrams are Programs!• Constraint-Based UML (CUML)

Circuits as Constrained Objects

V1 = I1 * R1

V2 = I2 * R2

V3 = I3 * R3

V1 =V2 = V3 = V

I1 + I2 + I3 = I

1/R1 + 1/R2 + 1/R3 =1/R

V = I * R

Cob Class Definition

class component { % generic circuit component attributes Real V, I, R; constraints V = I * R; constructor component(V1, I1, R1) { V = V1; I = I1; R = R1; }}

Cob Class for Parallel Circuit

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; }}

cse@buffalo12

cse@buffalo13

resistor value

extraconstraint

changeresistorbehavior

R1 isunknown

outputconstraint

Component

Real V, I, R

V = I * R

Series

Component [ ] Comp

forall C in Comp: (C.I = I)

(sum D in Comp: D.V) = V

(sum D in Comp: E.R) = R

Parallel

Component [ ] Comp

forall C in Comp: (C.V = V)

(sum D in Comp: D.I) = I

(sum E in Comp: 1/E.R) = 1/R

Comp: 1..N Comp: 1..N

CUML Diagram

CUML Diagram

Compiler

Textual Cob Code

By Chinchani, Pramanik, Dutta

cse@buffalo12

Circuit Diagram

Compiler

Textual code

Compiled CUML Code

Compiled Circuit Diagram Code

Cob Compiler

CLP® Code

Partial Evaluator

Optimized Code

ConstraintEngine

Answers

DiagramManager

Illustrating Partial Evaluation

V1 = I1 * 10

V2 = I2 * 20

V3 = I3 * 20

V4 = I4 * 20

30 volts

P1 P2S

Circuit Cob Code

constructor samplecircuit() { R1 = new component(V1, I1, 10); R2 = new component(V2, I2, 20); R3 = new component(V3, I3, 20); R4 = new component(V4, I4, 20); R12[1] = R1; R12[2] = R2; R34[1] = R3; R34[2] = R4;

P1 = new parallel(R12); P2 = new parallel(R34); P12[1] = P1; P12[2] = P2; S = new series(P12); B = new battery(30); C = new connect(B, S);}

Cob Code CLP Code samplecircuit() :- makearray(1,R12), makearray(1,R34), makearray(1,P12), component([V1,I1,10],R1), component([V2,I2,20],R2), component([V3,I3,20],R3), component([V4,I4,20],R4), Cob23 = R1, index(R12,1,Cob23), Cob24 = R2, index(R12,2,Cob24), Cob25 = R3,

index(R34,1,Cob25), Cob26 = R4, index(R34,2,Cob26), parallel([R12],P1), parallel([R34],P2), Cob27 = P1, index(P12,1,Cob27), Cob28 = P2, index(P12,2,Cob28), series([P12],S),

battery([30],B), connect([B,S],C).

Optimized CLP Code

V1 = V2 = I1 * 10 = I2 * 20 V3 = V4 = I3 * 20 = I4 * 20 S.I = I1 + I2 = I3 + I41/P1.R = 1/10 + 1/ 20V3 = S.I * P2 .R1/P2.R = 1/20 + 1/2030 = S.I + S.R30 = V1 + V3S.R = P1.R + P2.R

Truss as Constrained Object Load Load

Beam Joint

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; }}

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

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; }}

ConditionalConstraint

gear_box

Nb = 2 * NsNb, Ns, Ng, l, w, h

drive

Tin, Tout, Hin, Hout, Nin, Nout, E, RTout = 63025 * Hout / Nout Tin = 63025 * Hin / NinE < 1 E = Hout / Hin R = Nin / NoutMax E

gear_traingbox, mesh

R = (mmesh)m.rm mesh. m.g2.s = next(m).g1.s

P, N, d, F, PA, s

P = N / d N >= 18PA {14.5, 20, 25 }9 / P <= F <= 13/P

gear

belt_drive chain_drive

1

2

1

1

1

meshg1, g2, r

g1.N >= 17r = g2.N/g1.Ng1.P = g2.Pg1.F = g2.Fg1.PA = g2.PAr <= 5

Max r

n

reverted_train

compound_train

epicyclic_train

1

CUML Diagram

for Gears

Current Research

• Collaboration with several Engineering Faculty:- hydrological modeling, structural modeling

• Use Matlab for solving non-linear systems• Model Analysis and Fault Detection• Constraint Optimization and Relaxation• CobWeb: Constrained XML