130 likes | 221 Vues
Representing real-world coffee ordering problem into an abstract model for optimization. Explore relevant information, variables, fitness functions, and constraints for maximizing caffeine and sugar jolt per dollar.
E N D
Representing problems Abstraction from the messy real world to the ordered simplicity of the model
Abstraction • Representing the problem for processing • What information is relevant? • How should it be operationalized? • Data • Relations • Processes • What information is irrelevant? • The puzzles
My real world problem How should I order my coffee at Tim Horton’s to get maximum jolt per dollar from caffeine and sugar?
Variables • set of n controllable parameters V = {x1, x2, x3, …, xn } each variable xi has a set of possible values, domain Di e.g., V = { x1, x2, x3 } x1 D1 = {small, medium, large, extralarge} x2 D2 = {coffee, decaf} x3 D3 = {black, cream, sugar, doubledouble}
Problem Space • set of all possible combinations of variable values • dimension of space n: number of variables • size of space: |D1|x|D2|x…x|Dn| e.g., dimension = 3 size = 4 x 2 x 4 = 32 V = { x1, x2, x3 } x1 D1 = {small, medium, large, extralarge} x2 D2 = {coffee, decaf} x3 D3 = {black, cream, sugar, doubledouble}
small med large xlg coffee decaf black cream sugar dbldbl Problem Space (medium, coffee, dbldbl) V = { x1, x2, x3 } x1 D1 = {small, medium, large, extralarge} x2 D2 = {coffee, decaf} x3 D3 = {black, cream, sugar, doubledouble}
Fitness • the objective function • problem outcome as a function of the variables: f(x1, x2, x3,…xn) • goal: optimize (maximize or minimize) f e.g., maximize stimulation per dollar from caffeine and sugar V = { x1, x2, x3 } x1 D1 = {small, medium, large, extralarge} x2 D2 = {coffee, decaf} x3 D3 = {black, cream, sugar, doubledouble}
small med large xlg coffee decaf black cream sugar dbldbl Constraints • rules C(V) that eliminate some points in the problem space from consideration e.g., must play roll-up-the-rim
Abstraction - “Operationalizing” • representation of fitness and constraints for evaluation and search e.g. x1 = (cost, ml), x2= bool, x3 = (%coffee,%sugar) D1 = {(1.00,275),(1.15,325),(1.25,400),(1.39,550)} D2 = {1,0} D3 = {(100,0),(90,0),(100,100),(80,200)} fitness f= C(x1.ml*x2*x3.%coffee)+S(x1.ml*x3.%sugar) x1.cost constraint:x1 (1.00,275) V = { x1, x2, x3 } x1 D1 = {small, medium, large, extralarge} x2 D2 = {coffee, decaf} x3 D3 = {black, cream, sugar, doubledouble}
Exhaustive search bestFitness = - (assume maximize) bestV for all x1 D1, x2 D2, x3 D3,…xn Dn if (x1, x2,x3,…xn satisfy constraints C(V)) fitness = f(x1, x2,x3,…xn) if (fitness > bestFitness) bestFitness = fitness bestV = {x1, x2,x3,…xn} return bestFitness, bestV
Exhaustive search, e.g. bestFitness = - //jolt per $$ bestV for x1 D1 if (x1 (1.00,275)) // constraint for x2 D2 for x3 D3 fitness = C(x1.ml*x2*x3.%coffee)+S(x1.ml*x3.%sugar) x1.cost if (fitness > bestFitness) bestFitness = fitness bestV = {x1, x2,x3} return bestFitness, bestV
Summary • Parameters, dimension, solution space • Objective - fitness or evaluation function • Constraints - impossible points in solution space • Finding point in space with optimal fitness • No algorithm to calculate point • Space too large to search --> optimization methods with tradeoffs
Puzzles are Us SEND +MORE MONEY Each letter represents a different digit No leading zero’s Sum is correct Find assignment of digits to letters