Tag Archives: engineering

Are There PID Controllers in Data Science?

A while back I went to a data science meetup, and the presentation was on how an analyst solved his problem with a PID controller. As an engineer I’m well familiar with PID controllers. I spent a lot of time studying them in school. The problem in this scenario was optimizing the amount and cost of ad impressions in a given day. My first thought when I saw it was that this isn’t data science. You’d think that with the amount of data available that a regression or decision tree might work better. I’ve thought about this quite a bit since then, and my view has changed. In fact, I now his approach is brilliant in its simplicity.

PID Controller

By TravTigerEE of Wikepedia

For those not familiar, a Proportional Integral Derivative controller is a control-feedback loop that automates the control of systems. That’s a fancy way of saying that they control an input and monitor the output. If there’s a difference between the output and the desired output, the input is adjusted to account for this error. The first designs were for steering a ship, automating the task of maintaining a heading when there are wind or currents to account for. These aren’t new, the first designs were completed in the 1920’s, and today they’re commonplace. In fact, you’ve used them.

Your home’s thermostat is a PID controller. The input is whether or not to turn on your air conditioner or heater, the desired output is the temperature you want, and it measures the inside temperature. Most cars these days have cruise control, that’s another example of a PID controller that we use on a daily basis. An aircraft autopilot is a more complex example, as it maintains heading, altitude and airspeed. Your computer’s hard drive uses a PID controller to position its head on the platter. And they’re used extensively in manufacturing and industrial applications.

Some of the more cool or exotic uses of PID controllers are in a car’s suspension system, to make the ride ultra smooth. NASA uses them on their launch platforms to aid in keeping rockets balanced upright. Recently SpaceX and Blue Origin have autonomously landed rockets through the use of advanced control systems. And Boston Dynamics has created a number of awesome walking robots that maintain balance across slippery or rugged terrain. Some of these applications are quite a bit more advanced than the simple PID controller, but they definitely contain PID controllers.

By now hopefully you can see why I’d question whether PID controllers would be considered a data science tool. Certainly they’re useful, and if you find an application where they’ll work then its a great choice because they’re well documented, relatively easy to implement, and once they’re tuned they require little maintenance. These are all great attributes, and yet I wouldn’t expect them to be covered in a statistics course. Or a computer science course. The math behind PID controllers is calculus. In my own education, I studied a lot of calculus and these were only covered in my engineering coursework.

In fact, if we look at common data science tools, PID controllers are absent. One of the great reasons for choosing R over another language is that there are packages for everything. A Johns Hopkins professor even created a popular video proclaiming There’s an R Package for That, playing on the popular cell phone map ads from a few years ago. And yet, if you do a search there is no PID controller package for R. There is a blog post showing how to create one, but no package. And what about Python’s data science library scikit-learn? Nope. Data science upstart Julia? No. Not even Apache’s Hadoop or Spark frameworks have pre-built algorithms for a PID controller.

These data science packages and libraries are all designed to make sense of thousands (or more) rows of hundreds of variables. A PID controller reads one thing and controls another. PID controllers don’t work with big data. And yet, they’re incredibly useful in applications where we work with data.

So now lets pay closer attention to the data science side. A popular post over the past few years has been Drew Conway’s data science Venn diagram. One of the 3 primary components is hacking skills. Conway partly explains this as discovery and building knowledge via hypotheses and experimentation. That means figuring out how to get things done. You aren’t limited to what libraries have to offer. If you have domain experience and can simplify your problem to the point that a PID controller accomplishes what you need, that’s valuable no matter what you call it. I’d say that fits within data science.

It has also occurred to me that there are a few other data science applications not covered universally by data science tools. Collaborative filtering and A/B testing are both definitely in the realm of data science, and yet if you choose one of these methods for your project you’ll likely be coding up your own solution. Natural language processing is another example of a field within data science that calls on skills outside of a statistical model. There are definitely packages and libraries for NLP in the major languages, but this field has its own methods outside of categorization, classification or regression. And maybe that’s my point. This is data science. You do what you have to do.

Notice that I’m careful to call this data science. Another closely related moniker is machine learning. A PID controller is definitely not machine learning, nor knowledge discovery nor operations research nor data mining. This is not a method for classification or clustering. There is no model being created. This isn’t Frequentist or Bayesian. PID controllers can definitely be useful for solving data science problems, but they cannot predict anything.

What are some potential use cases where a data scientist might choose a PID controller? As a generic answer I’d say anywhere that you believe there’s a direct relationship between a variable that you control and an output that you monitor. The data stream should be continuous, or at least assumed continuous. The example that lead to this thought is perfect, controlling the number of ad impressions by adjusting the bid price in an auction. In this example, your ads are up and running 24 hours a day, 7 days a week, and you know almost instantly how many impressions you earned.

I actually think PID controllers could work well for a lot of problems with the online realm. Buying online ads, budget pacing and load balancing come to mind. There are probably areas within SEO where it would help.

This would not work as well for optimizing football game attendance by adjusting ticket prices. In this scenario the data is not continuous, there are days or months between events. There are also too many other variables at play. If temperatures are below freezing then ticket price probably isn’t a factor in game attendance, people won’t be as willing to sit in the cold. If the game is post-season then temperature probably isn’t a factor, people will attend regardless of temperature because they’re excited to see their team in the playoffs. These are guesses, but hopefully you see my point.

My own conclusion in this is that, yes, PID controllers are fair game within the realm of data science. The realm of controllers is stable, mature, and is still an area of active research. If you find a scenario where a PID controller gives you the results you’re looking for, then its absolutely a good choice.

Cellulosic Ethanol

Dual-fuel gas station at Sao Paulo, Brazil.
Image via Wikipedia

Last summer I shared my thoughts on biofuels, specifically E85. In short, yes they can offset our dependence on foreign oil, but because biofuels contain less energy per gallon than gasoline we’ll need more of it to keep up with our current consumption rates, and this solution completely neglects our need for more efficient cars.

There is a process that can produce E85 with the waste from other manufacturing processes that involve plants. This uses the plant material left over from other types of farming such as sugar or corn and uses the stalks, straw, wood, etc to make cellulosic ethanol. Cellulose is present in all plants, so there’s plenty of this material available, and humans can’t digest it, so this will never be a source of food for us. Plus, this uses the waste of other processes, so it wasn’t being used anyway. This negates the argument about growing for food versus fuel. Also, because this is a biofuel, it burns cleaner than petroleum based fuels. So far so good, right?

There are a couple of snags hidden in the details. First, the process of turning plant material into something you can burn in your car is not very efficient. With today’s technology we’d need A LOT of plant material to make enough E85 to make a dent in our foreign oil consumption, more than required to make corn ethanol. What this means is that if we’re going to look at this as a large scale source of energy, the waste from other manufacturing processes won’t provide enough raw material to work with. We’ll need to grow plants for the purpose of putting fuel in our cars. The food versus fuel argument is not solved.

And there’s more. Cellulosic ethanol is estimated to cost $2 per gallon, about the same as gasoline. Because its ethanol, a tank full of this fuel still won’t take you as far as a tank of gasoline, so the net cost to the consumer will still increase. The takeaway is that this has the potential to drive both food and fuel prices up. That’s not exactly what I have in mind when looking for alternative energies.

If you’re a die hard green energy proponent higher prices may not be enough to deter you, you want cleaner energy regardless of cost. Okay, lets look at this from another angle. Think of all the engergy required to grow, harvest and manufacture cellulosic ethanol. Tractors are needed, electricity to run the plant, fuel to distill the final product. Apart from the land devoted to grow the raw material, each of theses processes require energy. Today that energy is provided by petroleum based products. In other words, non-green energy is being used in the production of a green biofuel (what the???). If the manufacturers switched to burning ethanol in their processes so that this fuel were green from start to finish, they would still be burning fuel to make fuel, but because ethanol contains less energy per gallon they’d need to burn more of it and the cost of production would increase. Cellulosic ethanol would then become more expensive than gasoline. I’ve read that cellulosic ethanol burns clean enough that green house gases are reduced by 90% when compared with petroleum products. I question that stat, but even if true, because of the amount of energy required to produce the fuel it’s not enough. It would be more expensive and we’d still be polluting the atmosphere.

Keep in mind that there’s a good chance that your car is not capable of burning E85 as is. If you want to take advantage of E85 you’ll need to convert your engine which costs anywhere between $500 and $1,000. And, keep in mind that you’ll be spending more for fuel than you would if you chose to burn gasoline.

So lets put all of this together. If cellulosic ethanol becomes available in my neighborhood next year, I may be tempted to burn it instead of my regular gasoline. I’ll pay to convert my Nissan Maxima to burn E85. Then, I’ll fill my tank up. The cost will be about the same as what it costs me to fill up with gasoline, but instead of getting 300 miles per tank, I’ll only be able to drive about 250 miles. Plus, I’m buying a fuel that displaces land used for food production, and a lot of energy was used to make my E85.

I’m a strong proponent of alternative energies, for both political and environmental reasons. I think its smart for us to consider all kinds of solutions to our energy needs. Plus, as an engineer I appreciate that as a country we’re pursuing new technologies. There are two things that I object to about cellulosic ethanol. First, the media and biofuel evangelists tout this as the solution to all of our problems, and that’s just not the case. This doesn’t fully address our dependance on foreign oil, and it isn’t a boon for the environment either. At best, its trading one set of problems for another. And second, our government is pumping millions upon millions into this industry. I just don’t see this paying off. I’m in favor of smaller goverment, so honestly I wish they would leave this to the private sector, period. Since that isn’t a reality I wish they would at least shift some of the funds into other solutions, like nuclear fusion or geothermal energy, a smart power grid, improving wind energy storage… there are many other solutions more promising than biofuels.

Sweetwater Texas

© Guerito 2005
Image via Wikipedia

I have believed for a long time that high energy prices would ultimately be good for the American economy. I generally keep an ear to the ground for new developments in renewable energy technology, and new products that take advantage of alternative energy sources. I recently learned of a small town that has gotten in front of the alternative energy movement, Sweetwater, Texas. This has completely changed the outlook of the community. Ten years ago this was a town that teens left as soon as they could because Sweetwater offered no future for them. The town decided to install wind turbines. Today Sweetwater Texas is running on green energy.

This did more than just revitalize their economy. They needed workers to install and maintain the turbines, so in 2007 the community college in Sweetwater launched the first two-year program on wind energy technology (now there are several around the country). They still have more jobs than they can fill, so people are moving there to find work. Home prices have gone up and new homes are being built, which means more construction jobs. America’s premier wind energy legal seminar, which provides continuing legal education to attorneys, is held each year in Sweetwater. The mayor has been interviewed by the Discovery Channel.
Continue reading

Gene Kranz

Recent photo of NASA's very own Gene Kranz.
Image via Wikipedia

Tonight Gene Kranz, the famed NASA mission controller played by Ed Harris in Apollo 13, came to speak at UT and I was able to make it. I went with low expectations because I didn’t know much about him other than what I had seen in the movie, and just wow. This man is awesome. The speech was really inspiring and gave me renewed pride in being an engineer and being an American. It was that kind of speech.

Before Kranz came out, one of the professors involved in bringing him to speak at UT introduced some of the students and people present in the audience, and he did one of the coolest things that I’ve seen at any speech. He had the veterans stand to be recognized, and then he asked the military members awaiting a commission stand and be recognized. I’m proud of America, and I’m proud of my service, and I think its awesome that he gave credit to the military’s future leaders.

Mr. Kranz spoke for over an hour, most of it spent walking us through his thoughts and decision process during the Apollo 13 mission. Based on what he said I believe that the movie is pretty accurate (I’ve seen it dozens of times). What really came through in his speech, that I hadn’t noticed in the movie, is the amount of trust and cooperation between the team members. He pointed out a couple of times when he made a decision in the interest of moving forward, that some of the other engineers disagreed with, but once Kranz announced the decision the whole team got on board and worked together for the benefit of the mission. The whole story is inspiring, but hearing it from the perspective of this man in particular is something that I won’t soon forget.

When he was done he got a standing ovation, which he was apparently uncomfortable with because he quickly had us sit back down for a question and answer session. This was my favorite part of the event, the questions were great and he had some very good answers. I don’t remember all of the questions, but here are the ones that struck me.

He was asked if he was pleased with his portrayal in movies. He said that he thought Ed Harris did a great job, and that the story line of Apollo 13 was pretty accurate, with one notable exception. In the scene just after they realize the extent of the problem a few of the engineers state that such and such can’t be done. In the movie Harris (playing Kranz) blows up and says something along the lines of “failure is not an option”. Tonight Kranz said that he would never blow up at anyone who was within his authority, he wouldn’t allow himself the luxury of emotion or losing his cool when leading his team. I thought that was particularly insightful.

Someone asked him what he thought of NASA’s decommissioning of the space shuttle and planned absence from spaceflight. He said he thinks this is a travesty because America needs awesome challenges to inspire and bring out the best in its people. Leaving a gap in the flight plan also means forgetting things that we’ve fought hard to learn.

When asked what he thought of privatized spaceflight, he said “its the greatest thing since canned beer.” There is nothing like advancing technology to stimulate the economy and capture the attention of the world.

My favorite response came when he was asked how he found or acquired the leadership skills to bring out the absolute best in his team. He said that he grew up in a time when his father’s generation fought in WWII. He and his peers were too young to go, but looked at his parent’s generation as heroes which challenged him to achieve something great. Then in the early days of supersonic flight men like John Stapp, Joe Kittinger and Chuck Yeager risked their lives for advances in aviation technology. During Project Mercury John Glenn climbed into an Atlas rocket, and at that time three of the first five of them had exploded on launch. Everyone at NASA had a clear understanding of the risks involved and chose to participate anyway because we saw the greatness within the goals. This brings a very clear focus that is difficult to achieve in any environment. Kranz said that he’s spent a lot of time ruminating over his career and isn’t able to point to any one thing that makes him a leader, but that he does recognize that he wanted to live up to the greatness that he saw in his father’s generation and believed that he could.

I just can’t express how awesome it was to hear Kranz speak. His involvement in Apollo 13 and NASA makes him an American icon, and his story is definitely inspiring. I was tempted to skip because I had homework to get done last night. I’m really glad that I didn’t.

Electric Drag Racing

A buddy of mine sent me a link to an electric car that is entering in drag races. This is awesome. John Weyland gutted a 1972 Datsun 1200, converted it into an electric drive, named it White Zombie and has breaking records at his local drag strip. In this video he drops both a Corvette and a BMW M3. 2015 Edit: the video has been removed.
Continue reading

The Ford ECOnetic

I just learned that Ford has a car in production that will get 65 MPG. That’s not a misprint. The Ford ECOnetic is a diesel hatchback that gets a full 65 MPG. For those of you keeping up, that’s better than the Prius, and it isn’t even a hybrid. Ford has opted to have the motor manufactured in Britain, so it will not be cost effective to sell this car in America. Once again, you read right. The ECOnetic will only be available in Europe.

Americans are buying fuel efficient cars from Japan, and selling cars with even higher fuel efficiency in Europe. I’m losing hope.

200+ MPG

Its been too long since I’ve written. I’ve had a few posts rattling around in my head for weeks, but no time. Such is the life of a working student.

My mind is still consumed by fuel efficiency and energy consumption. I’ve had a handful of great conversations with other engineers, there are definitely some very cool ideas out there to bring the consumption rate of your daily driver up into the triple digits. And then, Volkswagen busts out with a 235 MPG car.

How? By rethinking everything that robs energy from a car in motion. Weight is reduced by having a carbon fiber body. Aerodynamic drag is reduced through tandem seating. It has a tiny 1 Liter engine with hybrid drive.

Is it ugly? You bet! Is it expensive? And how! Fortunately for you, it will save more than enough money to compensate for these annoyances. Assume you drive 1,000 miles per month, and you get about 22 MPG (like me). Getting one of these babies will do the same job as your car, and you save about 40 gallons of gas per month. Your neighbor with a Prius will be green with envy.

While I’m here, Obama recently recommended that we reduce our dependency on foreign oil by keeping our cars tuned and our tires inflated. Time magazine even backed him up with some favorable numbers. McCain bandwaggoned himself into the conversation. In the interest of time I’ll be succinct, you’re all idiots, and this plan is asinine. Of course it will save fuel, but once again it ignores the larger need for more fuel efficient cars. I have a much better idea. Lets apply our knowledge of science and physics and design a car that is more efficient.

Props to Chevy for ponying up a car that people are lining up for, the all electric Chevy Volt. Its cool to see American companies contributing.

As usual, there is more to say, but I don’t have the time to say it. I have a final exam in the morning, and that test isn’t going to take itself.

Ethanol

So I’ve been blogging about gas prices and the state of American automakers lately. I haven’t yet addressed one of the solutions that GM has proposed. Ethanol, or E85. Chevy and GMC are labeling their trucks, and some cars as well, as flexible-fuel vehicles, meaning that they can run on either unleaded gasoline or E85. E85 is attractive at first glance because it sells for less than gasoline. GM apparently believes that this is a better long term solution than hybrids. I think they need to reconsider. I applaud their efforts to go in new directions and try new things, but I don’t believe that E85 is a viable solution to America’s rising energy costs, for a couple of reasons.

First, E85 contains less energy per unit of fuel than gasoline, so you’ll need to burn more of it to go the same distance than you would with gasoline. Put another way, if you burn E85 in your car, you won’t go as far as you would have with gasoline. If America were to switch to this fuel we’d need to produce more of it.

Second, it is made with corn, or the American E85 is anyway. This means that the corn that would have been used for food is now used to make fuel for our cars. How many acres of corn plants does it take to produce a gallon of E85? I don’t know, but even if it were a fraction of an acre, we consume hundreds of thousands of barrels of oil per day. Sure corn is replaceable, but this seems to me like a losing proposition.

Finally, this does nothing to improve the efficiency of our cars. Sure more affordable gas is attractive, but doesn’t it make sense that its easier to drive cars that require less fuel to begin with? Especially in the land of SUV’s?

Oh, and I did find out what Chrysler/Dodge is up to. They’re closing plants.

I’m not going to lie, the future for the big three automakers is not pretty. I don’t think its too late, but man, they have to wake up. Make smaller cars. Invest in fuel cells. Make hybrids and electric cars. Hire young engineers that are excited about contributing to the available solutions. Stop putting DVD players in headrests and embrace the thing that made you great to begin with, ingenuity. There are American companies that are doing this, so why can’t you?

Space Elevator

In one of my classes I was assigned the task of writing a feasibility study of an engineering project with a team of students. My team chose to write our document on the space elevator. It was really fun, this project is ambitious, but after reading and writing on this subject for the past six weeks, I believe that we could see something like this within the next 50 years.

I asked my team for permission to post our report here, they were gracious. I worked with Aaron Seitz, Amitesh Parikh, and Sean O’Brien. We were asked to write as if we were a company within the industry, so we chose SpaceX. Our report is below.

One note of clarification, all references to SpaceX are fictitious. I have no reason to believe that they are suffering any financial difficulty, or are in need of new ideas. It was part of the assignment to presume that we were writing this report for an executive engineer within an actual company.

Continue reading

Ham Radio

I’m now in the cool part of my degree plan where we get to start doing cool stuff with the knowledge that we’ve acquired. This semester I joined a team of students that are building a CubeSat satellite, it launches sometime next fall. I’m learning a lot and its totally fun to be working with satellites. My specific piece is the communications system. In order to be qualified to talk to the satellite once its in orbit, I had to get my amateur radio (ham) operator’s license. I took the first test last weekend and am now studying for the next exam. Just this morning I found out my call sign. I am now also known as KE5RMR.