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; 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
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.
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.
CARROT CAKE Serves: 18 Calories: 575 1. Preheat oven to 350 degrees F (175 degrees C). Grease and flour 1K-1M LoC 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 meaning ?? ☹ completely.
CARROT CAKE what Serves: 18 Calories: 575 how 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.
CARROT CAKE what ✗ Serves: 18 20 ✗ Calories: 575 350 1. 2. 3.
CARROT CAKE what ✗ Serves: 18 20 ✗ Calories: 575 350 how 1. ??? 2. ⊙ � ⊙ 3.
CARROT CAKE what Serves: 18 Calories: 575 ✗ how constraint constraint solver solver a solution
CARROT CAKE what ✗ Serves: 18 20 ✗ Calories: 575 350 ✗ how constraint constraint solver solver a solution
constraint constraint solver solver ☹
constraint constraint solver solver ☹ ☹ perforGance exJressivitL
MODULE bakeCarrotCake fallback to… MAIN var timer, pan, bowl, grease, flour; oven.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; ugly... timer.reset(); WHILE (timer.time() < 10) END WHILE; works, fast! remove(&bowl, &over); END
backg4ound
backg4ound First purely declarative prog4amming system?
Ivan Sutherland’s Sketchpad - 1961
inspiration Ivan Sutherland’s Sketchpad - 1961 method
solution
prog4am
prog4am constraints
prog4am constraints UI to interact w/ const4aints
prog4am constraints API in IMP specific solvers to define coded in const4aints imperative langZage & how to solve
prog4am ü modularitL constraints constraints ü understandabilitL ü ex0ensibilitL imperative imperative ü emergent behavior code code ü flexbilitL ü efficiency ü practicalitL code SMT SAT numeric … {
prog4am constraints constraints imperative imperative code code
prog4am 1. class definitions data • constraint • 2. data 3. continuous behaviors constraints • 4. discrete behaviors (events) trigger • handler • add/remove • data/constraint •
API to interact prog4am constraints w/ const4aints
2. data
3. const4aints
4. events
UI to interact prog4am constraints w/ const4aints
prog4am constraints API in IMP specific solvers to define coded in const4aints imperative langZage & how to solve
l p1 p2 Defining a Const4aint
Solving constraint in isolation
l p1 p2 Solving a Const4aint
Solving constraint in isolation
Merging Solutions
Solving constraint in isolation hardcoded iterative (relaxation)
Solving
Demo: Benefits
Related Work Mixed Prog4amming Const4aint as a Desig7 e.g. Const4aint Imperative Pa9er7 (CDP) Prog4amming (CIP) ‘90 const4aints const4aints always vs. x + y = code 100 code y := 40; prog4am prog4am
Thank you! h9J://www.cdglabs.org/sketchpad14
4. events
4. events
Execution…
Recommend
More recommend