[제1회 과학혁신 컨퍼런스] Embedded Optimization for Real-Time Decision Making – 스티븐 보이드, 스탠포드대 전기공학과 학과장

that that was a little bit much don’t don’t believe that so I’m actually very happy to be here I want to echo Paul’s thanks too to the chain stitute and and to chairman chey for the support which is considerable when I think of 750 graduate graduated PhDs and that’s people working on research and science engineering other areas and doing this in a context of international collaboration it’s absolutely extraordinary it’s a wonderful thing I was very happy to see Stanford well represented in the list and I should say there that it’s a two-way street I hope that those 90 students learned a lot at Stanford I know some did but in fact they very very much enriched Stanford that’s where it word we’re very very blessed to have students from all over the world the most brilliant ones all working together and it’s it’s wonderful so again thanks thanks to the Institute okay so today I’m going to talk about embedded optimization for real-time decision making I should say this is very different very complementary from Paul’s talk which is about physics I’m actually gonna talk about mathematics but it’s gonna be mathematics that is has been is and will be more and more used in a lot of different areas and sometimes in areas where it’s not completely obvious that things are similar or where it’s even being used there we go good so let me just tell you a little bit that it’s gonna have it there’s gonna be a story the whole thing is gonna be a story so it’s gonna have a beginning a middle and an end and all that so it’s gonna be non-technical but I am gonna focus on on the ideas so I will I will focus on what are the ideas in in embed what is on what is embedded optimization what are smart systems how does it work also I’m going to talk about things like how do they fail which is also very interesting so it’s it’s not gonna be too entertaining so I’m sorry but you’re already here and it would be awkward you to leave now unless you’re at the back so you’re you’re now stuck but you will learn about something that affects all of you now and will actually only have more and more effect on people in the future okay so I’ll start by talking about so-called smart systems and then after that I’ll talk a little bit about optimization that’s sort of the mathematical and computational basis of smart systems and then I’ll talk about recourse briefly that’s the idea that you actually learn new things and then can actually act based on the new information and then I’ll wrap up with some comments about where is this going okay so let me start with smart systems well so I’m what I’m defining a smart system it’s not a standard term by the way but I’m defining it to mean it’s a system that it uses mathematical and mathematical algorithms runs on one or more computers or devices uses lots of data typically and then makes real-time decisions right so that’s that’s what I’m gonna call a smart system and I’ll give you some examples and many these are things that have been many of these are things that I’ve been running for decades others are things that are relatively newer right so so the first first example is electrical power generator dispatch right so what happens is in California between midnight and 2:00 a.m. in a bunker predictions are made of how much electricity is gonna meet it in California then a bunch of algorithms are run which determines which then tells each of the 3,100 generators in California how much electricity they should generate in 15-minute increments that’s the way it works okay so that’s the idea and the goal here is to do things like minimize the total cost of generation respect limits on transmission line capacity of course and of course there have to be contingency plans for unplanned outages right so if if one unit of a reactor goes down if a transmission line goes down you still want to be able to make sure that the lights go on in Los Angeles right so this is the this is what’s done and it’s done in a very sophisticated way and it’s done every day so just to give give a rough idea of what this looks like this would be this is a picture of some of the major transmission lines maybe there’s probably seven eight thousand of them or something like that and they’re connecting thirty-one 3100 about 3100 generators and maybe five thousand load points that’s where loads are extracted so it’s a big system and you can understand actually when you see

this why this could not possibly be done by hand anymore which is the way it was done in the 40s and 50s and 60s okay so part of this is of course building a prediction so this is this is from whit’s from a while ago but this will show you there we go so this is actually a prediction this is a prediction made the night before of the electricity use at a certain point actually this is for the aggregate of California right and then the dark curve shows what actually the the what the actual usage was and you can see that this is about whenever this net when this snapshot was pulled was about right here right um by the way this one is the updated one that’s based on one hour before so it’s of course a better prediction next I use forecast this also by the way is done using the types of methods I’ll talk about these very sophisticated machine learning models that predict that will make predictions about you know how much electricity use you’re going to need in the next 15 minutes hour or day okay here’s something very different on the surface and yet for me and you’ll see eventually the it’s it’s it’s basically the same it’s a coin so we go to a hedge fund so we go to a quantitative trading engine and what that’s something that does this on a minute-by-minute basis it could be hourly it could be by milliseconds it could be by days something like that but what it does is it takes forecasts of things like it does estimates of returns risks and transaction costs these depend on a lot of things and then what will happen is it will actually then make a decision of what to buy what to sell and what to hold okay and this is done completely automatically right this is something that used to be done of course by hand and in fact there’s still some people that do this right they they look and they say and that’s typically done where it’s on a much longer timeframe and they would say oh I think this sector is going to outperform so let’s buy some something like that right this has done all automatically and in fact it’s pretty much universally used by all quantitative hedge funds now so okay here’s a quick example it’s from a former student of mine it was at a hedge fund and this is the kind of thing you might want you know that this is this shows you for some period it’s about a year of you know the some index going down and yet despite that the the fund is going up so this is kind of this was a good year since then okay here’s another one also very different again seems very I’ve intentionally picked examples which are extremely diverse so they don’t that’s that’s actually kinda my point is that there’s actually they’re all unified to me they all look exactly the same and it’s a spam filter so here what happens is a message comes in attributes are looked at for example it could be where did it come from it could be word count it could be sophisticated attributes that features that it would actually figure out from your email and then it’ll guess if it’s spam and if it is flag it or even just automatically remove it right so that’s that’s how that works okay here’s an example of a various where I’m highlighting various things that might be noted in it might be features in a spam filter now in fact the features are not this simple they’re they’re actually much more sophisticated than this this is just a sort of illustrate what it might look like and in fact this is actually not very far from what sort of the original spam filters look like they’re way more sophisticated now okay here’s a last one is landing a rocket so same again it’s sort of the same type of problem here you have a rocket I don’t know if you’ve seen the SpaceX landing of the first stage of rockets that’s been happening I guess in in movies since the 1950s now it turns out in real life it hasn’t happened until maybe a few years ago and now several several companies have actually done this quite successfully right so but the idea is you have a rocket coming down and what you’re gonna do is you’re gonna to make your current position and your current momentum so where you where you are and where you’re going and it’ll also make forecasts of the winds that you will encounter between where you are and the landing pad again that’s a forecast it actually you should start seeing some commonalities in all of these things that’s like forecasting the the electricity use in California so you make a forecast of that and based on that you will DIF you’ll you’ll find a sequence of control surface deflections and moderate and Roccat rocket motor thrusts then will actually take you to the landing pad right so this is this is the same thing and you have to take into account all sorts of stuff first of all the physics the rocket dynamics wind limits on your control surface deflections and your rocket motor that kind of thing okay so and here’s a picture if you haven’t seen this you should if I I’m not going to show a video today if I if I were gonna show a video it would have been this because it

is kind of cool so and probably most of you have seen this or if you haven’t just go look this up it’s actually quite yeah by the way they they landed the two the two first stages absolutely simultaneously they had no reason to do that other than just to make it look cool so but they did it anyway so okay so let me talk about some other applications the same area the same types of things come up all over the place it comes up in like engine control it comes up in hybrid vehicle energy management do you turn on the internal combustion engine or do you not if you do what power do you turn it on to that kind of thing recommendation engine again very similar search engines are similar online advertising has moved essentially entire I mean it’s just changed the entire field this is how it works now it’s using these types of things flight management system that’s at a different time scale exactly the the same sort of thing automated real time fraud detection that’s universally used and again it’s the same sorts of ideas same thing you have things like supply chain systems are run exactly the same way you make forecasts of what people are going to order and so for example I can guarantee you that as we speak right now there’s there’s stuff moving to fulfillment centers around the Bay Area where I live that know has ordered yet no one because the models are good enough to make predictions that people are gonna order them they don’t even know they’re gonna order them yet but they’re going to and when they do it’ll be sitting in a fulfillment center outside San Jose okay so these are really spectacular things a revenue management that’s actually a euphemism for how a company can extract as much money as possible from you so and I’m very sorry to report that these are very well developed that’s good for the companies and it’s very bad for you so and it comes up in lots of other areas things like image speech recognition these sorts of things so so these are all very diverse examples they use a bunch of the same ideas and methods okay so now I can tell you with the talk about the talk is about how do these things work of course not gonna tell you the details but I am gonna tell you is like some of the rough ideas about how you know how these things are similar and all that kinda seven what the basic ideas are so you know how are these things similar even though they look very very different what methods do they use I’m gonna tell you something about that we’re also going to talk about how when and why do these things fail which they do by the way sometimes you hear about it and a whole lot of times you don’t hear about it right and then at the end I’m gonna make some predictions about where this is all going but that’s not my expertise and historically my predictions have been quite bad so you should probably ignore I’ll tell you when you can start ignoring what I say okay so that it’ll be later okay so what I’m gonna do now is tell you about optimization this is the core mathematical and algorithmic technologies used in all of these things and here it is so so it’s that’s called mathematical optimization and if the ideas you use mathematics and computers to make good decisions or choices right and so this coined I think brilliantly as by one of the the one of the academic Institute’s that you know that that studies this it’s great it’s like the science of better so it’s actually a very very nice name and it’s very old I mean this goes back this is what calculus is if you think about it right so we you know everyone has been tortured by taking calculus right in the the short story on what’s capital is good for is it’s you know it’s it’s for finding you know the maximum or minimum of a function or something and of course that’s all done using paper and pencil and that’s kind of silly but the point is it’s it’s got a very very long history so if you wanted to think of something you know the original the original optimization you’d go back to the you go back to the 18th century and this might be a picture you’d think of and that there that’s the one equation you might you’re gonna encounter today right so ok however there’s really a new approach and it actually started after about 1948 which actually coincides basically with the development of computers modern electronic computers and it’s this new style is not based on paper and pencil and calculus and all that kind of stuff it’s based on you know algorithm it’s algorithmic it uses powerful computers and it typically will use a lot of data so not not just a handful of things but actually just a ton of data ok and if you wanted a picture to kind of get a rough idea of what this what the feeling of all this is you might think of something like a you know a data center because that’s actually where a lot of this happens right and instead of thinking of some equations from mathematics you might think of some algorithm or computer code that actually is gonna do the optimization right that that’s what you would that’s what you should think of

okay so let me tell you about what optimization is the taxonomy is just just a couple of parts to it the first thing is you’ve got variables and these are the things that you have to choose and in fact sometimes they’re called the decision variables which makes it completely clear what they are they are the things you have to choose that you have a choice of so these are the selections you need to make and you need a list of things that you care about that depend on the choice right so in other words if you are coming up with a schedule you’d have to figure out what’s gonna be the cost of it how long is it gonna cut time to complete this job all sorts of things like that so that you have to list the things that you care about and then you need a model of how your choices affect the things you care about right so if I if I schedule this thing first and I send this to this data center and I do that then it’s gonna take longer or something like that but it’ll be it’ll be cheaper from an energy point of view or something like that so these are that you need a model for that and then the last component you need is you need something that describes your preferences among the choices so you have to be able to say what makes you happy what makes you sad what’s an absolute requirement and not that kind of thing so things what’s acceptable what’s unacceptable so this is this is all the parts to optimization there’s nothing more okay so to put this in you know a little bit more context in the examples if you take generator dispatch so that’s when I’m deciding which of my 3,100 generators in California are gonna be on at what levels maybe some of them will be off maybe some will be on and then I can choose like how much power they generate so here are some things we care about obviously if a generator can only put out 3 gigawatts we can’t ask it to put out more we can’t overload the transmission lines that the transport energy from one place to another we have to meet the required demand we care about the total cost of generation and we may also care about co2 emissions right so these would be the types of things that we’d care about are there are many other things you might care about robustness you would want to be able you’d want to know that that actually it’s resilient to one failure or two failures or something like that so that would be another that would be another thing that you would care about and the model is going to describe how power flows in the network so when I turn on all these generators to various powers it flows and you know it goes to the loads and things like that and that we just that that’s the bottle okay we’d also have a model that would tell us about the cost of generation and the emissions so that’s that’s that’s the model okay now when you describe preferences this is I mean this is sort of an extreme case but people talk about heart constraints right so these this says that some some choices are completely unacceptable right that they’re just they they’re they’re either illegal or impossible that’s typically the extreme okay and then you have an objective function the objective function is more like best effort what best effort is means you’ll take anything but for example the smaller is if it’s something you want to minimize the smaller it is the happier you are and that would typically be a cost a weight a size a power something like that a delay a latency something like that right so that would be that that’s and you’ll take anything but the smaller it is that the better it is and by the way some people maximize things right in economics it’s for example conventional in the field not to minimize like a cost but actually to maximize a utility or a net profit or something like that right so okay and there’s many other ways to describe preferences you can have a prioritized list of what you want and you could or you can have a trade-off among multiple objectives and in fact all real problems involve trade-offs among multiple objectives right but once you know sort of the basics of these sorts of things these actually sort of come for free so that that’s the sort of stuff you can just do easily okay so here’s an example for generator dispatch the constraints would be you have to respect generator limits you can’t overload transmission lines and you have to meet required demand and the objectives you might have to let’s say minimize the cost of generation and the other one would be to minimize the co2 emissions right and you might do something like this the results might be this is made-up but it’s you know it means you have some very let’s say cheap but dirty fuel sources you could use those and the good news is that be cheap and the bad news is you’d be spewing a lot of carbon dioxide and so here you’d get what would be called like an optimal trade-off curve of the two so okay how about trading shares in a quantitative trading engine how does that work how does an in hedge fund how does that work well the variables is going to be the shares of each asset at each moment that you that that you either buy or sell right and so that’s actually typically called the trade list right so that that’s what you have to choose and the constraints would be to respect let’s say legal limits so if you are running a mutual fund you are not

allowed to sell more than you own that’s an example it could be leverage limits your broker could require that you can’t you can’t be levered more than a certain amount the objectives typically our risk minimize some measure of the risk and the other would be of course to maximize some kind of average returned that’s these are this is this is the goal in finance right and the model is going to predict the sort of average return and the risk you’re exposed to as a function of what you do that’s the trade list that’s the X in the optimization problem that’s the variable that you’re gonna choose okay and here you would get something this would be a very typical way people have been looking at plots like this for maybe thirty forty years now and it’s sort of a risk-return optimal trade-off and it says if you if you’re willing to have a risk of you know four percent you can make seven percent return right so this is this is very typical and a lot of people look at that things like this all the time okay spam filter here the variables are actually not things that you do there are actually parameters in a statistical model of an email so that’s what you’re making basically these are the variables you want to choose and the objectives are to you want to minimize the false positive rate so that’s what happens when you declare something is spam but it’s not at the same time you want to minimize the false negative rate which is what happens when you you think something is not spam but it is right and these of course it’s antagonistic right you you you can’t have both of them unless it’s perfect by the way current ones are very near perfect but in fact you can’t have both of these zero for example at the same time and your model is gonna predict the false positive and negative rates right so that’s that’s the idea okay and here would be an example where you could you could trade off the false positive rate versus the false negative rate right so this would be the idea okay so actually this point we’re just gonna do some optimization and it’s actually gonna allow me to make a very important point so what we’re gonna do is this we’re gonna schedule for 200 megawatt hours demand we’re gonna minimize the total cost but I’ve got four generators and here’s their bid this one has 110 megawatt hours for sale at thirty seven dollars per megawatt hour and you know what to do what to do here is completely obvious right that what we should do is we should we should buy all of that all of that we’re up to 190 now and we’d take 10 from here okay and so the point about that is you know a lot of optimization is actually very simple and it can be done just by you know simple reasoning right so it’s very so this is very common by the way if you put together you don’t need a super fancy system and a you know a fancy computer algorithm to do this and that’s okay that’s okay because it it turns out but it’s probably good to admit that you know many optimization problems are actually just very simple however the point is this it takes very little before this problem is not easy for a human being it takes very very little at all so for example if I simply have my generators here you knows my four generators I connect them on a network these are my loads in red each of these is a line that can carry electricity and they’re limited they have limits you can’t pump over one of those lines more than some amount and it turns out already for a problem like this people can’t do it so I mean they can do it they could do something and they could reason about it they could say oh that’s overloaded okay shift some of the power down that line okay we better turn on this generator so people could do stuff like this and they would do a really actually crappy job of this to solve this kind of problem by the way what this this is actually exactly the kind of thing that new optimization methods can handle and they can handle not a tiny problem like this they can handle this with like thousands of generators tens of thousands of lines tens of thousands of load points and you’ll actually get the actual optimal flow right so this is very I mean this is that’s new that’s not that’s not something that existed 50 years ago so it did exist 20 years ago but in fact stuff has only just gotten better and better okay so an example here would go like this right that in this case you get things that are kind of non-obvious at all for example here’s the cheapest generator it’s offering 110 but you can’t you can’t use it all because you can’t get it to the loans because you’re limited by your by your your your capacities of your edges right so here’s for example a transmission line it’s tapped out and so on so this would be the idea so this is again just a baby example but things like this can be solved spectacularly well okay so now

I’m going to talk a little bit about where do models come from right so we’ve talked a lot about models of diverse different fields and the questions where do they come from right well the most common and the most traditional and historic source of models is physics so it’d be physics and things like that so you know these are first principles models like Newton’s laws of you know Mosher if there are dynamics or something like that and you know this is great for a generator dispatch it’s obviously not gonna work for spam right there is no fundamental there’s no Maxwell’s equations for spam and in fact it’s not going to work for anything that involves social systems and that would include all of economics all sorts of other areas like that is there is just there simply is no Maxwell’s equations or fundamental physics of the of social systems they’re they’re social constructs now the other you know there’s a caricature but at the other end you have data fitting methods for producing models right in fact everything is kind of something in between but these would be things like an they’re called black or gray box models and the idea is you guess a form of a model actually when you do this you do not believe it’s the truth right so this this saying that you know all models are wrong and some are useful so the idea is you simply admit from the beginning that you know if you say here’s my might regression model or something no one believes that’s actually the four that correct formula or something you just make a form for it and then what you use use optimization in fact to fit the parameters to observe data so that’s that’s kind of that’s another whole area of how we’re models come from and this is actually the this is the way you are a this is the on-ramp for using optimization for cases where there are not first principles models right I mean some people claim their first principles models for example in economics they’re interesting and useful but and they but they don’t they don’t hold that well right so that’s very common right so now usually the this thing you know these two gross areas of building models that’s actually the source of a lot of confusion so you know that’s what happens when you take a physicist that if you take a well depends the kind of physicist their experimental their okay but if you take a if you take sort of a theoretical physicist and then drop them into a hedge fund basically very bad things happen so then that that’s something that actually has happened I’m not sure what happens the other way around but it’s probably not as bad fine okay the first principles models you know this would be things like you know Newtonian mechanics so spacecraft dynamics electricity transmission how a circuit works if I’m designing a circuit in this if I’m designing this laptop or a circuit in the laptop these are these are just first principles models and the nice thing is they can actually be assembled so they’re compositional I can if I actually know some of these things I can put them together I can test the pieces individually very well that’s that’s great so that’s wonderful fitting a model that looks something like this and this is something everyone has seen you know this is sort of elementary regression I take some data here and I fit a line to it like this I actually have I do not think that this data actually fits exactly on a line I’m simply fitting a model to it now this line has two parameters which is the offset this way and the slope yeah but the types of models that actually people would use these days would have thousands of parameters millions of parameters that’s that’s quite common nowadays of course you can’t draw a picture of it then but these are quite sophisticated models but it but the principle is exactly this the picture is exactly the same you just can’t draw it if there’s a million parameters okay and this is this is actually very important because this this is how you can use optimization in cases where there isn’t a well-established model you build your own model basically okay so let me talk about the things that could go wrong in optimization well I’ve limited it to three and actually these are kind of the big three so the first question is you make an optimization problem but can you solve it that’s the first question and we’ll talk about that briefly the second is you forgot there’s things you care about that you forgot to specify now that’s your fault but we’ll talk about that later and the last one is bad models okay so that’s that’s something these are all sort of kind of very obvious but nevertheless these are the three issues that come up when you’re gonna when you’re gonna field or use optimization in an application right okay so the first is can you solve it right and it’s that’s a complicated question it’s actually a very interesting question and it’s the answer is something like this um whether or not you can solve a problem depends on a lot of things it depends on the size of the problem does it have five variables does it have five million this kind of thing

actually and the really interesting part for me is this it turns out there are very simple looking problems they look very innocent and I could describe them to a high school student and they are extremely difficult to solve okay it would take very powerful computers a long long time to find the answer okay there are other problems there are hard looking problems that look incredibly complicated they have they’re nonlinear they have thousands or tens of thousands or more variables they’re just they look absolutely crazy and here would be an example scheduling power generation for let’s say California that would look like a very large a very complicated problem those problems however because of their mathematical form they’re convex optimization problems they can be solved extremely with total reliability okay so so it’s actually very interesting it means that your intuition does not match your simple intuition does not match actually how hard it is and that’s actually mind research is I’m not gonna say anything more about that but that’s that’s kind of what I do what I and I’ll it’s fun so I I go prospecting I look around for problems most of them are very hard and all of a sudden I’ll find one and I’ll say aha we can solve that so it’s fun um and we actually do find applications that’s the good news about okay all right pitfall two things you forgot to specify okay so so the point about optimism I using optimization actually it’s a very good thing it’s actually a very good exercise because it forces you instead of just jumping in and saying oh you know if you think this sector is gonna go up by some well of course right or you know if the airplane is rolling to the left you know lift your right a L’Orange well of course right what’s very nice about it is that it forces you to articulate what you want and so that’s actually a very good exercise even if you’re then gonna use your istic methods for it it’s a very good exercise it’s and it actually has a lot of very good engineering implications right that if you for example if you can articulate what you want you can actually not design one airplane say or control one airplane but many right because you’ve got you just switch out a new model and you’ve got a new a new new design or something like that okay so another way to say this maybe a negative way is things these mathematical algorithms that run on a laptop or in a data center they have absolutely no sense at all zero they they just solve whatever you two say to do they do so if it that’s supposed to if you’ve forgotten something it doesn’t care it’s not gonna respect it right so so the I’ll turn it around I’d say this you have absolutely no right to complain if you don’t like the result then it’s because you’ve failed to specify it correctly so that’s that’s it so this is usually done in an iterative way where you would do this so you’re not allowed to say something like oh I don’t like that schedule no that’s it because if you’re relying too much on this one generator well if you don’t like that you should have said it that’s the point okay and the last one pitfall three bad models right so let me explain this it’s kind of obvious a model is never right they could sometimes I mean in Newtonian mechanics I mean we could be accurate to like we can make simulations that are accurate to three four significant figures in in when we simulate electronics we can be similarly accurate but in fact in other cases well I mean like in finance as my friends say there extremely happy when they get the sign right so so that’s not you know that’s not four digits or something so the model parameters you know they’re different from the true model there probably isn’t even a true model and there’s all sorts of stuff that you’re ignoring the other thing is of course models change with time and that could be smoothly or abruptly and that’s especially the case in anything that’s going to involve a social system so if you have economics if you’re predicting demand if we’re predicting anything involving human behavior of course that’s gonna change Styles tastes trends come through and things just change right period okay so if you’re lucky with the with a change in the with the change in if you’re lucky when the model changes or it’s wrong everything works but if not it can be very bad right so I’ll give you a quick example so here’s let’s do some finance so I will construct a portfolio and we’ll say what to buy and sell for an existing portfolio and we’ll predict it over the next year this is gonna be this will be our return distribution so I mean the nice part is there’s almost no chance of losing any money and we’re probably gonna make somewhere between you know seven and eight or something percent right so this is this is fine now this is based on a model which we know is wrong right now the good situation is this is when you actually run it you get something like that okay and it’s you know it’s it’s worse I mean there’s now

a you know a good not a good chance but there’s a nice positive chance of losing money you’ve shifted this thing over to the left which is bad um so this but if this happens this is kind of this is the good outcome right this is a good and someone says what happened you were predicting like 8% return and I got six or seven and you go hey well sorry the model wasn’t the model is not quite right so however what can happen and indeed does happen is that something like this this is the bad outcome so this is you you know you make a model based on stuff you use optimization all sort of stuff you choose two things and then what happens is you get something like this and what you’ve just done is you’ve just hired a bunch of kids from Stanford and Berkeley to put together this fancy algorithm and everything like that and congratulations what they’ve done is they’ve something that loses you money quickly right so then usually by the way they kick the kids out and the old the the old people who used to do this the manual way say I told you we should never have hired them and all that kind of stuff that’s typically what happens right by the way what typically happens after that is five years later the kids learn what they forgot to specify they come back and then it’s working better than the than the old car yes so that’s that’s the typical story okay so this is just garbage in garbage out right if if your models are wrong or if they become wrong then the results are useless or worse so you you can have actual I mean these things can have terrible terrible you know disasters can occur because of this right and typically that makes that means optimization gets a very bad name in that field and like I said five years later they come back and they’re now doing it right so I don’t know any case where it didn’t eventually work out I think that’s the right way to say it okay so I should say this on a positive note good practitioners of the stuff I’m talking about are absolutely aware of the issue that the model is not right and they always very carefully check that what they’re suggesting will continue to give benefits even when the model is not right at the very least they will do testing that’ll be the very least but in fact there are very cool methods now where you did you actually solve an optimization problem specifically taking into account the fact that you don’t know the model so that’s that’s some come that’s some relatively current research but it’s actually been going on for maybe a couple of decades okay so quick example this is again from a student of mine ooh is it a hedge fund and you know this is this is the volatility of the some fund he was involved with and the scale is kind of giving away the punchline of course right image but you look at this and if you saw that you would say well yeah the it looked the model looks reasonable you know it’s some kind of you know random walk a Gaussian random walk and all that kind of stuff and you can kind of guess what’s gonna happen that’s what’s hidden right so this is the this is the so-called quant crunch of 2007 and so you’re you’re annualized volatility goes up to something like you know 300 times what your model says it should be so this is a spectacular example of a model simply going bad right so okay what I’ll talk about now is a recourse and it’s actually it’s it so the optimization I’ve talked about so far is sort of static so you have a model and you decide what to trade but in fact for a lot of these things and then I guess this would be you trade and hold right or you’d schedule tomorrow’s generators in California or something like that but in fact in a lot of these problems in fact many of them they happen periodically right so for example you schedule the generators in California for tomorrow that’s based on predictions of things like the weather and demand for electricity those predictions are not right they’re pretty close actually but they’re not right and so what would happen is you would typically maybe every hour every 15 minutes or something like that you would actually get new predictions and then update update your what which generators you’d ask to turn on and turn off and at what level right so that’s how that would work okay that’s the idea of recourse we’ll talk about that and the basic idea is that you’re gonna make so you’re gonna make a sequence of actions that’s kind of the idea and these will be based on information available at that time and that information updates right so and it’s got lots of names it’s called dynamic optimization optimization recourse it’s the entire field of automatic feedback control so that’s a huge field goes back well over 100 years they may not think of it this way but this is in fact what it is right so so it’s and that’s the idea in art of AI this would be called an intelligent agent you know that’s something that you know gets new information thinks or computes or runs an algorithm and then issues actions right so they would call that an intelligent agent okay and the idea about this is it’s actually the

people who have done control have known this for more than 100 years these are very powerful ideas that the the ability to sort of repeatedly replan and chain and change actions change course makes up actually for all sorts of errors in the model right so this is this is sort of very well known and it’s the basis of all sorts of things it’s actually what makes a lot of this stuff actually work is the recourse okay so in our examples I mean this is kind of obvious what the recourse would be in generator dispatch you would modify the general the generator powers based on updated forecasts of demand right so if all of a sudden you realize whoa it’s gonna be much hotter than I thought or it’s a bit cloudy and in fact from this this solar farm over here I’m just not gonna get that much power out of it or something like that then you would update these things and redo stuff in a trading engine this is sort of the whole idea what happens is you have a forecasting system that’s forecasting how the markets are moving basically you would use the most current forecast to redo things and actually to trade some other stuff right so that’s how that would work in landing a rocket that is exactly how it works so for example the SpaceX landing works exactly like this if it gets ten times a second as it approaches the landing pad it takes forecasts it first predictions of where it is and where it’s going as position of momentum it then makes forecasts of the winds it’s going to encounter on its way to the landing pad it then works out a complete trajectory to the landing pad if it flew that trajectory it would fail 100% of the time 100% because it actually doesn’t quite know where it is it doesn’t quite know its momentum or something like that and it definitely doesn’t know exactly the winds it is going to encounter right so what it does is for a tenth of a second it actually follows that plan for a tenth of a second and a tenth of a second it does the entire thing again using lidar to estimate the winds all that kind of stuff it does it just reap lands everything and that’s what makes it work right so this is so the idea of recourse is not a small thing it’s actually a critical part of all this okay now there’s a standard scheme for this is called rolling horizon optimization this is used in 50 different fields all with different names and by the way they would not even recognize these are people who wouldn’t even talk to each other actually so and the idea is you’re going to it’s it’s it’s actually very elementary it goes like this what you’re gonna do is you’re gonna plan over a horizon of time my you have to choose the horizon appropriately and what you’re gonna do is you’re gonna get predictions for the future unknown quantities that be predictions of how the markets are moving predictions of the winds predictions of the demand and renewables generation things like that you’d make predictions for these things and then what you do is use optimization to get a complete plan of action over that period you have no intention of executing that plan of action because you know your forecasts are wrong but you also know that you know one moment in the future you’re gonna redo the whole thing you’re gonna get new forecasts and you’re gonna do it again so that’s the idea and then you execute according to plan and then you replay and when you have new data so this is it by the way this is universally used in lots of fields and you know it’s I guess in supply chain I asked someone it was an expert on supply chain I said what do you call it when you do this and he looked at me and he said what do you mean and I said you know when you make forecasts you optimize over the thing then later you do it again and he looked at me he said he said you know we call that supply chain optimization and I said oh he said we would never do anything else so it was very you know so so this is some things as hardly knew ok so I just give you a quick example here and it actually embedded in the slides there’s a dirty secret which I’m about to tell you so it’s it’s this so here’s the current time that’s the horizon we’re planning over and this is the actual demand the blue we don’t know it because this is the time now the green is our prediction and actually what I do want to point out here is your prediction is pretty bad right so that’s it’s not good now what the prediction is doing is it’s getting the general trend you know it’s saying actually we were we are definitely going to be needing more power later in the day but it’s not predicting this crazy spike or something like that right so maybe this is a micro grid or something okay so I’ll roll time forward and you can see what’s happening is your your prediction is not is you know it’s not particularly good and yets things like just work extremely well in practice right and I’m I’ll say one more thing about it this is sort of the the dirty secret is that these is if you have recourse front if you’re doing recourse and replanting you can actually do you can use forecasts that are pretty bad I mean so the typical one used for example in drunk driving like in cars is

extremely simple here’s the prediction of what the driver is gonna do for the next three seconds this is used by everyone it’s this you’ll be at the same speed and your steering wheel will be a angle will be constant period that’s it right so you’re gonna be on the positive speed on an arc that’s it so it’s quite naive and yet if it’s redone every tenth of a second it works very well so okay so I’m gonna wrap up now with some general comments about this I’ll say a little bit first about you know I haven’t talked about research this is just like big picture ideas about you know how certain mathematical methods are now very widely used they will be used more and more for sure so so what people in the research is focusing on things like well one is the core optimization algorithms but especially in the area of reliability and something has changed very much optimization used to be used in the 40s 50s and 60s for designing stuff and so the point is if the algorithm fails it doesn’t matter because you know you just I don’t know you can fiddle with it have an expert try it out but the point is if it’s embedded in a jet engine it can’t fail it has to it simply has to work right if it’s an if it’s in a self-driving car it can’t all of a sudden say sorry I don’t know you know sorry I don’t know what to do or I fail to solve it you can’t do that right so reliability is and it’s something that actually academics have traditionally not worked on or emphasized too much domain-specific languages so that’s something my group has worked on and the idea there is to actually make the software infrastructure that makes this vision closer to a reality so and the vision is very simple here’s how it should work ideally you have a problem you should articulate what you want period and then you let the optimization algorithm decide what to do so by the way this is also that’s not I mean that’s also good management right you say exactly what you’re gonna you say what you want you say how you’re gonna measure it and then you let let others figure out how to do it right so that’s it and so we’re making software that kind of has that flavor right okay code generation this is where you want to actually feel something and not sort of test it and things like that and the idea there is you describe an optimization problem and then what comes out it’s not a solution but in fact code that is super reliable like infinitely reliable and we’ll solve that problem and so for example there’s one where in fact my group worked on the code Jenner it’s my group’s code generator that generated all the code for example for the SpaceX right so that’s that’s what what was flying on those things was C source that was compiled that came out of a code generator from my group so that was it that was fun I’m not taking credits actually as one of my students or a couple of my students I should say okay and of course the other fun part is to look for new applications so that’s very interesting because you know some the these technologies of mathematics the algorithms and the optimization is very unevenly diffused in some fields it’s extremely well I mean people have been doing this in finance for a long time but then it’s actually but if what I’m interested in is things where it actually hasn’t yet diffused and it’s very varied so that’s actually quite interesting not to look at these okay one interesting thing about this is that there’s something new going on here and it doesn’t have a name I mean I guess you could call it AI but I sort of don’t like that name but you know okay here it is but the idea is there’s something like a new applied math is is emerging and you know it’s basically the kind of things I’ve been showing you it’s it’s it’s techniques and approaches you use model fitting to fit models from data right so and that you’d find in statistics machine learning AI and it’s very algorithmic computationally oriented and it’s something like a new and a new area and there’s a big shift from the mathematics of physics which was of course very highly stat the 19th century through the middle of the that was out chilly through the middle of the 20th century very well you know very well studied and this were shifting towards the mathematics of information right which applies to social systems and things like that where there are no fundamentals ok and this is done in a lot of places if there’s not a fixed Department for this it’s computer science ISTA tist ‘ok so are a lot of different departments ok and it’s used in lots of different areas and it’s kind of this is what makes these things smart I mean if you look at these things and you’re like wow how did it know to do that this is kind of what it does this is this is the inside or I’ve now told you what’s on the inside ok so I want to say a little bit up where is it going this is exactly the point where you should stop trusting me because I’m about to make you no predictions and things like that some of it will be right but most of it will probably be wrong so this is where you should not trust me anymore ok so this is not gonna slow down it’s going

to accelerate is what’s gonna happen and you’ll be hearing a whole lot of hype about this and some of it will be true right so some of it will be out some of it will be true but out of context and not anywhere near as useful as you think like something that place go okay that’s an example alright so because then you know everyone gets very nervous this oh my god if it can play go you know what can it do right ok so you’ll hear some of it’s gonna be true I don’t know which parts you know you have it’s gonna be your job to figure out which part is true and which is just hype but a lot of stuff is kind of already here you know a lot of these various things there are a lot of things going in and you know some are bad but I should say that and and I want to say a little bit I’m gonna finish up with just again wild conjectures about you know what is all this imply about the future so first the positive idea and the positive idea is something like this right when you know the positive view of what’s gonna happen is you know devices and services are gonna get faster cheaper they’re gonna get cleaner they’re gonna get safer that’s actually a very important part of all this right that for example a lot of times you put in a sophisticated control system and the thing does not get it doesn’t get more efficient it doesn’t get faster it doesn’t get better but it could be way more safe and that’s actually very important so it’s it’ll handle weird situations that nobody figured out it’ll do just the right thing okay and this’ll you know this laugh at a real advantage you can extend the existing infrastructure you know the the life of that will be instant now this is this is the Silicon Valley Stanford take on it that of course we think it’s wonderful if you can you know make something cleaner more efficient and improve an efficiency 5% 10% that’s wonderful that’s great we’re more interested or more focused on doing things they’re worse they could where the improvement is not 5% but it’s infinity in other words you could do things that you could never have even dreamt up before right so that’s actually kind of what’s driving a lot of the psyche around Stanford and stuff like that so it’s very okay and now sort of some of the bad and a lot of this is actually already happening actually all of it so the first thing is these smart devices can be hacked so I have a colleague Dan Bonet who does security I watch the lectures a couple of years ago and I had nightmares for basically the next year because he what he basically said is you know you can hack into any of these things it’s it’s ridiculous your router and all sorts of other stuff that’s it then he just sits there and actually once this does it right there he said there I’m into the router fine now I’m trusted now I’ve done this now I’ve taken over that I’ve done that so terrifying now that’s gonna have to get fixed privacy you are absolutely being trapped period right so there’s a huge big issue of what’s gonna happen when what’s gonna happen when in five years trucks are driving themselves or there are no more cashiers in California I think there’s something like half a million of them or something like that what what’s gonna happen right what about accountability and liability or here’s a very specific example this actually happened the Californian depends system operator they do the the ones who schedule the electricity for California they built a very smart system they’re very very clever and you know JP Morgan made one that was smarter and basically sucked out sucked down you know tens of billions of dollars from California because they could do it better than that there were loopholes that they knew about that Cal iossef did not right my feeling on all of these is these are all fixable if there’s the will and whether or not there’s a will is not a technological problem it’s a it’s a it’s a political and social question so okay so I’m I’m gonna quit here but this is depressing so I’m gonna go back to the previous slide this one there we go okay and I’ll stop here [Applause] [Applause]