real time embedded convex optimization
play

Real-Time Embedded Convex Optimization Stephen Boyd joint work with - PowerPoint PPT Presentation

Real-Time Embedded Convex Optimization Stephen Boyd joint work with Michael Grant, Jacob Mattingley, Yang Wang Electrical Engineering Department, Stanford University Spencer Schantz Lecture, Lehigh University, 12/6/10 Outline Real-time


  1. Real-Time Embedded Convex Optimization Stephen Boyd joint work with Michael Grant, Jacob Mattingley, Yang Wang Electrical Engineering Department, Stanford University Spencer Schantz Lecture, Lehigh University, 12/6/10

  2. Outline • Real-time embedded convex optimization • Examples • Parser/solvers for convex optimization • Code generation for real-time embedded convex optimization Spencer Schantz Lecture, Lehigh University, 12/6/10 1

  3. Embedded optimization • embed solvers in real-time applications • i.e. , solve an optimization problem at each time step • used now for applications with hour/minute time-scales – process control – supply chain and revenue management – trading Spencer Schantz Lecture, Lehigh University, 12/6/10 2

  4. What’s new embedded optimization at millisecond/microsecond time-scales millions traditional problems → → problem size − thousands ← our focus tens microseconds seconds hours days solve time − → Spencer Schantz Lecture, Lehigh University, 12/6/10 3

  5. Applications • real-time resource allocation – update allocation as objective, resource availabilities change • signal processing – estimate signal by solving optimization problem over sliding window – replace least-squares estimates with robust (Huber, ℓ 1 ) versions – re-design (adapt) coefficients as signal/system model changes • control – closed-loop control via rolling horizon optimization – real-time trajectory planning • all of these done now, on long (minutes or more) time scales but could be done on millisecond/microsecond time scales Spencer Schantz Lecture, Lehigh University, 12/6/10 4

  6. Outline • Real-time embedded convex optimization • Examples • Parser/solvers for convex optimization • Code generation for real-time embedded convex optimization Spencer Schantz Lecture, Lehigh University, 12/6/10 5

  7. Multi-period processor speed scheduling • processor adjusts its speed s t ∈ [ s min , s max ] in each of T time periods • energy consumed in period t is φ ( s t ) ; total energy is E = � T t =1 φ ( s t ) • n jobs – job i available at t = A i ; must finish by deadline t = D i – job i requires total work W i ≥ 0 • S ti ≥ 0 is effective processor speed allocated to job i in period t D i n � � S ti ≥ W i s t = S ti , i =1 t = A i Spencer Schantz Lecture, Lehigh University, 12/6/10 6

  8. Minimum energy processor speed scheduling • choose speeds s t and allocations S ti to minimize total energy E E = � T minimize t =1 φ ( s t ) s min ≤ s t ≤ s max , subject to t = 1 , . . . , T s t = � n i =1 S ti , t = 1 , . . . , T � D i t = A i S ti ≥ W i , i = 1 , . . . , n • a convex problem when φ is convex • more sophisticated versions include – multiple processors – other constraints (thermal, speed slew rate, . . . ) – stochastic models for (future) data Spencer Schantz Lecture, Lehigh University, 12/6/10 7

  9. Example • T = 16 periods, n = 12 jobs • s min = 1 , s max = 6 , φ ( s t ) = s 2 t • jobs shown as bars over [ A i , D i ] with area ∝ W i 40 12 35 10 30 25 8 φ t ( s t ) job i 20 6 15 4 10 2 5 0 0 0 1 2 3 4 5 6 7 0 2 4 6 8 10 12 14 16 18 s t t Spencer Schantz Lecture, Lehigh University, 12/6/10 8

  10. Optimal and uniform schedules • uniform schedule: S ti = W i / ( D i − A i ) ; gives E unif = 374 . 1 ti gives E ⋆ = 167 . 1 • optimal schedule S ⋆ optimal uniform 6 6 5 5 4 4 s t s t 3 3 2 2 1 1 0 0 0 2 4 6 8 10 12 14 16 18 0 2 4 6 8 10 12 14 16 18 t t Spencer Schantz Lecture, Lehigh University, 12/6/10 9

  11. Minimum time control with active vibration supression F T • force F ( t ) moves object modeled as 3 masses (2 vibration modes) • tension T ( t ) used for active vibration supression • goal: move object to commanded position as quickly as possible, with | F ( t ) | ≤ 1 , | T ( t ) | ≤ 0 . 1 Spencer Schantz Lecture, Lehigh University, 12/6/10 10

  12. Ignoring vibration modes • treat object as single mass; apply only F • analytical (‘bang-bang’) solution 3 1 0.5 F ( t ) 2.5 0 −0.5 2 −1 y 3 ( t ) −2 0 2 4 6 8 10 12 14 16 18 20 t 1.5 0.1 1 0.05 T ( t ) 0 0.5 −0.05 −0.1 0 −2 0 2 4 6 8 10 12 14 16 18 20 −2 0 2 4 6 8 10 12 14 16 18 20 t t Spencer Schantz Lecture, Lehigh University, 12/6/10 11

  13. With vibration modes • no analytical solution, but reduces to a quasiconvex problem • can be solved by solving a small number of convex problems 3 1 0.5 F ( t ) 2.5 0 −0.5 2 −1 y 3 ( t ) −2 0 2 4 6 8 10 12 14 16 18 20 t 1.5 0.1 1 0.05 T ( t ) 0 0.5 −0.05 −0.1 0 −2 0 2 4 6 8 10 12 14 16 18 20 −2 0 2 4 6 8 10 12 14 16 18 20 t t Spencer Schantz Lecture, Lehigh University, 12/6/10 12

  14. Grasp force optimization • choose K grasping forces on object to – resist external wrench (force and torque) – respect friction cone constraints – minimize maximum grasp force • convex problem (second-order cone program or SOCP): max i � f ( i ) � 2 minimize max contact force i Q ( i ) f ( i ) = f ext � subject to force equillibrium i p ( i ) × ( Q ( i ) f ( i ) ) = τ ext � torque equillibrium � 1 / 2 � µ i f ( i ) f ( i )2 + f ( i )2 ≥ friction cone constraints z x y variables f ( i ) ∈ R 3 , i = 1 , . . . , K (contact forces) Spencer Schantz Lecture, Lehigh University, 12/6/10 13

  15. Example Spencer Schantz Lecture, Lehigh University, 12/6/10 14

  16. Grasp force optimization solve times • example with K = 5 fingers (grasp points) • reduces to SOCP with 15 vars, 6 eqs, 5 3-dim SOCs • custom code solve time: 50 µ s (SDPT3: 100ms) Spencer Schantz Lecture, Lehigh University, 12/6/10 15

  17. Robust Kalman filtering • estimate state of a linear dynamical system driven by IID noise • sensor measurements have occasional outliers (failures, jamming, . . . ) • model: x t +1 = Ax t + w t , y t = Cx t + v t + z t – w t ∼ N (0 , W ) , v t ∼ N (0 , V ) – z t is sparse ; represents outliers, failures, . . . • (steady-state) Kalman filter (for case z t = 0 ): – time update: x t +1 | t = A ˆ ˆ x t | t x t | t − 1 + L ( y t − C ˆ – measurement update: x t | t = ˆ ˆ x t | t − 1 ) • we’ll replace measurement update with robust version to handle outliers Spencer Schantz Lecture, Lehigh University, 12/6/10 16

  18. Measurement update via optimization • standard KF: ˆ x t | t is solution of quadratic problem v T V − 1 v + ( x − ˆ x t | t − 1 ) T Σ − 1 ( x − ˆ minimize x t | t − 1 ) subject to y t = Cx + v with variables x , v (simple analytic solution) • robust KF: choose ˆ x t | t as solution of convex problem v T V − 1 v + ( x − ˆ x t | t − 1 ) T Σ − 1 ( x − ˆ x t | t − 1 ) + λ � z � 1 minimize subject to y t = Cx + v + z with variables x , v , z (requires solving a QP) Spencer Schantz Lecture, Lehigh University, 12/6/10 17

  19. Example • 50 states, 15 measurements • with prob. 5%, measurement components replaced with ( y t ) i = ( v t ) i • so, get a flawed measurement ( i.e. , z t � = 0 ) every other step (or so) Spencer Schantz Lecture, Lehigh University, 12/6/10 18

  20. State estimation error � x − ˆ x t | t � 2 for KF (red); robust KF (blue); KF with z = 0 (gray) 0.5 Spencer Schantz Lecture, Lehigh University, 12/6/10 19

  21. Robust Kalman filter solve time • robust KF requires solution of QP with 95 vars, 15 eqs, 30 ineqs • automatically generated code solves QP in 120 µ s (SDPT3: 120 ms) • standard Kalman filter update requires 10 µ s Spencer Schantz Lecture, Lehigh University, 12/6/10 20

  22. Linearizing pre-equalizer • linear dynamical system with input saturation y ∗ h • we’ll design pre-equalizer to compensate for saturation effects y u v equalizer ∗ h Spencer Schantz Lecture, Lehigh University, 12/6/10 21

  23. Linearizing pre-equalizer ∗ h u e v equalizer ∗ h • goal: minimize error e (say, in mean-square sense) • pre-equalizer has T sample look-ahead capability Spencer Schantz Lecture, Lehigh University, 12/6/10 22

  24. • system: x t +1 = Ax t + B sat ( v t ) , y t = Cx t x ref t +1 = Ax ref y ref = Cx ref • (linear) reference system: + Bu t , t t t • e t = Cx ref − Cx t t x t = x ref • state error ˜ − x t satisfies t x t +1 = A ˜ ˜ x t + B ( u t − v t ) , e t = C ˜ x t • to choose v t , solve QP � t + T τ = t e 2 x T minimize τ + ˜ t + T +1 P ˜ x t + T +1 subject to x τ +1 = A ˜ ˜ x τ + B ( u τ − v τ ) , e τ = C ˜ x τ , τ = t, . . . , t + T | v τ | ≤ 1 , τ = t, . . . , t + T P gives final cost; obvious choice is output Grammian Spencer Schantz Lecture, Lehigh University, 12/6/10 23

  25. Example • state dimension n = 3 ; h decays in around 35 samples • pre-equalizer look-ahead T = 15 samples • input u random, saturates ( | u t | > 1 ) 20% of time Spencer Schantz Lecture, Lehigh University, 12/6/10 24

  26. Outputs desired (black), no compensation (red), equalized (blue) 2.5 0 −2.5 Spencer Schantz Lecture, Lehigh University, 12/6/10 25

  27. Errors no compensation (red), with equalization (blue) 0.75 0 −0.75 Spencer Schantz Lecture, Lehigh University, 12/6/10 26

  28. Inputs no compensation (red), with equalization (blue) 2.5 0 −2.5 Spencer Schantz Lecture, Lehigh University, 12/6/10 27

Recommend


More recommend