1 Lemkes Algorithm: The Hammer in Your Math Toolbox? Chris Hecker definition six, inc.

Slides:



Advertisements
Similar presentations
TWO STEP EQUATIONS 1. SOLVE FOR X 2. DO THE ADDITION STEP FIRST
Advertisements

3.6 Support Vector Machines
Angstrom Care 培苗社 Quadratic Equation II
If...Then? Today I can construct function tables with if...then statements using simple equations.
© 2008 Pearson Addison Wesley. All rights reserved Chapter Seven Costs.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Multicriteria Decision-Making Models
Chapter 1 The Study of Body Function Image PowerPoint
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 6 Author: Julia Richards and R. Scott Hawley.
Author: Julia Richards and R. Scott Hawley
1 Copyright © 2013 Elsevier Inc. All rights reserved. Appendix 01.
Properties Use, share, or modify this drill on mathematic properties. There is too much material for a single class, so you’ll have to select for your.
UNITED NATIONS Shipment Details Report – January 2006.
February 21, 2002 Simplex Method Continued
© 2001 by Charles E. Leiserson Introduction to AlgorithmsDay 17 L9.1 Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 9 Prof. Charles E. Leiserson.
Thursday, March 7 Duality 2 – The dual problem, in general – illustrating duality with 2-person 0-sum game theory Handouts: Lecture Notes.
February 7, 2002 A brief review of Linear Algebra Linear Programming Models Handouts: Lecture Notes.
Tuesday, March 5 Duality – The art of obtaining bounds – weak and strong duality Handouts: Lecture Notes.
Properties of Real Numbers CommutativeAssociativeDistributive Identity + × Inverse + ×
Exit a Customer Chapter 8. Exit a Customer 8-2 Objectives Perform exit summary process consisting of the following steps: Review service records Close.
FACTORING ax2 + bx + c Think “unfoil” Work down, Show all steps.
1 Outline relationship among topics secrets LP with upper bounds by Simplex method basic feasible solution (BFS) by Simplex method for bounded variables.
Robust Window-based Multi-node Technology- Independent Logic Minimization Jeff L.Cobb Kanupriya Gulati Sunil P. Khatri Texas Instruments, Inc. Dept. of.
Solve Multi-step Equations
REVIEW: Arthropod ID. 1. Name the subphylum. 2. Name the subphylum. 3. Name the order.
Mathematics for Economics Beatrice Venturi 1 Economics Faculty CONTINUOUS TIME: LINEAR DIFFERENTIAL EQUATIONS Economic Applications LESSON 2 prof. Beatrice.
EC220 - Introduction to econometrics (chapter 1)
Pole Placement.
Discrete Math Recurrence Relations 1.
Copyright © Cengage Learning. All rights reserved.
1 Column Generation. 2 Outline trim loss problem different formulations column generation the trim loss problem master problem and subproblem in column.
1 Chapter 10 Multicriteria Decision-Marking Models.
Shadow Prices vs. Vickrey Prices in Multipath Routing Parthasarathy Ramanujam, Zongpeng Li and Lisa Higham University of Calgary Presented by Ajay Gopinathan.
EU market situation for eggs and poultry Management Committee 20 October 2011.
An Application of Linear Programming Lesson 12 The Transportation Model.
1 CMSC421: Principles of Operating Systems Nilanjan Banerjee Principles of Operating Systems Acknowledgments: Some of the slides are adapted from Prof.
Outline Minimum Spanning Tree Maximal Flow Algorithm LP formulation 1.
2 |SharePoint Saturday New York City
Applications Problem Solving. 6/25/2013 Applications 2 Four-step Method 1. Define variables Name the quantities to be found Write these down Example:
Name Convolutional codes Tomashevich Victor. Name- 2 - Introduction Convolutional codes map information to code bits sequentially by convolving a sequence.
Solving Equations How to Solve Them
Equations of Lines Equations of Lines
Factor P 16 8(8-5ab) 4(d² + 4) 3rs(2r – s) 15cd(1 + 2cd) 8(4a² + 3b²)
Basel-ICU-Journal Challenge18/20/ Basel-ICU-Journal Challenge8/20/2014.
1..
Joint work with Andre Lieutier Dassault Systemes Domain Theory and Differential Calculus Abbas Edalat Imperial College Oxford.
Optimization 1/33 Radford, A D and Gero J S (1988). Design by Optimization in Architecture, Building, and Construction, Van Nostrand Reinhold, New York.
© 2012 National Heart Foundation of Australia. Slide 2.
Abbas Edalat Imperial College London Contains joint work with Andre Lieutier (AL) and joint work with Marko Krznaric (MK) Data Types.
Splines I – Curves and Properties
Copyright 2006 John Wiley & Sons, Inc. Beni Asllani University of Tennessee at Chattanooga Operations Management - 5 th Edition Chapter 13 Supplement Roberta.
Perfect Competition.
CS 240 Computer Programming 1
Model and Relationships 6 M 1 M M M M M M M M M M M M M M M M
Slippery Slope
Analyzing Genes and Genomes
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
Chemical Reaction Engineering (CRE) is the field that studies the rates and mechanisms of chemical reactions and the design of the reactors in which they.
Intracellular Compartments and Transport
PSSA Preparation.
Essential Cell Biology
Chemical Reaction Engineering (CRE) is the field that studies the rates and mechanisms of chemical reactions and the design of the reactors in which they.
Profile. 1.Open an Internet web browser and type into the web browser address bar. 2.You will see a web page similar to the one on.
State Variables.
The Pumping Lemma for CFL’s
Chapter 5 The Mathematics of Diversification
Compiler Construction
Link State Routing Jean-Yves Le Boudec Fall
Presentation transcript:

1 Lemkes Algorithm: The Hammer in Your Math Toolbox? Chris Hecker definition six, inc.

2 First, a Word About Hammers requirements for this to be a good idea a way of transforming problems into nails (MLCPs) a hammer (Lemkes algorithm) lots of advanced info + one hour = something has to give majority of lecture is motivating you to care about the hammer by showing you how useful nails can be make you hunger for more info post-lecture very little on how the hammer works in this hour If the only tool you have is a hammer, you tend to see every problem as a nail. Abraham Maslow

3 Hammers (cont.) by definition, not the optimal way to solve problems, BUT –computers are very fast these days –often dont care about optimality prepro, prototypes, tools, not a profile hotspot, etc. –can always move to optimal solution after you verify its a problem you actually want to solve

4 What are advanced game math problems? problems that are ammenable to mathematical modeling state the problem clearly state the desired solution clearly describe the problem with equations so a proposed solutions quality is measurable figure out how to solve the equations why not hack it? I believe better modeling is the future of game technology development (consistency, not reality)

5 Prerequisites linear algebra vector, matrix symbol manipulation at least calculus concepts what derivatives mean comfortable with math notation and concepts

6 Overview of Lecture random assortment of example problems breifly mentioned 5 specific example problems in some depth including one that I ran into recently and how I solved it generalize the example models transform them all to MLCPs solve MLCPs with Lemkes algorithm

7 A Look Forward linear equations Ax = b linear inequalities Ax >= b linear programming min c T x s.t. Ax >= b, etc. quadratic programming min ½ x T Qx + c T x s.t. Ax >= b Dx = e linear complimentarity problem a = Af + b a >= 0, f >= 0 a i f i = 0

8 Applications to Games Applications to Games graphics, physics, ai, even ui computational geometry visibility contact curve fitting constraints integration graph theory network flow economics site allocation game theory IK machine learning image processing

9 Applications to Games (cont.) dont forget... –The Elastohydrodynamic Lubrication Problem –Solving Optimal Ownership Structures The two parties establish a relationship in which they exchange feed ingredients, q, and manure, m.

10 Specific Examples #1a: Ease Cubic Fitting warm up with an ease curve cubic x(t)=at 3 +bt 2 +ct+d x(t)=3at 2 +2bt+c 4 unknowns a,b,c,d (DOFs) we get to set, we choose: x(0) = 0, x(1) = 1 x(0) = 0, x(1) = 0 1 x t 0 0 1

11 Specific Examples #1a: Ease Cubic Fitting (cont.) x(t)=at 3 +bt 2 +ct+d, x(t)=3at 2 +2bt+c x(0) = a0 3 +b0 2 +c0+d = d = 0 x(1) = a1 3 +b1 2 +c1+d = a+b+c+d = 1 x(0) = 3a0 2 +2b0+c = c = 0 x(1) = 3a1 2 +2b1+c = 3a + 2b + c = 0

12 Specific Examples #1a: Ease Cubic Fitting (cont.) d = 0, a+b+c+d = 1, c = 0, 3a + 2b + c = 0 a+b=1, 3a+2b=0 a=1-b => 3(1-b)+2b = 3-3b+2b = 3-b = 0 b=3, a=-2 x(t) = 3t 2 - 2t 3

13 Specific Examples #1a: Ease Cubic Fitting (cont.) or, x(0) = d = 0 x(1) = a + b + c + d = 1 x(0) = c = 0 x(1) = 3a + 2b + c = x(0) x(1) x(0) x(1) abcdabcd == Ax = b, a system of linear equations (can solve for any rhs)

14 Specific Examples #1b: Cubic Spline Fitting same technique to fit higher order polynomials, but they wiggle piecewise cubic is better natural cubic spline x i (t i )=x i x i (t i+1 )=x i+1 x i (t i ) - x i-1 (t i ) = 0 x i (t i ) - x i-1 (t i ) = 0 there is coupling between the splines, must solve simultaneously x0x0 x1x1 x2x2 x3x3 t0t0 t1t1 t2t2 t3t3 4 DOF per spline –2 endpoint eqns per spline –4 derivative eqns for inside points –2 missing eqns = endpoint slopes

15 Specific Examples #1b: Cubic Spline Fitting (cont.) a0b0c0d0a1b1c1d1...a0b0c0d0a1b1c1d1... x0x100x1x200...x0x100x1x = x i (t i )=x i x i (t i+1 )=x i+1 x i (t i ) - x i-1 (t i ) = 0 x i (t i ) - x i-1 (t i ) = Ax = b, a system of linear equations

16 Specific Examples #2: Minimum Cost Network Flow what is the cheapest flow route(s) from sources to sinks? model, want to minimize cost c ij = cost of i to j arc b i = is supply/demand, sum(b i )=0 x ij = quantity shipped on i to j arc x *k = sum(x ik ) = flow into k x k* = sum(x ki ) = flow out of k flow balance: x *k - x k* = -b k one-way streets: x ij >= 0

17 Specific Examples #2: Minimum Cost Network Flow (cont.) min cost: minimize c T x the sum of the costs times the quantities shipped (c T x = c ·x) flow balance is coupling: matrix x *k - x k* = -b k x ac x ad x ae x ba x bc x be x db. = … …... babbbcbd...babbbcbd...b minimize c T x subject to Ax = -b x >= 0 a linear programming problem

18 Specific Examples #3: Points in Polys point in convex poly defined by planes n 1 · x >= d 1 n 2 · x >= d 2 n 3 · x >= d 3 farthest point in a direction in poly, c: n1n1 n2n2 n3n3 x Ax >= b, linear inequality min -c T x s.t. Ax >= b linear programming

19 Specific Examples #3: Points in Polys (cont.) closest point in two polys min (x 2 -x 1 ) 2 s.t. A 1 x 1 >= b 1 A 2 x 2 >= b 2 stack em in blocks, Ax >= b n1n1 n2n2 x1x1 n3n3 x2x2 x1x2x1x2 x = A 1 A 2 A = what about (x 2 -x 1 ) 2, how do we stack it? b1b2b1b2 b =

20 Specific Examples #3: Points in Polys (cont.) how do we stack x 1,x 2 into single x given (x 2 -x 1 ) 2 = x x 2 x 1 +x 1 2 x1x2x1x2 x 1 T x 2 T = x x 2 x 1 +x 1 2 = x T Qx min x T Qx s.t. Ax >= b a quadratic programming problem x 2 = x T x = x · x 1 = identity matrix

21 Specific Examples #3: Points in Polys (cont.) more points, more polys! min (x 2 -x 1 ) 2 + (x 3 -x 2 ) 2 + (x 3 -x 1 ) 2 x1x2x3x1x2x3 x 1 T x 2 T x 3 T min x T Qx s.t. Ax >= b another quadratic programming problem same form for all these poly problems never specified 2d, 3d, 4d, nd! = x T Qx

22 Specific Examples #4: Contact model like IK constraints a = Af + b a >= 0, no penetrating f >= 0, no pulling a i f i = 0, complementarity (cant push if leaving) f1f1 f2f2 a1a1 a2a2 f1f1 f2f2 a1a1 a2a2 linear complementarity problem its a mixed LCP if some a i = 0, f i free, like for equality constraints

23 Specific Examples #5: Joint Limits in CCD IK how to do child-child constraints in CCD? parent-child are easy, but need a way to couple two children to limit them relative to each other how to model this & handle all the cases? define d n = g n - a n min (x 1 - d 1 ) 2 + (x 2 - d 2 ) 2 s.t. c 1min <= a 1 +x 1 - a 2 -x 2 <= c 1max parent-child are easy in this framework: c 2min <= a 1 +x 1 <= c 2max another quadratic program: min x T Qx s.t. Ax >= b a1a1 g1g1 a2a2 g2g2 a1a1 g1g1

24 What Unifies These Examples? linear equations Ax = b linear inequalities Ax >= b linear programming min c T x s.t. Ax >= b, etc. quadratic programming min ½ x T Qx + c T x s.t. Ax >= b Dx = e linear complimentarity problem a = Af + b a >= 0, f >= 0 a i f i = 0

25 QP is a Superset of Most quadratic programming min ½x T Qx + c T x s.t. Ax >= b Dx = e linear equations Ax = b Q, c, A, b = 0 linear inequalities Ax >= b Q, c, D, e = 0 linear programming min c T x s.t. Ax >= b, etc. Q, etc. = 0 but MLCP is a superset of convex QP!

26 Karush-Kuhn-Tucker Optimality Conditions get us to MLCP for QP form Lagrangian L(x,u,v) = ½ x T Qx + c T x - u T (Ax - b) - v T (Dx - e) for optimality (if convex): L/ x = 0 Ax - b >= 0 Dx - e = 0 u >= 0 u i (Ax-b) i = 0 –this is related to basic calculus min/max f(x) = 0 solve min ½ x T Qx + c T x s.t. Ax - b >= 0 Dx - e = 0

27 Karush-Kuhn-Tucker Optimality Conditions (cont.) L(x,u,v) = ½ x T Qx + c T x - u T (Ax - b) - v T (Dx - e) y = L/ x = Qx + c - A T u - D T v = 0, x free w = Ax - b >= 0, u >= 0, w i u i = 0 s = Dx - e = 0, v free xvuxvu Q -D T -A T D 0 0 A 0 0 = yswysw + c -e -b y, s = 0 x, v free w, u >= 0 w i u i = 0

28 This is an MLCP xvuxvu Q -D T -A T D 0 0 A 0 0 = yswysw + c -e -b y, s = 0 x, v free w, u >= 0 w i u i = 0 a=Afb+ a i f i = 0 some a >= 0, some = 0 some f >= 0, some free (but they correspond so complementarity holds)

29 Modeling Summary a lot of interesting problems can be formulated as MLCPs –model the problem mathematically –transform it to an MLCP –on paper or in code with wrappers –but what about solving MLCPs?

30 Solving MLCPs (where I hope I made you hungry enough for homework) Lemkes Algorithm is only about 2x as complicated as Gaussian Elimination Lemke will solve LCPs, which some of these problems transform into then, doing an advanced start to handle the free variables gives you an MLCP solver, which is just a bit more code over plain Lemkes Algorithm

31 Playing Around With MLCPs PATH, a MCP solver (superset of MLCP!) really stoked professional solver free version for small problems matlab or C OMatrix (Matlab clone) free trial (omatrix.com) only LCPs, but Lemke source is in trial »not a great version, but its really small (two pages of code) and quite useful for learning, with debug output »good place to test out advanced starts my Lemkes + advanced start code not great, but Im happy to share it its in Objective Caml :)

32 References for Lemke, etc. free pdf book by Katta Murty on LCPs, etc. free pdf book by Vanderbei on LPs The LCP, Cottle, Pang, Stone Practical Optimization, Fletcher web has tons of material, papers, complete books, etc. to authors relatively new math means authors are still alive, bonus!

33

34 Specific Examples #5: Constraints for IK compute forces to keep bones together a 1 = A 11 f 1 + b 1 a 1 : relative acceleration at constraint f 1 : force at constraint b 1 : external forces converted to accelerations at constraints A 11 : force/acceleration relation matrix f1f1 fefe

35 Specific Examples #5: Constraints for IK (cont.) multiple bodies gives coupling... a1a2a1a2 A 11 A 12 A 21 A 22 f1f2f1f2 b1b2b1b2 =+ f1f1 f2f2 fefe a = Af + b a = 0 for rigid constraints Af = -b, linear equations