#291: Operational Resilience with Pyomo Transcript
00:00 Do you have a scientific system that needs optimization or solving?
00:03 Our guest on this episode, Clark Petrie, is here to tell us all about Pyomo.
00:07 This is a library that can solve all sorts of cool problems, linear programming, nonlinear equations, and many other things that you can throw at it.
00:14 We're going to solve a really fun diet problem.
00:16 What is the most nutritious meal that you can eat for the least amount of money?
00:20 The answer might surprise you a little bit. It's going to be a lot of fun.
00:23 So listen in to hear about how Clark has used Pyomo to do his work and how you might use it in yours.
00:29 This is Talk Python to Me, episode 291, recorded October 1st, 2020.
00:34 Welcome to Talk Python to Me, a weekly podcast on Python, the language, the libraries, the ecosystem, and the personalities.
00:52 This is your host, Michael Kennedy.
00:54 Follow me on Twitter where I'm @mkennedy, and keep up with the show and listen to past episodes at talkpython.fm
01:00 and follow the show on Twitter via at Talk Python.
01:03 This episode is brought to you by Linode and Talk Python Training.
01:07 Please check out the offers during their segments.
01:09 It really helps support the show.
01:11 Hey everyone, two quick announcements before we jump into the show.
01:14 Number one, I really appreciate everything that many of you are doing to support us here at Talk Python
01:19 and make it possible for this to be my full-time job.
01:22 Our primary means of support is through the courses over at Talk Python Training,
01:26 and I've been thinking about how I can offer you something special in return.
01:29 What I've come up with is something I'm calling Talk Python to Me Pro Edition.
01:34 It's like regular Talk Python, but it comes with two perks.
01:37 It is ad-free so you can listen without any interruptions, and you'll have the entire history going back five years to episode zero in your podcast player.
01:45 Talk Python To Me Pro is available exclusively to listeners who have an everything bundle over at Talk Python Training.
01:51 If this sounds like something you want, learn more at talkpython.fm/pro.
01:56 And if you already have a course bundle, just visit that link for details on how to add the Pro Edition to your podcast player.
02:01 Announcement number two, somewhat related to Talk Python Pro, Black Friday is just around the corner if you're listening to this episode right when it comes out.
02:09 We'll be offering major discounts on our brand new FastAPI course and on our everything course bundle over at Talk Python Training for just four days.
02:18 So visit talkpython.fm/Black Friday to get notified when the deals go live.
02:23 Thanks so much for your support.
02:25 Even if you're just listening, it really means a lot.
02:27 Thank you.
02:28 Now, let's optimize some things with Python.
02:31 Clark, welcome to Talk Python to Me.
02:33 All right.
02:34 Thank you, Michael.
02:34 I'm happy to be here.
02:35 Yeah, I'm happy to have you here.
02:36 And we're going to talk about operational resilience and using a package called Pyomo,
02:41 which is about solving all these constraint problems, which brings me back to my math roots, right?
02:48 Like I didn't do that much applied math, but I definitely studied a ton of math before I got deep into programming.
02:53 So it'll be a fun journey, I think.
02:55 Happy to have you.
02:55 Yeah, this is a lot of fun for me.
02:57 I've been a fan of the show for a while, and it's kind of surreal to be sitting here talking to you right now.
03:02 So this is exciting and fun, and I'm happy to spread the joy of Pyomo to the audience.
03:06 Yeah, and honestly, I had not heard of Pyomo.
03:08 I obviously know about some of these like solver type systems and the general concept,
03:13 but I've never used Pyomo and it looks really cool.
03:15 We have a really fun and slightly comedic, but honestly serious example to go through as well to give people a sense of like the kinds of problems we're solving.
03:24 But, you know, that's not where we start the show, right?
03:27 We start with your story.
03:28 So let's start there.
03:29 How did you get into programming and Python?
03:30 I mean, I took a really roundabout way to get there.
03:33 Just for, I guess, audience context, I was born in 81 and grew up in rural Northern California,
03:39 kind of one of the few tech nerds in a one-stop-light town.
03:42 I mean, there was literally a girl that rode a horse to school.
03:44 I'm not even joking about that.
03:45 No way.
03:46 That's crazy.
03:47 Yeah.
03:47 We had these like ag fields out back, and she would sometimes ride her horse to school and just put the horse out to pasture during the day.
03:53 That's actually really cool.
03:54 It was neat for her.
03:55 I was not into that, but like, especially looking back now, I can go, that's pretty legit.
04:00 Yeah.
04:01 But, you know, like I said, I was one of the few tech nerd kids, and I remember the early days of AOL,
04:05 and I was actually making money as like a sophomore making web pages for local businesses.
04:11 Okay.
04:11 Yeah.
04:12 I guess the HTML that I did all by hand back then, you could say it was my first experience programming, so to speak.
04:17 I did a little bit of IRC bot coding.
04:20 I loved trying to make what we now think of as like a chat bot, but I'd had some foresight.
04:25 I could tell there was a future in that, but it was just for me, it was a toy, and I love that stuff.
04:31 But it was just me and a single mom predominantly who, despite her best efforts,
04:36 didn't really know how to guide me to college.
04:37 So I kind of stumbled into joining the military, specifically the Navy, right after high school in 99.
04:42 Fast forward to actually get to answering your question.
04:45 They cultivated my potential.
04:48 I eventually got commissioned as an officer, and in 2015, I got sent to the Naval Postgraduate School
04:53 for the Operations Research Curriculum, which...
04:55 That sounds really cool.
04:56 I often will colloquially...
04:58 Yeah, it was a great opportunity.
05:00 I mean, I got paid to go to grad school, so I can't...
05:01 I'm like the luckiest guy around, which for someone that hasn't heard of OR,
05:06 a lot of us will just kind of cheat and just call it applied mathematics,
05:09 compared to...
05:10 I hope I'm not offending any actual math masters out there.
05:14 But from looking at the curriculum, you know, we just kind of drop a few math classes,
05:18 add in a few programming classes, which, to answer your question, in the first quarter,
05:21 we took a Python course.
05:23 And I just...
05:23 I kind of fell in love and quickly realized that was the main technical tool I wanted to
05:31 cultivate for my time in school, and also what I wanted to really use in whatever thesis
05:36 I ultimately ended up doing.
05:37 And here we are now.
05:39 Yeah, here you are.
05:40 You've done your thesis with Pyomo and Python, and we're going to talk about it.
05:44 That'd be great.
05:44 Yeah.
05:45 So it's never too late to learn to code.
05:46 I mean, heck, I was...
05:47 Yeah.
05:47 ...35.
05:48 Yeah.
05:49 And when I started that, so...
05:51 Well, I wasn't quite that far along, but I hear a lot of stories from people like,
05:54 oh, I started that when I was four.
05:55 Like, as soon as I could sort of kind of read, I was on the computer and whatnot.
05:59 And for me, it wasn't that way at all.
06:02 It was basically grad school, almost grad school, senior year of college, doing research projects,
06:07 going to actually need some programming skills to start answering these questions.
06:11 But once I got into it, it was like, why have I been studying this other stuff?
06:16 This is way more fun.
06:17 How do I do more of this?
06:18 And less of what, I'm actually getting my degree in.
06:20 That was a bit of a problem, but it worked out in the end, I suppose.
06:22 Yeah.
06:23 Yeah.
06:23 I did similar stuff where I kind of juggled around electives to take more programming classes
06:28 while I was there because I was enjoying it so much.
06:30 I kind of put off other pain until later, I guess you could say.
06:35 Exactly.
06:35 So what is operations research?
06:38 Like, what kind of problems are being solved there?
06:41 Give people a sense of what that means.
06:42 So from the military perspective in particular, a lot of it is logistics and optimization.
06:47 So in that curriculum, there's kind of three main tracks people tend to fall down.
06:51 One is the optimization track.
06:53 You could say that's where I went.
06:54 Another is more of a just data analysis track, a lot of regression analysis.
07:00 And the third would be simulations.
07:03 And I guess you could say just trying to drive answers through some kind of simulation theory.
07:08 So within operations research, we're looking to find the best way to go about doing something.
07:14 So some of those classic computer science problems exist in that domain, I'd say.
07:17 You know, the traveling salesman problem is an early one.
07:20 Right.
07:21 And it's about doing that at scale for...
07:23 The Euler Bridge problem.
07:25 Yep.
07:25 That one.
07:26 That seven bridges.
07:27 City.
07:27 I forgot the name of the city.
07:28 Yeah.
07:28 You know, we go through some of the classic use cases during World War II with like...
07:32 God, like...
07:35 I don't know.
07:35 It might have been post-World War II, I want to say.
07:36 But like looking at the Soviet railway system and how...
07:40 What's the minimum cut, right?
07:41 To essentially disable their railway system if they were to invade Europe.
07:46 Right.
07:46 And it's a lot of work in that domain.
07:49 Yeah.
07:49 Okay.
07:50 Pretty interesting.
07:51 And I'm still looking forward to the example we're going to get to.
07:54 Yeah, I'm so goofy.
07:56 And contrast it with the seriousness of these things.
07:58 But how about day-to-day?
08:00 Like, what are you doing now?
08:02 So right now, I'm a senior officer working in the Pentagon as a data analyst.
08:06 Let me just really quick.
08:08 I got to get the obligatory.
08:10 The views and opinions expressed here are mine and mine alone.
08:13 They do not represent the U.S. government, the Department of Defense, or the U.S. Navy.
08:17 So there we go.
08:17 I said it.
08:18 We're safe.
08:19 This is the world of Piomo, according to Clark, not the U.S.
08:23 Okay, got it.
08:24 Yeah, got it.
08:25 So basically, I work for a three-star admiral, which is pretty darn senior.
08:28 And he is in charge of the entire Navy Reserve.
08:31 So for kind of civilian context, you could think of that as a multi-billion dollar company with 60,000 people.
08:37 Yeah.
08:37 Wow, okay.
08:38 And he's the CEO, if you will.
08:39 And at the Pentagon level, and we have, you know, it's the military, so everything's tiered.
08:43 It's very vertical.
08:44 And I'm one of his two data guys, basically.
08:47 And we have one never-ending project, which is we're always analyzing and forecasting our personnel strength, which is a multivariate problem in and of itself.
08:57 We got to look at, as the Navy Reserve, we receive people that leave the active duty Navy, but we also can recruit off the street.
09:05 So we get folk that are coming straight into the Navy Reserve, those that are leaving active duty, and we have to try to plan out how many people we're going to have, and do we have the right types of people for all of our different missions across the future years defense program, which is sort of the budgetary outlook.
09:20 That's our main job.
09:21 But honestly, we probably spend more of our time just digging into random data for whatever the Admiral needs to be educated on, the other senior decision makers in the Pentagon, so they can go forth and move out.
09:32 COVID was a big example of that.
09:34 It's funny.
09:35 You have the world shut down with COVID, and literally the Joint Chiefs of Staff are coming to us wanting answers now, like right now, right?
09:42 Yeah.
09:42 You got to tell us this.
09:43 So, yeah.
09:45 So it was me and my counterpart who got really smart on a pretty thorough analysis and built a unified data project to answer anything about Navy Reserve medicine, because we have doctors and nurses and critical care and all that in the Navy Reserve.
09:58 So how many do we have, and if we pull them to go to New York, are we pulling them from a hospital in another hot spot in their civilian life because they're a reservist?
10:06 And so that's answering questions like that as a recent example, you could say, is what I do.
10:11 Okay.
10:11 Yeah.
10:12 Two things I want to talk about.
10:13 One is we saw the nightmare that was the cruise ship industry, right?
10:18 Yes.
10:19 And I think there's still people around the world who are still stuck on these cruise ships, right?
10:25 Like not cruisers, right?
10:27 They were taken and put somewhere.
10:29 I remember, like, I guess it varied where you were, but people who worked on the cruise ships.
10:33 I think there's still a ton of them stuck there.
10:34 And that's just insane.
10:36 And yet, I used to live in Coronado, California, a little island outside of San Diego for a little bit.
10:42 And there was two of the main aircraft carrier station there.
10:46 I know that pier very, very well.
10:48 It's a beautiful place.
10:50 But the reason I bring that up is literally the traffic would change.
10:55 The traffic patterns would change how much traffic there was and whether or not the aircraft carriers were home or they were gone.
11:01 Because there are so many, there's like 5,000 people on an aircraft carrier, something like that.
11:06 Yeah.
11:06 If the, so this is, you're getting really into my wheelhouse.
11:09 My first 10 years as an officer, I was one of the nuclear engineers for aircraft carrier reactor plants.
11:15 Oh, wow.
11:15 Okay.
11:15 Which is why I had the technical aptitude to do the ops research program for like eligibility.
11:20 And yeah, if the carrier has the air wing embarked, you're looking at 5,000 or 6,000 people.
11:25 Yeah.
11:26 And when the air wing, all the planes and everything associated there is not there, you're talking about 3,000.
11:30 Either way, whether a carrier is important or not changes the quality of life for a commuter for sure.
11:35 Yeah.
11:36 I mean, it would change.
11:37 It would dramatically change.
11:38 So why do I bring that up?
11:39 Well, you guys got these, I mean, that's the same size as a cruise ship or bigger and you've got all these people on there.
11:44 And that's a huge challenge.
11:46 I mean, how did you all deal with that?
11:47 What was even the outcome?
11:48 I know that there was a commander of one of those carriers that was lost his job basically.
11:55 Because he spoke out about like, this is a serious problem.
11:58 He was very upset and kind of went above rank or pulled rank or something like that, right?
12:02 Yeah.
12:03 I mean, I can't really like, I wasn't there, right?
12:05 But I can only report what I kind of saw in the news.
12:07 I don't have much insider information, if you will.
12:10 But we take rank and reporting at the chain very seriously.
12:15 And I feel for that gentleman.
12:17 My job before this was as a commanding officer.
12:19 And he was facing incredibly tough decisions.
12:22 And it's just, the whole thing's unfortunate.
12:24 But as far as what you're getting at with like the cruise ships that are dealing with such rampant COVID problems,
12:30 yeah, that's really tough.
12:31 Because on a ship, where are you going to go, right?
12:33 Yeah.
12:33 But one way that I think we haven't been as decimated is the wrong word,
12:39 but maybe negatively impacted with our ships, partially because generally, most of the sailors on ships,
12:46 and the average age of a Navy sailor is like 21 years old.
12:50 We're talking pretty healthy people.
12:52 Which is probably not the same age as the average cruiser.
12:55 I do love a good time on a cruise ship.
12:57 But if I need to feel young, I can also do that, right?
13:00 Yeah, right.
13:01 So I think there's probably some degree of extra resilience, I would think,
13:06 amongst our personnel on ships that has probably helped mitigate the problem.
13:10 And I'll tell you this.
13:11 We have also had, we're the military, right?
13:13 And we need to be ready.
13:15 The restrictions in place on us for doing things that would possibly increase your risk profile are pretty strict.
13:23 Yeah.
13:23 Like, even though I'm in Northern Virginia, you know, my wife can, she could go out and go eat and hug everyone she wants to hug.
13:31 But like, if I were to go, I'll give you an example.
13:33 One of my big personal hobbies outside of nerd stuff is I'm a big Brazilian jujitsu guy, which is really mean wrestling, if you will.
13:41 Yeah.
13:42 It's cool, but it's also kind of up close with other people.
13:44 Yeah.
13:45 There's no way to socially distance when you're rolling around with people, right?
13:48 And if I were to go do that and get COVID, technically speaking, I would have disobeyed like a direct order.
13:54 Right.
13:55 You know, and I'm senior enough that I probably wouldn't get like in real trouble, if you will.
13:59 But I know, like, I'm a good boy.
14:01 So.
14:01 Yeah.
14:02 The restrictions in place like that are probably protecting our people more.
14:05 Sure.
14:06 Well, and also just like what you do on a cruise ship, like you go from port to port and you go out and experience those places.
14:12 Whereas you can say, you know what?
14:14 We're not going to go into port and you guys don't go anywhere.
14:16 You stay here.
14:17 Which is a different kind of experience, I guess.
14:20 Yeah.
14:20 No more pulling into Hong Kong and going wild, I suppose.
14:24 It's probably restricted liberty when the ships do pull in.
14:27 Yeah, exactly.
14:27 But I'm a desk jockey now.
14:29 My ship going days are way behind me.
14:30 This portion of Talk Python to me is sponsored by Linode.
14:35 Simplify your infrastructure and cut your cloud bills in half with Linode's Linux virtual machines.
14:40 Develop, deploy, and scale your modern applications faster and easier.
14:44 Whether you're developing a personal project or managing large workloads,
14:47 you deserve simple, affordable, and accessible cloud computing solutions.
14:51 As listeners of Talk Python to me, you'll get a $100 free credit.
14:55 You can find all the details at talkpython.fm/Linode.
14:59 Linode has data centers around the world with the same simple and consistent pricing, regardless of location.
15:05 Just choose the data center that's nearest to your users.
15:08 You'll also receive 24-7, 365 human support with no tiers or handoffs, regardless of your plan size.
15:15 You can choose shared and dedicated compute instances, or you can use your $100 in credit on S3 compatible object storage,
15:22 managed Kubernetes clusters, and more.
15:25 If it runs on Linux, it runs on Linode.
15:27 Visit talkpython.fm/Linode or click the link in your show notes, then click that create free account button to get started.
15:36 Got your land legs back.
15:37 Okay, so let's talk a little bit about, let me just ask you about Python and the government,
15:42 our programming and the government.
15:44 I did 10 years of in-person training, and much of that was at places that were like HP or JP Morgan or something like that.
15:53 But periodically, we teach classes at military places.
15:58 And they were a little bit different, right?
15:59 Like I did a class for the people that ran the launch control for NASA.
16:04 I think they were technically Air Force, but still, that was pretty cool.
16:06 And someone at Edwards Air Force Base.
16:08 And I talked about like, oh, yeah, you just pip install this thing.
16:11 And you get like, look at this amazing package that are like, that's really awesome.
16:14 We're never, ever going to be able to do that.
16:17 You can't just install stuff off the internet.
16:19 So tell us what programming in this world feels like.
16:22 So that's the tough part, right?
16:27 Is anyone listening to this show probably knows what Python's capable of.
16:31 And we're all here because we love it, right?
16:33 It's a great language.
16:34 And then there's the government limitations that you just got to.
16:38 So there's a group in the Pentagon called N81 that doesn't really mean anything.
16:42 But they're kind of some of our researchers on the Navy side.
16:44 And a lot of ops research guys and a lot of coders.
16:47 We do in some cases have standalone machines that are able to touch the outside world.
16:52 But they're just not plugged into like our broader, just unclassified internet,
16:56 which is called NMCI for Navy Marine Corps internet.
16:59 Now, some of those N81 folk allegedly treading a little bit of dangerous water, maybe,
17:04 maybe found a way to kind of get Python working on their machines, but to try to do work.
17:10 But again, what you got to a truth, which is, oh, you go, you need some package.
17:13 You can't just pip install it.
17:15 Again, allegedly, it might be the case that you have to download the wheel.whl files.
17:21 Whl, yeah.
17:22 Yeah, yeah.
17:23 You have to download the wheel files.
17:24 I call them wheel files.
17:25 I don't actually know what the...
17:26 Yeah, yeah.
17:27 Yeah.
17:27 Yeah, you have to download those manually and install them.
17:30 But of course, if one package needs like subservient packages, you have to like backtrack, right?
17:36 Until you have what you need to then get Python running.
17:39 But even if you go through that heartache, you now are facing another conundrum, which is you have Python running, yay, on your government computer, which because we're so big and we try to standardize everything.
17:53 And for good reason, there's a lot of background processes running to keep machines up to date and to monitor activity and such.
18:01 A core i5 with 8 gigs of RAM that is, you know, permanently got 80% of that used isn't exactly the like analytical monster you might want.
18:12 Right, right.
18:13 And so...
18:14 And it's trying to decrypt the drive and run the three different virus scanners and then the network monitor.
18:20 It's like at a permanent 60% CV usage before you touch it, right?
18:23 Yeah, exactly.
18:24 You know too well.
18:25 So that's the hard part is someone like me, I'm always beating the drum.
18:30 My last boss when I was a commanding officer probably got tired of me beating the drum about, you know, if we can improve the technology that our sailors have, we'll be so much more efficient.
18:39 Yeah.
18:40 And that's one of our limitations.
18:41 And I understand and get the complexities of that problem.
18:44 It's not easy.
18:45 It's not, oh, you just got hired with insert tech company here.
18:48 Here's your new MacBook.
18:49 You can't do that with us.
18:51 Yeah, exactly.
18:51 But that's sort of the challenge.
18:54 Now, what's sort of interesting is COVID has changed a lot of that.
18:59 It's changed it for, I think, for banks and for all sorts of industries that were like, we can't work from home.
19:05 You can't access this from your home.
19:06 But you guys are kind of the far end of that spectrum.
19:09 Well, yes, comma.
19:11 I've actually been working from home for six months, which has allowed me to, with data that is not sensitive, obviously, the main thing that I would be dealing with would be personally identifiable information.
19:23 Now, that's on my machine.
19:24 I keep a good delineation.
19:26 But a lot, the main data sources I tend to work with don't have that anyway.
19:30 So I've been able to move a lot of my analytical work to my personal computer, which I'm a nerd.
19:34 It's a good machine, right?
19:35 So that has sort of supercharged me with what I've been able to do as an analyst in this work from home environment, which has, at least in my case, but I can just kind of sense that across the broader structure of the military, the higher ups are realizing, oh, wow.
19:52 Our people are more effective in a lot of cases, and they're happier?
19:56 What?
19:56 You know?
19:57 Yeah, exactly.
19:58 Wait a minute.
19:59 And we have this big fancy building we can go to, but they don't want to go to it anymore.
20:03 Like, it's, yeah, it's a really interesting paradox.
20:05 And what's silly about that is, for anyone listening out there that's doing data work, I work in a secure space.
20:11 So I can't have my cell phone.
20:13 And I'm not missing it because I want to play a game.
20:15 I can't have a podcast going.
20:17 Yeah.
20:17 I can't have music going, right?
20:20 And just that change alone, just to put on something when I got to really focus on a data problem and just get some kind of good techno trance going, if you will, in the classic coder.
20:29 Yeah, just have the distractions, right?
20:32 Yeah, it helps.
20:32 So COVID's changed a lot of that for us.
20:35 And I can just tell, I think, like the whole world at large, we're just a microcosm of it.
20:38 We're never going to go back to normal, whatever that was.
20:41 Yeah.
20:42 We're permanently going to be.
20:43 So what about, like, things that allow whitelisted packages?
20:49 To be vetted and then like local PyPI server type of things.
20:55 Is that something you guys have looked at or maybe you will be looking at?
20:59 Yeah, there is some of that happening.
21:01 So government is headed in that direction.
21:03 The senior people, they get it.
21:05 I mean, it isn't like they don't know, right?
21:07 Yeah.
21:08 And they can recognize that we, from my point of view anyway, maybe a little bit behind, just a little bit behind our civilian peers and know they need to bring that stuff online.
21:18 And we're starting to develop some of that.
21:20 I know some of my counterparts in my office, you know, working for the Admiral of the Navy Reserve, they're helping.
21:27 They're involved with the process to develop what we're calling the authoritative data environment, which is going to be sort of a, what's the name for when you have like a kind of a machine and a machine?
21:36 I'm blanking right now.
21:37 Like a virtual machine?
21:38 Yeah, yeah, a virtual machine.
21:39 I was just blanking.
21:40 It's basically a virtual environment that you can like remote into.
21:43 And then you're going to have the full suite of packages.
21:46 And presumably someone would have white listed all the Python packages you could want, right?
21:52 So we're trying to get there.
21:53 It's just, we got to get there while navigating the limitations of our government requirements, which, you know, many of which are in congressional law, right?
22:02 So it's not like that's an easy thing to change and update.
22:04 It's not like there's just a picky manager.
22:06 No, no, no, no, no, no.
22:08 So that's where we're headed.
22:10 So another thing, I don't want to go too far down the strad hole, but it is interesting to me.
22:14 So let me ask another question.
22:15 So have you guys looked at things like VS Code has the ability to just like run in the browser and execute code and say like a Docker environment in Azure or other places where if you just have access to the internet, you basically have unbounded compute.
22:33 Have you looked at those types of setups or even creating like isolated something like that internally, but then setting up those kinds of servers?
22:40 There is something like that.
22:41 And it actually shows you how much in demand it would be.
22:43 When that initially got set up, I'm blanking on the name.
22:45 I haven't tried to use it for almost a year.
22:47 The demand.
22:48 It was overwhelmed and just killed it.
22:50 Yeah.
22:51 Yeah.
22:52 Demand from people like me was so significant.
22:55 It just vomited and died.
22:57 And it was really hard to use.
23:00 And then the other problem is we don't exactly have the fastest pipe up and down to do work like that.
23:06 So you're going to be working in a high latency environment oftentimes, which can make the experience more challenging.
23:11 But there are setups.
23:13 I know the Air Force has one that's pretty robust.
23:15 Okay.
23:15 I think that's kind of ironic given that our ARPANET and DARPA and all that stuff sort of created the internet.
23:22 Yeah, right.
23:23 And I know people hear I'm in the Pentagon.
23:25 They picture some kind of like Jason Bourne control room.
23:29 Right.
23:29 And those places exist in the Pentagon.
23:31 I'm not in it.
23:32 Yeah.
23:33 But.
23:33 Exactly.
23:34 Yeah.
23:34 Yeah.
23:35 Cool.
23:35 All right.
23:35 So another thing I want to kind of touch on is you wrote an interesting article that actually touched on an episode with Jacqueline and Emily about the different branches or pot.
23:48 Like when you say I'm a data scientist or I have a career in data science or data engineering, like that actually can mean a whole bunch of different stuff and really interesting ways to kind of map out that world.
23:57 You want to talk about that just a little bit?
23:58 Sure.
23:59 Yeah.
23:59 I mean, I have a blog that's for me.
24:01 I don't.
24:01 I haven't even done like good SEO on it for that matter.
24:05 But that episode was 262 with Jacqueline and Emily.
24:08 You know, they described different kind of fictitious companies.
24:11 And one of them, when they got to this is a large company, probably a lot of government contracting.
24:15 Maybe it is government.
24:16 You know, my ears perk up.
24:17 Right.
24:17 Maybe it's Boeing.
24:18 Maybe it's even the Pentagon.
24:19 Okay.
24:20 Right.
24:20 And then they perfectly describe some of these challenges we just discussed, which is, wow, you don't have access to the tools you want.
24:27 But then they really go down the analyst role, which is certainly what I consider myself.
24:30 I'm technically trained.
24:32 I have technical skills.
24:33 But especially at my level, they were so eloquent in how they described it.
24:39 I'm the one who, almost by virtue of my education, when I speak to numbers, it's gospel, if you will.
24:47 And then that's an important trust, right?
24:48 My admiral trusts me that I'm right.
24:50 And I can never betray that.
24:52 So I'm the one that's kind of in the boardroom, if you will, showing the CEO the charts and breaking down what's what for them, as opposed to the real data engineer in the trenches.
25:04 Right.
25:05 Like deploying a machine learning model to production over like a FastAPI implementation, right?
25:10 Not so much that.
25:11 No, no, no, not at all.
25:12 I have done some technical stuff with Python in my current role.
25:15 And we can talk about that.
25:16 But I am more of the, and Jacqueline and Emily talk a lot about, I think they say Excel and PowerPoint.
25:21 I'm like, haha, yeah, that's my life.
25:23 My PowerPoint skills have become much stronger in the last year of this job than my coding skills.
25:30 That is the lingua franca of that whole environment, isn't it?
25:33 Yep, absolutely.
25:34 I legitimately was joking with my other data buddy, just about what a PowerPoint savant I've become, almost to the point that, like, it's like, oh, you want your slides touched up?
25:43 Contact Clark.
25:44 So that's a feather.
25:46 I remember doing a training course with this group out of the Air Force Academy in Colorado Springs.
25:53 And, like, one of the pinnacle moments was when we found a way to dynamically generate one of the slides in PowerPoint.
26:01 It was like, it would pull in data from where all the planes were flying.
26:05 And it would dynamically, like, in real time or, like, near real time update what would be shown in the PowerPoint.
26:11 It wasn't, like, enough to have that on a web page.
26:13 It was like, it needs to generate a slide on live data.
26:18 Like, why would you do that?
26:19 Like, it doesn't matter why.
26:21 It has to do this because this is the world we're in, right?
26:24 Yep.
26:25 We are beholding the PowerPoint for sure.
26:27 You know, it's funny we talk about PowerPoint because Tableau is starting to gain traction.
26:31 People are realizing the power of a good Tableau dashboard.
26:34 And that has, if nothing else, the name Tableau, like, is spoken in whispers in the halls of the Pentagon.
26:40 So, you know, maybe we'll get there eventually.
26:43 Yeah, that's a bit of a step up.
26:44 That's a bit of a step up.
26:45 Yep.
26:45 But, yeah, anyone who has not listened to episode 262, and I'll link to it, Jacqueline and Emily wrote a,
26:50 really good book.
26:52 Like, I'm not even that interested in a data science career for myself.
26:55 And I'm like, this is like a page turner.
26:57 This is really, I think they really broke it down well.
27:00 And it, because people ask me, like, oh, I want to get into data science.
27:03 What should I do?
27:04 What should I study?
27:05 I'm like, that's not enough.
27:06 I don't know enough to answer your question necessarily, because that means kind of different things.
27:10 So, I recommend people check that out.
27:12 It's a good one.
27:13 Yeah, definitely.
27:13 I mean, for me, that episode gave me, like, validity.
27:16 I'm kind of the king of imposter syndrome.
27:18 And I heard that.
27:19 I was like, oh, like, they describe a legitimate, valuable role that I'm kind of well-suited to.
27:25 Sweet.
27:26 You know?
27:27 That's awesome.
27:27 That's all right.
27:28 Well, because you might compare yourself against, like, the machine learning people deploying
27:33 machine learning models at Google.
27:34 You're like, well, I can't do any of that.
27:36 Like, all of that is foreign to me, right?
27:37 But that doesn't mean you're not doing valid data science.
27:40 Like, you're just doing, like, a different slice of it.
27:42 Yeah, absolutely.
27:43 And it's important to have someone that can speak to it and translate it into the common
27:48 vernacular, if you will.
27:49 And I think that's kind of where I've found myself.
27:51 Yeah.
27:52 And hearing them talk about that gave me hope, because whenever I retire from the service in
27:56 a couple of years, potentially, like, okay, cool.
28:00 There are roles in the outside world.
28:01 Some kind of weird military Stockholm syndrome.
28:04 I know that there are.
28:05 Yeah.
28:06 I suspect that a lot of the stuff that you work on, you can't really share or talk about
28:10 a bunch.
28:11 And so it doesn't give you that chance to kind of put it side by side with other people.
28:15 Let's talk about your thesis and this optimization stuff for the Python library, Pyomo.
28:21 Sure.
28:22 So you said you did your work at Los Alamos National Labs.
28:25 Is that right?
28:26 Yeah.
28:26 So I can back that up a little bit.
28:28 Professor David Alderson, who's one of my thesis advisors, he's the head of the postgraduate
28:33 schools, Center for Infrastructure Defense.
28:36 I want to make sure.
28:38 Yeah.
28:38 Center for Infrastructure Defense.
28:40 Making sure that the power grid doesn't go down and that the internet stays on and things
28:45 like that.
28:46 Yeah, absolutely.
28:47 It's a power, water.
28:49 And then that goes two ways, right?
28:50 From a military context, it's about protecting our stuff in a potential theater of war, whether
28:55 we're setting up a forward operating base in theater, as we would say, or domestically.
29:00 But at the same time, if we know how to protect our stuff and are smart on that, we also know
29:04 how to take out the enemy stuff better.
29:06 Yeah.
29:07 And so it works both ways from a military context.
29:09 So he's the head of that center.
29:11 And I got hooked up with him mainly because he taught one of the more advanced coding courses
29:17 I took while I was there.
29:18 And again, loving the language, coming back to how we started.
29:20 And he was working in conjunction with researchers at Los Alamos National Labs, which is how I got
29:26 hooked up with them.
29:26 Okay.
29:27 So which was a good opportunity.
29:29 I got sent out there for several weeks to just be in that environment, learn, and kind
29:33 of get hands-on with some other data, which I was able to bring back for my thesis, which
29:37 then Paloma became kind of the cornerstone of it.
29:39 Yeah.
29:39 What was your thesis about?
29:40 Yeah.
29:40 So it was assessing the operational resilience of electrical distribution systems.
29:44 Yeah.
29:45 Okay.
29:46 At the time, anyway, transmission, you know, think the big power towers that you see when you're
29:51 in the middle of a highway somewhere that's the transmission lines.
29:54 Those are really well understood.
29:55 The white and orange ones that are really high.
29:58 Yeah.
29:58 Yeah.
29:59 Those ones, right?
29:59 Okay.
30:00 Yeah.
30:00 Those are really well understood and modeled as we understood.
30:03 But distribution, like what's in your neighborhood, what's in your town, wasn't.
30:08 And obviously, distribution works great.
30:09 Right.
30:10 But from our awareness, no one had really built a model using real world data, taking
30:16 into account all of the mathematics for three phase AC transmission.
30:21 That's kind of where some of my nuclear engineering background helped because I was cursorily familiar
30:27 with that stuff.
30:28 Yeah.
30:29 I mean, that's basically a power plant as well, right?
30:31 Yeah.
30:31 Power plant and all the distribution, right?
30:33 So I was familiar with concepts like real and reactive power.
30:37 No one had built a model that took in real world data.
30:40 And what we could basically do is say, hey, if we take out this electrical pole or that transformer,
30:48 what will unequivocally happen?
30:50 Most analysis had been based.
30:54 It was essentially data analysis and regressions where you look at a disaster that happened,
30:58 maybe a tornado touchdown in Oklahoma, right?
31:00 Okay.
31:01 We know that the tornado did damage here, here, and here.
31:04 Okay.
31:05 We understand the results of that.
31:06 Now we can apply those results and think we'll know what will happen somewhere else.
31:10 But we built a model that will allow us to unequivocally state what would happen.
31:14 Yeah.
31:14 Okay.
31:15 And so the optimization part of that was working with the distribution system.
31:20 We kind of made an assumption, if you will, that we want to minimize how much load, real
31:26 and reactive power load, is lost if you take out a telephone pole or something, right?
31:32 So in the end, the grid wants to keep power going everywhere the power is being asked for.
31:37 So what we're trying to do is minimize the amount of power lost when you essentially mess with
31:42 the network.
31:43 Right.
31:44 Okay.
31:44 I grew up in Kansas City.
31:46 Tornado Alley is sometime called.
31:48 We ran experiments like that all the time of what happens if we take out this block of
31:54 thing or whatever.
31:55 But yeah, not in that clear sense, right?
31:58 Like stuff would just get blown over and see the little capacitors, whatever, it's explode,
32:03 whatever those gray cylindrical things that are on the towers.
32:07 Yeah.
32:08 Or the poles.
32:08 Yeah.
32:09 All right.
32:09 So use this library, Pyomo.
32:12 Tell us about that.
32:13 Yeah.
32:13 So what the library does, like we talked about at the beginning, I can't talk to what's
32:18 happening behind the package.
32:19 Sure.
32:20 But it allows us to set up an optimization framework.
32:23 As a consumer of it.
32:24 Yeah.
32:24 Yeah.
32:24 I'm a consumer, right?
32:25 So allows us to set up in Python and optimization framework to, I guess, structure these problems.
32:32 So we're talking about an objective function.
32:34 It can be a multi-objective function.
32:35 And then the various constraints to perform linear or nonlinear optimization in whatever
32:42 capacity you want to.
32:43 So using everything that we love about Python, right?
32:46 The relatively straightforward syntax.
32:48 And then all the tools beyond that, which made it unique.
32:52 We can set up these problems and then throw a solver at it.
32:56 Like Cplex is what I used, which to me is a bit of a magic black box, though.
33:00 We went into some of the mathematics behind that, obviously, like the simplex method and
33:03 all the Danzig's work back in the 40s.
33:06 But we throw a simplex at it and then structure in Python how we want our results.
33:11 And voila.
33:12 In the case of my thesis, we get a detailed printout, if you will, of what loads stayed up, what went
33:19 down.
33:19 And we can analyze that all within a Python framework.
33:21 Yeah.
33:22 That's beautiful.
33:22 To give people a sense of this, let me maybe go through some of the problems that it solves.
33:27 And then like some examples of using it.
33:29 Then we'll go through a concrete code example.
33:31 And that'll bring it together.
33:32 So looking through their docs, some of the things you can do is linear programming.
33:36 And I don't know how many people have done linear programming.
33:38 It's really simple.
33:39 It's not necessarily easy to compute, but it's not like a complicated thing.
33:43 But it really, it's incredible the way that that like, this is the exact answer.
33:47 Like all these constraints.
33:48 Here's the optimization.
33:49 I love it because it's simplicity plus power.
33:52 Yeah.
33:53 What we always talked about linear programming is guaranteed optimality, right?
33:57 It's pretty straightforward.
33:59 You don't have a local minimum or a local maximum.
34:02 That's not the actual answer, right?
34:03 Yeah.
34:03 Yeah, exactly.
34:04 And in some cases, especially with nonlinear problems, you can get stuck in a local minimum
34:09 or maximum depending on where you're going.
34:10 But generally speaking, if you write a greedy heuristic, you'll get a good answer.
34:15 But is it optimal?
34:18 Right.
34:18 And that's the real sticking point that the professor's there because maybe this comes
34:23 back to kind of that military background, but we often will not settle, especially in a war
34:28 context, I suppose, for anything that's suboptimal, right?
34:32 And that guaranteed optimality.
34:33 And I know an example of FedEx, right?
34:36 Right.
34:36 They gobble up a lot of the ops research graduates out of the Naval Postgraduate School
34:41 because their profit margins hinge on optimality with delivery, right?
34:47 There's a traveling salesman problem for you, right?
34:49 Yeah.
34:50 Yeah.
34:51 The whole UPS, FedEx delivery stuff, especially with COVID, it's like insane how many of those
34:57 guys are driving around.
34:58 So we've got linear programming, quadratic programming, nonlinear programming, what it
35:02 gets really interesting.
35:03 Let's see, stochastic stuff, just junctive programming, which I don't know anything about,
35:08 but differential algebraic equations, equilibriums, all these different types of problems.
35:14 It can solve those.
35:14 And then some of the projects using it that they've listed on their site that I thought
35:18 was interesting is the DISPA set, which is unit commitment and dispatch model focused on
35:24 balancing and flexibility problems in European power grades.
35:28 It seems like it comes back to power a lot, honestly.
35:30 Yeah.
35:31 I was actually surprised looking through these, seeing how many power problems there were,
35:34 which I don't know.
35:35 I would not have expected that, but yay.
35:37 Yeah.
35:38 I didn't either, but yeah, that's cool.
35:39 There's another one, which I don't know how to pronounce.
35:42 I-D-A-E-S-P-S-A, P-S-E toolkit, which is a open source optimization-based framework for
35:49 chemical processes, which is pretty cool.
35:52 MinPower, which is an open source toolkit for students and researchers and power systems.
35:56 Open energy modeling framework.
35:58 Like I said, it's a lot of energy in here, which is a open framework for developing energy
36:03 models that emphasize communication and community involvement.
36:07 And then OpenAgua, which is a web-based app for modeling water systems for water resource
36:12 planning and management.
36:13 So I think that gives people a sense of like some of the types of problems this is being
36:17 applied to.
36:18 Yeah.
36:18 And I know those are kind of, those are obviously complex and real world.
36:22 I know in a learning context, many of the classic computer science problems, traveling salesman,
36:28 the knapsack problem.
36:29 If you're familiar with that or for the audience's essay is basically, I have a bag that can hold
36:34 20 units of stuff.
36:35 And I have a hundred units worth of things I want.
36:38 I would love to try to fit in it.
36:40 How do I maximize my value by putting in the knapsack?
36:42 We would structure problems like those in Pyamo while we were learning the package.
36:47 Right.
36:48 So some of those classic problems can be solved here.
36:50 Yeah.
36:51 Yeah.
36:51 Cool.
36:51 All right.
36:53 So on the Pyamo website, they have this dietary problem.
36:56 They have a bunch of examples of, here are some examples you said.
36:58 Do you want to talk us through this?
37:00 It's a little bit hard to talk about code over the air.
37:02 So we'll just keep it kind of vague in general, but maybe talk us through this and people go,
37:06 okay, I see what this does and how I might use it.
37:08 Yeah.
37:09 Yeah.
37:09 This is a great example, especially, I don't want to spoil it, but it gets a funny result.
37:13 So what this diet problem is trying to do, and this is a classic optimization problem,
37:18 is you want to select, you have a group of foods and you want to select foods to meet your
37:23 nutritional requirements at minimum cost.
37:26 And I think nutritional means caloric.
37:29 Yeah.
37:30 Not necessarily all your vitamins.
37:32 And I'm living on the food pyramid, right?
37:34 Yeah.
37:36 Yeah.
37:36 It's a very simple, it's a toy problem, right?
37:38 So it's going to be relatively simple.
37:40 And any optimization problem that'll probably go into Piamo is going to have either the word
37:45 minimize or maximize, right?
37:47 So we're trying to meet certain constraints, these caloric requirements while minimizing cost.
37:51 Although I am reading, sorry to cut you off, but it does say, and the amount of vitamins,
37:55 minerals, fat, sodium, and cholesterol.
37:57 So it's not just calories.
37:59 So it's a little more nuanced.
38:00 Okay.
38:01 All right.
38:01 Okay.
38:02 Yeah.
38:02 So what they do is they set up the mathematical formulation outside of code first, which is how you would do any good linear programming.
38:09 And so you have a couple sets, right?
38:11 You have a set of foods and a set of nutrients.
38:13 And then they have a whole bunch of parameters that need to really read, I guess.
38:17 But like the cost per serving of a given food, the amount of nutrient J and food I.
38:22 So it's A sub IJ.
38:25 And then you got minimum level of nutrients.
38:27 Right.
38:28 Like how much sodium, how much fat and so on.
38:30 Yeah.
38:30 Yep.
38:31 Yep.
38:31 The amount of the food, I guess, mass or volume.
38:34 And then how much you can actually consume.
38:36 Let's see here.
38:37 What else have they got?
38:38 This is great.
38:39 The number of servings of food to consume.
38:43 So how much are you eating of any given food, I guess.
38:45 And then, so here's the meat and potatoes of any good LP.
38:48 Either you're going to minimize the cost of the food.
38:51 So you're minimizing the sum of 4i of the cost times how much you eat of different foods.
38:57 Right.
38:57 So i is the different foods and it's how much you eat of it times the cost of it.
39:01 Right.
39:02 So if you're eating $5 milkshakes and you eat two of them, right, you spent 10 bucks.
39:07 Right.
39:07 We're trying to minimize that cost.
39:08 Yeah.
39:09 And you've gotten however much goodness out of that.
39:12 Yeah.
39:12 But you're trying to minimize the price.
39:13 So that would be 10 contribution there.
39:15 Uh-huh.
39:15 Okay.
39:16 Go ahead.
39:16 So then, but now to frame this, I don't know if this is a little abstract for the audience,
39:20 but you can think of a lot of these problems in like a multidimensional framework.
39:24 If you just have X and Y axes and going up and Y and to the right, if you will, and X is
39:31 both the direction you want to go.
39:32 Well, the optimal spot of those two constraints is the top right corner.
39:36 Right.
39:37 So I don't know if that made sense, but yeah.
39:39 So for the constraints, you're going to limit the nutrient consumption for each one.
39:43 So you have like a less than set up.
39:45 You got to limit the amount of food consumed.
39:47 Like you can't just eat like a hundred cheeseburgers and go, we're good.
39:50 Yeah.
39:51 We're good.
39:51 Right.
39:52 And then you have a maximum amount of food that I guess your stomach can hold that they
39:55 have in here.
39:56 Right.
39:57 So you can only eat so much of the various foods less than or equal to the maximum amount you
40:03 can eat.
40:03 And then there's also, and this is important that you'll see this will get forgotten a lot
40:08 because it's so stupid, but you have to have a lower bound with optimization problems.
40:13 Right.
40:13 So they, the amount of food you eat has to be greater than or equal to zero.
40:16 Right.
40:17 Cause if you don't have that in there, it'll be like, Oh, eat infinite negative food and
40:21 you're great.
40:21 Right.
40:22 It's free.
40:22 You can't eat negative milkshakes.
40:24 Right.
40:24 So.
40:25 Exactly.
40:25 You get paid to eat it.
40:26 So that's sort of the LP setup that they have on this site.
40:30 And then they go into the actual pie on formulation where they were always this, they import it.
40:35 And then you'll see if someone were to look at this link in the show notes, they, they
40:40 define it as an abstract model.
40:41 You can do a concrete model, an abstract model.
40:44 I'm actually not a little embarrassing.
40:46 My, my thesis was concrete.
40:48 I'm not super informed on what the difference is between those, but we can move along, I suppose.
40:55 And then they just, in their code, they, we define those things.
40:59 We had the set of food, right?
41:00 That was F.
41:01 And so they're going to have, there's an object in Pyamo called model, right?
41:05 So model.f is a set.
41:08 They set it equal to a set and model.n is the nutrient set.
41:13 So model.n equals a set, right?
41:14 And those are just, now those are objects in Pyamo's framework in Python that now just
41:19 exist for the purpose of these optimization problems.
41:22 I've been talking a lot.
41:23 You want to run with this?
41:24 I don't know.
41:24 No, no, go ahead.
41:25 Like, you know this better than I do.
41:26 So we're getting close to the end.
41:28 That's actually not a whole lot more to it.
41:29 Yeah.
41:29 And then we're going to get to the fun part at the end.
41:31 So then they have to define the cost of each food, right?
41:33 And this is, as a small aside, this was great about doing this in Python is that you can,
41:39 we all know how well Python works with data, right?
41:43 So half of my thesis code was just taking the real world electrical grid data that we had
41:48 and getting it shaped for use, right?
41:51 So they do something similar here where they are looking at the data they have and feeding it in for each food, right?
42:00 And then you got to keep track of how much of the stuff you're eating and they have some more code in there.
42:05 Yeah.
42:05 So you like, you've got this param object.
42:07 You say the parameters come out of this, the food set or the nutrition set, the nutrient set.
42:13 And then here's, these are positive reels or these are non-negative reels or these are integers.
42:18 They can go up to infinity or whatever, right?
42:21 Yep.
42:21 Yeah.
42:22 Thanks for bringing that up.
42:22 So yeah.
42:23 So you kind of just lay that out really.
42:24 I think it's pretty straightforward.
42:25 It's good.
42:26 These are the constraints.
42:27 Yep.
42:27 And you have these, bam.
42:29 And now, now the model from a mathematical perspective understands what those are, right?
42:34 And then the exciting part is they get to where they define the objective function, which as we described is how much does the food cost times how much of that food you eat for a given food.
42:44 And then minimizing that.
42:46 So they set that up.
42:49 And then the same constraints that we discussed a couple minutes ago about, again, the lower bound, not going below zero, the nutrient consumption for each food.
42:57 They set up those constraints again in this, their functions that they set up and then pass these.
43:03 You will usually in Pyamo, you'll write the function just as you would essentially any other Python function, passing it some of the elements of your model.
43:12 And then you'll, once you have that function written, you will then pass that to a model dot, whatever you want to name it.
43:22 And the function contains the constraint.
43:26 And now passing that to the model dot, whatever your name is, will give that Pyamo object the inherent mathematical rules of said constraint.
43:36 Yeah.
43:37 It's pretty neat.
43:38 And I guess the last bit is there's also a data file, which looks a little bit like YAML.
43:44 I don't think it's YAML at all, but it looks like that's kind of the visualization.
43:48 It says, okay, we have cheeseburgers, ham sandwiches, fish sandwiches, chicken sandwiches, sausage biscuits.
43:53 You're going to get some serious caloric intake from that.
43:55 And then, you know, like how much you're allowed to eat, how much protein you need, how much carbohydrates.
44:01 And then it lays out like the ingredients for each one of those.
44:05 So you just define this data file that says the parameter F has this options, the parameter N has these options and so on.
44:11 Right.
44:12 So.
44:12 Yep.
44:13 Put those two things together at the end.
44:15 You say Pyamo solve, give it a solver, give it the Python code and the data file that has all these parameters.
44:21 Yes.
44:22 And it comes up with a beautiful solution in a, actually, I think an actual YAML file for the output.
44:27 Yep.
44:28 And then, so here's the funny part.
44:29 So how should we eat?
44:30 Like I'm looking to get a little healthier, but also save some money.
44:33 So what do I do?
44:33 Yeah.
44:33 So, well, I got some great news for you, my friend.
44:36 For only $15 a day.
44:39 If you eat four cheeseburgers, only five French fries, one fish sandwich.
44:45 Oh, five servings.
44:47 Oh yeah.
44:47 Five servings of French fries.
44:48 Five servings of French fries, I believe.
44:49 One fish sandwich and four milks.
44:51 You're good.
44:52 Boom.
44:53 Yes.
44:54 Yes.
44:56 The only thing that would make me happier is if there was like an ice cream shake or two in there.
45:00 What you got to do is you got to be sitting there eating that and just let people that walk by, just tell them that you're optimal.
45:07 Exactly.
45:08 I've solved it.
45:10 I've solved the nutritional problem.
45:12 Yeah.
45:13 So I'll include this problem in the show notes.
45:14 It's pretty interesting.
45:16 It went really quick.
45:17 It took 9.7 milliseconds to run this.
45:19 So that's pretty quick.
45:21 The best.
45:21 And I mean, I can tell you, we had time parameters in my thesis and we're talking a pretty robust
45:26 electrical system and some pretty high, high level mathematics to account for all of the three phase AC power flow constraints and everything there in for a lot from the electrical engineering perspective.
45:36 Yeah.
45:37 And I did all of it on a fairly middle of the road, like 2015 MacBook Pro.
45:42 And it would knock it out in 20 seconds, maybe.
45:46 Yeah.
45:46 That's incredible.
45:47 I thought, well, maybe I'll come back to this tomorrow.
45:49 You know, I didn't know.
45:51 Yeah.
45:52 Yeah.
45:53 Tell people it's going to take really long.
45:55 I'll take the rest of the day off.
45:56 Well, darn it.
45:56 It's done already.
45:57 Yeah.
45:57 But that's the nice thing about it is when you structure, it's so abstract, it's hard to talk about like a podcast, I suppose.
46:05 But when you structure the mathematics right, letting the solver work, that the solution is computationally, I suppose, not that intensive, I guess I would say.
46:16 Yeah.
46:17 As opposed to trying to enumerate the best solution.
46:19 Right.
46:21 Yeah.
46:21 Yeah.
46:22 But that's the computational savings.
46:23 Exactly.
46:25 You're taking an intelligent way to get to optimality as opposed to trying to do something and the sun would burn out before you'd finish, right?
46:32 Right.
46:33 Well, and it's a solver, right?
46:35 It doesn't just like try every possible thing.
46:38 It has algorithms and stuff and it's beautiful.
46:40 Yeah.
46:41 And the individuals that write these solvers, I mean, they're the mad scientists, right?
46:46 That are able to.
46:47 Yeah.
46:48 You know, the solvers that actually blow my mind are the stochastic ones.
46:52 I took some Stokes classes and it was just one of those like, okay.
46:55 I don't really understand.
46:58 I barely touched on it.
46:59 I wasn't very much on the statistical side, but I did work with some people in my math experience around those.
47:06 And it's like, here's a problem that'll take seven days to solve, or we can do this little magic and get basically the same answer in about half a second.
47:13 Like, wait a minute, how did that even, how is this even possible?
47:16 Like, what are these things doing?
47:17 Well, I mean, that kind of comes back to what I said.
47:19 I get a little naive with some of my education at times, but I want to say that in one of our first coding classes, we set up something like a traveling salesman problem.
47:29 And I'm sitting there going, I got a Core i7 in here.
47:32 This will knock this out.
47:34 I start letting it go.
47:35 And just to prove the point, the professor is like, literally, because we're doing it like brute force, basically.
47:41 He's like, the sun will die before your computer will finish this problem.
47:45 Yeah.
47:45 You know, and then we structure it smartly in Piomo, and it takes a couple milliseconds.
47:49 Yeah.
47:50 It's insane.
47:51 That's so insane.
47:52 You also start to appreciate, like, factorial and stuff.
47:56 Oh, yeah, right.
47:57 What do you mean, the heat death of the universe before this time?
48:01 This is no good.
48:01 All right.
48:02 Well, I think that gives people a sense.
48:04 I mean, honestly, I don't recommend the diet.
48:07 But it gives people a sense of the type of problems and the way you set them up.
48:13 And it's a pretty clear, understandable problem.
48:15 And then a simple bit of code, like the Python code that actually does the smarts, right?
48:21 The cost and the limits or the constraints.
48:24 But it's probably like six or seven lines of code.
48:26 It's not a lot.
48:27 No, it's very straightforward.
48:29 The actual, again, coming back to, you know, my thesis, heck, I haven't pulled up, but something
48:34 like 600 lines of code.
48:35 And I want to say two thirds of that was just prepping the data, right?
48:39 And then the actual Piomo work was.
48:42 Yeah, exactly.
48:43 Yeah.
48:44 Maybe of that remaining third half of it.
48:46 And then the last part of that third was like shaping the output to be intelligible,
48:50 right?
48:51 The Piomo itself is pretty clean.
48:53 Right.
48:54 Wow.
48:54 Okay.
48:54 Yeah.
48:55 It definitely looks interesting.
48:56 And it looks very like it solves many different types of classes of problems, right?
49:01 Like linear programming versus nonlinear programming versus stochastic programming.
49:04 And then those solve each many interesting real world problems, right?
49:09 So this is broadly applicable, I think.
49:11 Yeah.
49:11 And I'm one of those guys that's like every problem is a network problem, right?
49:14 And you can feed those to this.
49:16 And then I view the world as either network problems or assignment problems.
49:19 And assignment kind of ties back into some of my work for the government, which is, do we
49:23 have the right people where they need to be?
49:24 And you can throw that at this.
49:26 Yeah.
49:26 Are you a fan of graph theory?
49:27 Yes.
49:28 Yeah, I am too.
49:29 I love that part.
49:29 All right.
49:31 Let me add, I think this is probably a good place to sort of wrap up our general conversation.
49:34 I'll ask you the two questions.
49:35 Anything else we should add to the general conversation before we wrap it up?
49:38 I got to just thank professors Alderson and Carlisle.
49:41 I mean, again, kid from the country didn't know what was going on in life and kind of stumbled
49:46 into this curriculum that has completely changed my life.
49:48 And I've always joked, I'm the dumb, smart kid that's smart enough to get into the advanced
49:53 stuff and then struggle the whole time.
49:55 And yeah.
49:57 Exactly.
49:57 I don't belong here, but somehow they let me in.
49:59 But yeah, that's cool.
50:01 Yeah.
50:01 That happened to me at the nuclear power curriculum.
50:03 It happened to me here.
50:04 I'm forever indebted to those two gentlemen.
50:06 So just thanks to them is something I would love the chance to throw out here.
50:09 Yeah, absolutely.
50:09 All right.
50:10 So before I let you out of here, this has been really interesting, but let me ask you
50:13 the final two questions.
50:14 And I have a twist on the second one because I want to throw out something in addition.
50:19 And while we're talking, because I want to hear your thoughts on it.
50:21 Okay.
50:22 If you're going to write some code, what editor would you use?
50:24 Either Jupyter Notebooks or Sublime Text.
50:27 Jupyter or JupyterLab?
50:28 Ooh, now you're getting beyond my head.
50:30 Have you made the transition over to JupyterLab or are you sticking with the traditional?
50:34 I don't think I have.
50:35 I'm probably stuck in the past.
50:37 Yeah.
50:38 They're pretty similar.
50:39 They're pretty similar.
50:39 All right.
50:40 Good ones.
50:41 And then notable PyPI package.
50:43 Pyama, probably the reason I'm here.
50:44 Right?
50:45 So, yeah.
50:47 Awesome.
50:48 That's really cool.
50:49 That's really cool.
50:50 All right.
50:50 So I put, I want to give a shout out to one because I think this is actually going to
50:53 be pretty interesting.
50:54 I haven't talked about it on Talk Python.
50:55 I have on Python Bytes.
50:57 Do you see that link?
50:58 Yeah.
50:58 Click, open that link.
50:59 And then let me describe this to the people.
51:01 And then you give me your thoughts.
51:02 There's a cool graphic.
51:03 So you don't have to like, there's like an animated GIF.
51:06 So you don't have to like feed.
51:07 So a lot of times what we do is we do math and optimization problems like we're talking
51:13 about here in code.
51:16 And the code looks a little bit like theoretical math, but not really like theoretical math.
51:22 But it would be really nice if you could have like the LaTeX fancy published like math book
51:29 representation of the steps that you're doing.
51:32 So there's a really cool project called Hand Calcs.
51:36 Have you heard of this?
51:38 No, I've not.
51:39 But so I wrote my thesis in LaTeX because there was so much of that fancy math, the actual written
51:49 math, right?
51:50 For all my constraints.
51:51 Yeah.
51:51 And learning LaTeX was a challenge, especially when I'm trying to wrap my mind around my
51:57 actual thesis work.
51:58 So seeing what I'm seeing here and the fact that it's in Python, I'm jealous.
52:02 I'm jealous right now.
52:03 Yeah.
52:03 Just scroll through some of the pictures here and I'll put it in the show notes as well.
52:07 So what you can do is you can write out like statements and equations in Python.
52:12 And then you can say, render with this Hand Calc, you say, render the, what I would have
52:17 done like step-by-step sequence I would have had to do to work out that calculation, right?
52:23 So you could say like X equals negative B plus square root B squared minus 4AC divided by
52:29 two, like quadratic.
52:30 And it'll actually, if it knows what the values of those are, it'll write out the steps of solving
52:36 that equation like bit by bit by bit as you would in like math class, but in Jupyter notebooks.
52:42 Yeah.
52:42 This is super cool.
52:43 Isn't this neat?
52:45 I thought like given what you're talking about, like this, this is a good thing to pair it with.
52:49 Oh yeah.
52:49 I mean, this would have, this would have saved a lot of time.
52:52 What have I done with my life?
52:56 This is pretty new.
52:57 I believe this is from Connor Fester and I'm really impressed with this project.
53:00 This is cool.
53:01 Yeah.
53:01 That's super, super cool.
53:04 Cause I mean, for me, it was either try to use the, in my opinion, atrocious math type
53:09 plugin in word, which not happening or write in LaTeX.
53:16 And this would have been more fun because I would have been able to stick with one.
53:19 Yeah.
53:19 LaTeX is fine, right?
53:21 Like all the math books and all the math papers and physics, I suppose as well.
53:24 Like almost all of them are done in that.
53:26 Right.
53:26 But the thing is now you've got the data in two places and if you change one, but you
53:31 forget to change the other.
53:32 Oh no.
53:33 It's all like, this just takes your Python code and like turns it into symbolic math.
53:38 It's awesome.
53:38 Yeah.
53:39 This is super cool.
53:40 Nice.
53:40 All right.
53:40 Well, let's leave it with hand calcs and a final call to action.
53:43 People want to get started with these types of problems and like using libraries like this.
53:48 What do you say?
53:49 Well, if you want to use Pyamo, if you're listening to this podcast, you're probably
53:52 familiar with some of those classic computer science problems.
53:55 I'd say pip install Pyamo and try to structure one of those problems in that system.
54:00 Then my other, I guess I'm going to have two calls to actions.
54:03 I'm cheating.
54:03 Go for it.
54:04 The other one I'll say is from that analyst perspective, kind of bringing it full circle
54:08 to Jacqueline and Emily, I get looked at at work like I'm a sorcerer because of some
54:12 of my Python skills and listening to some of your guests, like I'm not right.
54:16 But your calls to action often reach out saying, Hey, you know, maybe you're that person in
54:22 a job and you have this one Excel task that you do all the time, right?
54:26 You could automate that.
54:27 Well, I'm kind of that guy in a way where the calls to action that you've sent out, again,
54:35 I'm that person who has been automating things.
54:38 There was one example where we literally had people going through surveys by hand.
54:42 So this is surveys where like we ask our sailors, how do you feel about A, B, C, and
54:46 D?
54:47 And they used to go through them by hand.
54:48 And I was like, that can be better, right?
54:51 And so just...
54:51 This can't be the best way.
54:54 No, right?
54:55 And so we had the data digitally and I'm not even an NLP, not to be confused with nonlinear
55:00 programming, but I'm not a natural language processing guy.
55:02 But I installed some packages and was able to try to get sentiment out of surveys, right?
55:07 And so...
55:07 Oh, that's cool.
55:09 I just say that the power of this language can help at all levels.
55:13 And I'm at a fairly high level of government.
55:14 It's incredible what it does for us.
55:16 So the call to action, I suppose I'm rambling a little bit, is if you are that guy out there,
55:21 take it from another one of that guy that it really does work.
55:24 Yeah.
55:24 Yeah.
55:25 I think it's great.
55:26 And you're in one of these positions where you're a little bit on the boundary of a lot
55:31 of people who need answers.
55:32 They have a lot of data, but they can't answer the question themselves through code or programming
55:37 or anything along those lines.
55:39 And so it's like right there for you to just take that little step and come across as a
55:44 magician.
55:44 Like I do like to say that developers, data scientists, people who can write code, we really are in some
55:51 sense, the wizards or magicians of the modern era, right?
55:56 You think about an idea, you sort of do the incantation.
56:00 And then out of just energy in your thought comes a thing that can have huge impact.
56:05 And those don't have to be, oh, I created some huge, like I created Airbnb or whatever.
56:09 It could be there are people that can now focus on stuff that humans are good at and not just
56:15 typing in, moving stuff around from one Excel sheet to the other, to copy it over to PowerPoint,
56:19 to show it to the general.
56:20 Yep, absolutely.
56:21 I have so many examples.
56:22 I can give you one more.
56:23 Like we have this huge database of what civilian skills people have in the Navy Reserve, which
56:29 is a unique thing of us because we have our reservists have their military life, but they
56:32 have their civilian life.
56:33 And facets of their civilian life might be applicable skill sets that we could employ in a military
56:39 context.
56:40 And whoever designed the system to capture this only set up free text entry.
56:46 So imagine if you have 20,000 people do free text entry of what they're capable of, right?
56:55 You're like, couldn't I have just gotten a combo box?
56:58 Exactly.
57:01 But...
57:02 Or a radio button list or something.
57:04 Some kind of dropdown, maybe some cascading dropdown menus, right?
57:08 But so I inherited that database and it was sort of one of those, can you make anything of
57:13 this?
57:14 And right at the same time, a pretty high level individual was coming to us saying,
57:17 hey, do you have anyone with civilian skills to do this?
57:21 And I just wrote the world's most basic query and was like, yeah, we got seven.
57:25 Here they are.
57:26 Right?
57:27 Yeah, that's awesome.
57:28 And you would have thought I'd like conjured a spell, right?
57:31 And...
57:32 Yeah.
57:32 So this is why I made that source for a common beginning of this.
57:36 It really is incredible what you can do.
57:38 It absolutely is.
57:38 And it's within everyone's reach, I think.
57:40 Yeah.
57:41 It just takes a little bit of practice and a little bit of trying it out.
57:44 Yeah.
57:44 All right, Clark.
57:45 Thank you so much for being here.
57:46 It's been a lot of fun to talk about all these problems and cool work.
57:49 And thanks for helping us all live a little healthier lives, getting our diet figured out.
57:54 Four cheeseburgers, five servings of fries, a fish sandwich, and four milks.
57:58 You're set.
57:59 You're set.
58:00 You're going to live forever.
58:02 Optimally.
58:03 All right.
58:03 Great to chat with you.
58:04 All right.
58:06 Thanks, Michael.
58:06 Yeah.
58:07 Bye-bye.
58:07 This has been another episode of Talk Python to Me.
58:11 Our guest on this episode was Clark Petrie.
58:14 And it's been brought to you by us over at Talk Python Training and our friends at Linode.
58:18 Simplify your infrastructure and cut your cloud bills in half with Linode's Linux virtual machines.
58:23 Develop, deploy, and scale your modern applications faster and easier.
58:26 Visit talkpython.fm/Linode and click the Create Free Account button to get started.
58:31 Want to level up your Python?
58:33 If you're just getting started, try my Python Jumpstart by Building 10 Apps course.
58:38 Or if you're looking for something more advanced, check out our new async course that digs into
58:43 all the different types of async programming you can do in Python.
58:46 And of course, if you're interested in more than one of these, be sure to check out our
58:50 Everything Bundle.
58:51 It's like a subscription that never expires.
58:53 Be sure to subscribe to the show.
58:55 Open your favorite podcatcher and search for Python.
58:57 We should be right at the top.
58:58 You can also find the iTunes feed at /itunes, the Google Play feed at /play,
59:03 and the direct RSS feed at /rss on talkpython.fm.
59:07 This is your host, Michael Kennedy.
59:09 Thanks so much for listening.
59:11 I really appreciate it.
59:12 Now get out there and write some Python code.
59:14 I'll see you next time.
59:34 Thank you.