Everyone, welcome back. Today, we're going to learn about integer programming. This is another type of linear programming where now our decision variables all have to be integers. As a friendly reminder what is an integer? Integer is like a whole number 1, 2, 3, 4. We're not allowed to have 1.5, 1.6, 1.7. So we only want whole number solutions inside of our linear programming problem. It turns out that this restriction is not as easy as it might seem. Solver will take care of all the math on the back end. But one thing that you the human should not do is run solver without adjusting for it for energy programming, and I'll show you how to do that. And I'll show you sort of the common pitfalls that can happen. But just remember as we talk about integer programming this is all fancy names for LP which is linear programming. And then we have our transportation and we have our assignment and now we're sort of working with integer programming. So all of this falls under the umbrella of linear programming. Since it is a linear programming problem, read the problem positive video about Liz Bailey and the owner of Princess Brides. And let's see if we can go through and solve it and it's going to feel very similar to something we've done prior. I just want to introduce this new concept of integers as our decision variable. So if you want pause the video and get this started as we go, okay, ready? Liz Bailey is the owner of Princess Brides. She uses radio to market and two types of ads are available. Those during prime time and those during other times. So peak and off peak, let's create our little spreadsheet here. We will give it a header and we're going to introduce our variables. So this should feel like our old template. We have two types of ads to buy. We have peak or prime time and we have off peak. So let's label them accordingly. And as always we will label our decision variables green. Let's center to make things look pretty. Each prime time ad costs $390. So that's going to be a cost to it. Cost usually go under constraints. So maybe we'll put our constraints with our budget and let's line these up. Remember you have to line these up with the corresponding column. So each prime time or peak ad costs $390. We'll throw that in there. And reaches 8200 people. Now we want to, if you read the problem a little bit, we want to maximize the number of people reached. So that's going to be part of our objective, more people the better. So we put 8,200. Usually we put Coefficients of the objective function here and sometimes we put dummy variables in the green cells. So I'm going to go a little quickly through this one because we've done this one before. Off peak ads, so this is our column C now, they cost $240. So we'll put the cost under our budget. They reach 5,100 people. 5,100 on average. Now here's the budget. So remember how this works on our constraint table. We always go three past where the decision variables end. So I have two decision variables. It ends in column C. So I'm going to go 1, 2, 3 past. Maybe I have more constraints to come, let's see. So we had them on, we put our LHS for left hand side, we put the sign and then we do right hand side. As a reminder, the sign and right hand side. These are numbers, these are not formulas. Budget, you want to be less than or equal. You want to be under budget, you want to be over budget. And our budget is $1800. You can format this to money if you want. You can leave it as is since it is a budget that's implied, that's all fine. Well center everything. The left hand side is a formula. This is going to be the sum product of the decision variables. How many of each ad you buy comma, and then the cost for them. Understand this formula, I buy one peak ad is costing $390 and multiplying together. If I buy two off peak ads, it's two times 240, I multiply them together. My total cost then adds them up. So beautiful some product to get me my 870. So this is actually okay if I buy one and two. But now I need to keep track of how many people that I reach. So let's put our objective, what is the point? What are we trying to do? The number of people reached, and our objective here is a max. We will label the cell as people reached and then we will color coded gray. And how many people do I reach? If I have one peak add that reaches 8200 people. Well, once again I multiply it together and then I add up the number of people reached by the peak ads and then the number of people reached by the off peak ads. So let me put some formula texts in here. What's going on, and remember the left hand side formula text. I can show that as well, a nice use of the sum product formula. Now we have some other constraints that we just need to manage, that's fine. She wants at least two prime time ads, at least to prime time ads. So the prime time ads have to be at least two. We've seen this before, remember what that means? It's got to be greater than or equal to two. We also want no more than six off peak ads. So off peak ads have to be less than or equal to six. Alright, we can do that, that's fine. So let's put that in. No more than six off peak, at least two peak. How does it work? Remember in the constraint table, you never put variables. These are all numbers in here. But what numbers go inside of these tables they are the coefficients. When you write out the algebraic inequality, they are the coefficients that occur on these variables. So when there's nothing here remember it's like an invisible one. So it's like one times the number of peak variables or one times the number of off peak variables. So the coefficient always goes inside the box. So no more than six that behave the number of off peak should be less than or equal to six, that's fine. And at least two peak, one peak should be greater than or equal to. To constraint table is going to look something like this. I'm going to leave the other cells blank. Remember blanks are treated as zero and then I'm going to put dollar signs on my left hand side formula. This lets me just drag it down so I don't have to keep typing it every single time. All right, so then we check, do we have all the constraints matched? So let's go over to solver and see what we find. So data solver. We said our objective, that's the gray cell as always we want to maximize the number of people reached and the variable sales are the green cells. Subject to the constraints. Here we go, so let's add them in there. I have left hand side. I have two less than or equals together, so I'll batch upload those less than or equal to and then I'll do the right hand side. So I have the two budget and no more than six off peak adds constraint. And we have to add one more. I want the left hand side to be greater than or equal to the right hand side for the constraint that at least two peak adds are purchased and I hit okay. I select simplex LP for linear programming, this is still all a linear programming problem and I hit Solve. Solver found a solution, all constraints and optimal conditions are satisfied. Thank you so much solver, we hit Okay. So let's start doing this here. Let's just write this down summary sentence, say the following. We're going to recommend, we can solve this we're getting paid lots and lots of money for our work. Two peak ads and 4.25 off peak ads. And hopefully as you write this, something feels wrong. How do you buy 4.25 off peak ads? I only want to say every fourth word. That doesn't work, so this is the problem this is the problem right here. One of the constraints that's implied by the problem. Sometimes they're clear about it sometimes you have to sort of infer it is that you can only purchase a whole number Radio ad. You can't buy .25 or radio ads. So this is the problem. And what's interesting about this. Notice, if you did this, you're going to reach the most people. The reach here will be 38,075 people. But here's the warning to you. This is what I see a lot of students do. Warning, warning, warning, this should not be you. A lot of students say well I'll just round it. Do not round your answer, that is not how this works. The math behind this is a little complicated, little tricky. Again, it still takes care of it all for you but do not round your answer. Just to show you why not? If you have two peak ads and let's say you round it four off peak, what would the reach be? Let's find out. So let's just round this to four for a minute. And that would reach 36,800 people. So that is sort of the wrong way to do it. That's a common mistake. What you need to do is tell solver that these things can only be integers and that's the new skill for this. Everything so far should feel very similar. The only thing to do is add integer constraints to solver. This is the correct way. Let's go back to solver for a minute. If I hit add this is a constraint, the variables have to be a certain thing, this is a constraint. Go back to your variables, your decision variables. And in the dropdown menu you know the first three. Less than equal two equal greater than equal two. The fourth one is integer, INT. This says I need these numbers to be integers. When you select integer in the middle dropdown it automatically populates the right dropdown to integer. So hit Okay. And you'll see that now appear in the constraint. One thing you should check is under this options bar there is a checkbox back here that says ignore integer constraints. Sometimes this is checked if you're putting on the integer constraint and nothing's changing. You might have this checked by accident where you're just ignoring that. The reason for that is the algorithm that solver runs is more complicated it takes more memory, it takes more time. If you don't have the problem set up just right everything we do in this class will be perfectly fine. But if you're just making up numbers and you put on integer constraints you can really bog down your computer and freeze it if you're not careful. So this is sort of like a safety, but for everything we do all the numbers are fine. So go back to the problem here, okay? Make sure you have this new integer constraint on your variables and you could solve. Solver found a solution, all constraints are satisfied. So we hit OK. Look at the answer that salver came back with. Solver came back with the correct answer which is buy four peak ads one off peak ad to reach a maximum of 37,900 people. So you can imagine if your consultant firm ran solver and then recommended to peak ads, four off peak ads you would your solution reaches 36,800 people. The correct answer, so do not round it, the key here is do not round it. The correct answer, when you put in the integer constraint solver is two by four peak ads, one off peak ads and you reach 37,900 people. It's almost 1000 people more than the other rounded answer. So this is a big warning watch out this will be of course in any quiz the wrong answer choice that will be there tempting you to pick. But add the integer constraint, do not round if you just run the regular lP problem. Alright, so go over this example, make sure you can add the integer constraints. And now going forward look for integer constraints, do you need the variables to be imagers? That's a question you have to ask yourself as you go through and try these problems. All right, great job on this example. We'll see you next time