Const4aints as a Desig7 Pa9er7 Hesam Samimi Alessandro - - PowerPoint PPT Presentation

const4aints as a desig7 pa9er7
SMART_READER_LITE
LIVE PREVIEW

Const4aints as a Desig7 Pa9er7 Hesam Samimi Alessandro - - PowerPoint PPT Presentation

Const4aints as a Desig7 Pa9er7 Hesam Samimi Alessandro War0h Mahdi Eslamimehr Alan Bor7ing Lab Labs MODULE bakeCarrotCake MAIN var timer, pan, bowl, grease, flour; oven.start(); WHILE (oven.heat < 350) END WHILE;


slide-1
SLIDE 1

Hesam Samimi Alessandro War0h

Const4aints as a Desig7 Pa9er7

Lab Labs

Mahdi Eslamimehr Alan Bor7ing

slide-2
SLIDE 2
slide-3
SLIDE 3

MODULE bakeCarrotCake MAIN var timer, pan, bowl, grease, flour;

  • ven.start();

WHILE (oven.heat < 350) END WHILE; add(&pan, &grease); add(&pan, &flour); add(&bowl, &egg1); add(&bowl, &vanilla); add(&bowl, &carrots); timer.start(); place(&bowl, &oven); WHILE (timer.time() < 50) if (toothPickInCenterOfCake() && itComesOutClean()) { break; /* HACK FIXME */ } END WHILE; timer.reset(); WHILE (timer.time() < 10) END WHILE; remove(&bowl, &over); END

slide-4
SLIDE 4

CARROT CAKE Serves: 18 Calories: 575

  • 1. Preheat oven to 350 degrees F (175 degrees C). Grease and flour

a 9x13 inch pan.

  • 2. In a large bowl, beat together eggs, oil, white sugar and 2

teaspoons vanilla. Mix in flour, baking soda, baking powder, salt and

  • cinnamon. Stir in carrots. Fold in pecans. Pour into prepared pan.
  • 3. Bake in the preheated oven for 40 to 50 minutes, or until a

toothpick inserted into the center of the cake comes out clean. Let cool in pan for 10 minutes, then turn out onto a wire rack and cool completely.

✔ ✔ ✔

slide-5
SLIDE 5

CARROT CAKE Serves: 18 Calories: 575

  • 1. Preheat oven to 350 degrees F (175 degrees C). Grease and flour

a 9x13 inch pan.

  • 2. In a large bowl, beat together eggs, oil, white sugar and 2

teaspoons vanilla. Mix in flour, baking soda, baking powder, salt and

  • cinnamon. Stir in carrots. Fold in pecans. Pour into prepared pan.
  • 3. Bake in the preheated oven for 40 to 50 minutes, or until a

toothpick inserted into the center of the cake comes out clean. Let cool in pan for 10 minutes, then turn out onto a wire rack and cool completely.

✔ ✔ ✔

slide-6
SLIDE 6

CARROT CAKE Serves: 18 Calories: 575

  • 1. Preheat oven to 350 degrees F (175 degrees C). Grease and flour

a 9x13 inch pan.

  • 2. In a large bowl, beat together eggs, oil, white sugar and 2

teaspoons vanilla. Mix in flour, baking soda, baking powder, salt and

  • cinnamon. Stir in carrots. Fold in pecans. Pour into prepared pan.
  • 3. Bake in the preheated oven for 40 to 50 minutes, or until a

toothpick inserted into the center of the cake comes out clean. Let cool in pan for 10 minutes, then turn out onto a wire rack and cool completely.

1K-1M LoC

⊙⊙ meaning??

slide-7
SLIDE 7

CARROT CAKE Serves: 18 Calories: 575

  • 1. Preheat oven to 350 degrees F (175 degrees C). Grease and flour

a 9x13 inch pan.

  • 2. In a large bowl, beat together eggs, oil, white sugar and 2

teaspoons vanilla. Mix in flour, baking soda, baking powder, salt and

  • cinnamon. Stir in carrots. Fold in pecans. Pour into prepared pan.
  • 3. Bake in the preheated oven for 40 to 50 minutes, or until a

toothpick inserted into the center of the cake comes out clean. Let cool in pan for 10 minutes, then turn out onto a wire rack and cool completely.

✔ ✔ ✔

how what

slide-8
SLIDE 8

CARROT CAKE Serves: 18 20 Calories: 575 350 1. 2. 3.

what

✗ ✗

slide-9
SLIDE 9

CARROT CAKE Serves: 18 20 Calories: 575 350 1. 2. 3.

what how

✗ ✗

⊙⊙

???

slide-10
SLIDE 10

CARROT CAKE Serves: 18 Calories: 575

how what

a solution

constraint constraint solver solver

slide-11
SLIDE 11

CARROT CAKE Serves: 18 20 Calories: 575 350

how what

a solution

constraint constraint solver solver

✗ ✗

slide-12
SLIDE 12

constraint constraint solver solver

slide-13
SLIDE 13

constraint constraint solver solver

perforGance exJressivitL

☹ ☹

slide-14
SLIDE 14

MODULE bakeCarrotCake MAIN var timer, pan, bowl, grease, flour;

  • ven.start();

WHILE (oven.heat < 350) END WHILE; add(&pan, &grease); add(&pan, &flour); add(&bowl, &egg1); add(&bowl, &vanilla); add(&bowl, &carrots); timer.start(); place(&bowl, &oven); WHILE (timer.time() < 50) if (toothPickInCenterOfCake() && itComesOutClean()) { break; /* HACK FIXME */ } END WHILE; timer.reset(); WHILE (timer.time() < 10) END WHILE; remove(&bowl, &over); END

fallback to… ugly... works, fast!

slide-15
SLIDE 15

backg4ound

slide-16
SLIDE 16

backg4ound

First purely declarative prog4amming system?

slide-17
SLIDE 17

Ivan Sutherland’s Sketchpad - 1961

slide-18
SLIDE 18

Ivan Sutherland’s Sketchpad - 1961

inspiration method

slide-19
SLIDE 19
slide-20
SLIDE 20

solution

slide-21
SLIDE 21

prog4am

slide-22
SLIDE 22

prog4am

constraints

slide-23
SLIDE 23

constraints

prog4am

UI to interact w/ const4aints

slide-24
SLIDE 24

specific solvers

prog4am

coded in imperative langZage

API in IMP to define const4aints & how to solve constraints

slide-25
SLIDE 25

constraints constraints imperative imperative code code

prog4am

ü flexbilitL ü efficiency ü practicalitL ü modularitL ü understandabilitL ü ex0ensibilitL ü emergent behavior

code

{

SMT SAT numeric …

slide-26
SLIDE 26

prog4am

constraints constraints imperative imperative code code

slide-27
SLIDE 27

prog4am

  • 1. class definitions
  • data
  • constraint
  • 2. data
  • 3. continuous behaviors
  • constraints
  • 4. discrete behaviors (events)
  • trigger
  • handler
  • add/remove
  • data/constraint
slide-28
SLIDE 28

constraints

prog4am

API to interact w/ const4aints

slide-29
SLIDE 29
  • 2. data
slide-30
SLIDE 30
  • 3. const4aints
slide-31
SLIDE 31
  • 4. events
slide-32
SLIDE 32

constraints

prog4am

UI to interact w/ const4aints

slide-33
SLIDE 33

specific solvers

prog4am

coded in imperative langZage

API in IMP to define const4aints & how to solve constraints

slide-34
SLIDE 34

Defining a Const4aint

p1 p2 l

slide-35
SLIDE 35

Solving

constraint in isolation

slide-36
SLIDE 36

Solving a Const4aint

p1 p2 l

slide-37
SLIDE 37

Solving

constraint in isolation

slide-38
SLIDE 38

Merging Solutions

slide-39
SLIDE 39

Solving

constraint in isolation

iterative (relaxation)

hardcoded

slide-40
SLIDE 40

Solving

slide-41
SLIDE 41

Demo: Benefits

slide-42
SLIDE 42

Related Work

vs.

code const4aints const4aints code

prog4am prog4am

Mixed Prog4amming e.g. Const4aint Imperative Prog4amming (CIP) ‘90 Const4aint as a Desig7 Pa9er7 (CDP)

always x + y = 100 y := 40;

slide-43
SLIDE 43

h9J://www.cdglabs.org/sketchpad14

Thank you!

slide-44
SLIDE 44
  • 4. events
slide-45
SLIDE 45
  • 4. events
slide-46
SLIDE 46

Execution…