Hello, everyone. I'm Jenny Tzeng. This video will introduce how to get shadow price with Gurobi and Python. So first, it's our role map. First, we will reveal the shadow price idea we introduced before, and we have two incidents for today's video to get shade of prices. And in previous video, we introduced the idea of shadow prices, which is the amount of objective values increase when we add one unit on the right hand side of light constraints. In this video, we use two incidents to talk about how to get the shadow price for each constraint with gurobipy. We also want to compare the shade of highs is in the original setting and, adjusted objective value if the right hand side of the constraint is added by 1. So let's construct our first incidents producing decks and tables. Consider the problem we have introduced before we have to do is even variable. The first one is the decks we produced, and the second is the tables we produced and we have the formulation as below. The first line is our objective function, and it is to maximize our total profit and we have three constraint and the first one is about the good limitation and the second one is a labor resource. The last one is the machine limitation, and we have the sign constraint for this problem. When we construct model, we use gurobipy and get shadow price from a constraint attribute in Gurobi optimizer Pi and let's construct a model and 21st. So before we construct this model, we should import out the package we need. Learn the called we construct the model just like we have done before. And there is a little different is that we put our code about the data part and model part into a function which is linear example and the input is limitation list. So in the function we have the data part, which is to prepare our data for the model. And we construct our model, Model LP example to each one and first we should add our variable. This is a linear programs, so our variable type is continuous. Then we said our objective value the next we add our constraint then optimize list model and this function will have the output is our model. This will make we can get shadow price for free. So we construct this model and then we have the limitation list. This is just like we have formulate and our origin model will apply linear example function and input is our limitation list. Then we have our shadow price for each constraint which we use the the attributes of the model pi. So let's strongly say, so we can get the result from the optimizer and we can see our optimum value is here and our objective value is this amount. And we also get our shadow price for each constraint in good labor and machine. And the shade of crisis is like this. We want to have a test to compare if the shadow price is some the objective value increase. So we use a for loop to compare if the adjusted objective value increase is some of our shadow price. So first we bring out our shadow price from our original model. Then we bring the original objective value. Then we start to addressed our limitations. Each iteration, we will add one unit on one constraint right hand side and then we construct the model with new constraint, that is, we put our new limitation list in the new model and we will print the objective value out to be compared. So let's strongly self, so we can get our result in first concern. We can see our we have the shadow price in this amount and original objective value like this. Then if we add one unit on the first constraint, we have this objective value in this amount. And if we to compare the adjusted objective value with the original one, we can see that gap is equal to the shadow price. So we have this result. Let's go back to slide to see how to interpreted. So after building a new model with gurobipy, we have an optimal solution like this, and our objective value is this and we also get our shadow of price of the three constant below tables, for example, for good constraint. Our shadow of price is less amount, and our objective value is is indeed increase the amount of shadow price and in our second constraint, we have the shade of price is zero by complementary slackness. The non binding constraint at the optimal solution implies let the shadow price equals to zero in fiscally lets me at the optimal solution. The labor resource is not exhausted, so if we add one unit on the labor resource, the objective value will be not have any improvement. And in lakes example, the shadow of price of each constraint is equal to the amount of objective value increase. When we add one unit on lead constraint. Then let's start our second incident personnel scattering. Consider the personal scheduling problem we also have introduced before. We lead exciting the number of people who work for five consecutive days starting from day I and we have the formulation as below. And the first line is our objective function, which is to minimize the total employee we hired. And we have seven constants and the first constant. It means that on Monday we should have 110 employees to be on duty. So we add up the workers who could work from Monday, Thursday, Friday, Saturday and Sunday, and in the second constraint, it means that on Tuesday we need 80 employees to be on duty. So we add up the worker work from Monday, Tuesday, Friday, Saturday and Sunday and so on and the last line is our sign constraint. So we have the formulation. Let's construct this model on Python. So for all this problem, first we improve the package. We need us before and we have an Excel file, which includes our constraint limitation. So we read this Excel as personnel constraint in this Excel file. We have a table about the seven days people's limitation for all this problem. Then we also construct function for these incidents its name as personnel scheduling example and our input is the constraint. And we also have the data in the middle part. The in the data part, we prepare our data on this even variable and our resource limitations. And in the model part, we have a model personnel scattering to eg2 and we add our variables because it is also an linear programs. So the variable type is also continuous and we said objective value, which is minimized the total employee we hired. And then we add constraint to add the seven constraint in one line. We use this particularly so and finally we optimize our model, then print out our solution. This function returns is our model. So then we construct our original model with our original limitation setting. So we run this cell, And we can get our result so we can see that this is our optimal solution. And this is our objective value. And we also want to note if the shadow of price for each constraint is the same as its definition, that is, the amount of just objective value increased. So we also use a for loop to do this test. First we print out our shadow of price of each constraint, and then we print out our original objective value. Then we start to adjust our resource limitation for each constraint. But finally we print out the the adjusted objective value. So we run this for loop and we can get our result for first constraint. It's trading price is one third and the original objective value is less amount. And if we add one unit on first constant right hand side, we can get our objective value increased to this amount, and the amount increasing is exactly the shadow of price. And to the second constraint, it's Trader price is 0, so we can expect it that our objective value increase will be 0. So our original objective value is this amount and adjusted objective value is the same as our original one. So we have this result. Let's go back to slide 2 interpret it. So after building a new model with gurobipy, we have optimal solution just like this. And our objective value is this amount. And if we compare this solution with that one we obtained with Excel solver, we can find there are a little different. That's because this problem has multiple optimal solution and we can get the shadow price for each constraint and the right hand side and amount at optimal solution. So if we look at the first role is the first constraint, we have the shadow price is 1 third and its right hand side is 110, and the optimal solution on Monday there are 110 workers could be on duty, so this constraint is binding. If we add one resource on the right hand side of this constraint, the objective value will increase one third just as the shadow price. And if we look at the second roll of this table, which is the second question for Tuesday. Its right hand side is 80 and it's shadow price is 0 and we look at the optimal solution. On Tuesday, there are 136 and two third people could be on duty, so this amount is far from the right hand side. If we add one unit on this constraint, the the objective value will be not have any improvement. So that's all for the two incidents. There are some remarks to remind the two incidents are indeed the typical ones. So the shadow price is the same of the amount of objective value increase. From previous video we mentioned that the shadow price would be sand as the amount of objective value increased when we add the right hand side of the constrained by one. Assuming the current optimal basis remains the sound. However, shade of heights are still useful when we need to evaluate resource adjustment or answer hard questions. That's all for today's video. Thank you.