Question: Write the python script using Gurobipy for the following objective function using set notation. The answer I am looking for is the entire script. The

 Write the python script using Gurobipy for the following objective function

Write the python script using Gurobipy for the following objective function using set notation. The answer I am looking for is the entire script. The model's report should follow the example below, so the print commands need to be written to match that. Minimize Z: x1 + x2 + x3 + x4 + x5 + x6 S.T. x6 + x1 >= 20 x1 + x2 >= 50 x2 + x3 >= 80 x3 + x4 >= 100 x4+x) >= 40 x5 + x6 >= 30 NOTE: The optimal solution was given and should equal a minimum number of officers equaling 180. Example of how the report should be printed: The minimum officers for the Police Scheduling: 180 Shift 1: officers starting = XX, total working = XXX, required = 20 Shift 2: officers starting = XX, total working = XXX, required = 50 Shift 3: officers starting = XX, total working = XXX, required = 80 Shift 4: officers starting = XX, total working = XXX, required = 100 Shift 5: officers starting = XX, total working = XXX, required = 40 Shift 6: officers starting = XX, total working = XXX, required = 30 Hint #1: The modulus operator is your friend for handling the case when starting in shift 6 also covers shift 1. Remember that Python uses zero indexing. Hint #2: Even though we use continuous variables that could have any real number value, since our demands are integer the optimal solution will be integer. There exist an infinite number of nonoptimal feasible solutions with decimal police officers, but optimal solutions will be implicitly integer. This is nice because problems using continuous variables solve faster than problems with integer variable restrictions. Decimal officers would be problematic. Hint #3: The getAttr() method on the model can get lots of useful information. For example, to get a list of all decision variable values after solving, you can do shiftStarts = m.getAttr("X", m.getVars() The arguments are 1) the optimal values of the 2) model variables. Hint #4: Very related to the previous hint, recall that the surplus =- slack. To get the total working each shift, look at the number required to meet each constraint, and the surplus of each constraint Write the python script using Gurobipy for the following objective function using set notation. The answer I am looking for is the entire script. The model's report should follow the example below, so the print commands need to be written to match that. Minimize Z: x1 + x2 + x3 + x4 + x5 + x6 S.T. x6 + x1 >= 20 x1 + x2 >= 50 x2 + x3 >= 80 x3 + x4 >= 100 x4+x) >= 40 x5 + x6 >= 30 NOTE: The optimal solution was given and should equal a minimum number of officers equaling 180. Example of how the report should be printed: The minimum officers for the Police Scheduling: 180 Shift 1: officers starting = XX, total working = XXX, required = 20 Shift 2: officers starting = XX, total working = XXX, required = 50 Shift 3: officers starting = XX, total working = XXX, required = 80 Shift 4: officers starting = XX, total working = XXX, required = 100 Shift 5: officers starting = XX, total working = XXX, required = 40 Shift 6: officers starting = XX, total working = XXX, required = 30 Hint #1: The modulus operator is your friend for handling the case when starting in shift 6 also covers shift 1. Remember that Python uses zero indexing. Hint #2: Even though we use continuous variables that could have any real number value, since our demands are integer the optimal solution will be integer. There exist an infinite number of nonoptimal feasible solutions with decimal police officers, but optimal solutions will be implicitly integer. This is nice because problems using continuous variables solve faster than problems with integer variable restrictions. Decimal officers would be problematic. Hint #3: The getAttr() method on the model can get lots of useful information. For example, to get a list of all decision variable values after solving, you can do shiftStarts = m.getAttr("X", m.getVars() The arguments are 1) the optimal values of the 2) model variables. Hint #4: Very related to the previous hint, recall that the surplus =- slack. To get the total working each shift, look at the number required to meet each constraint, and the surplus of each constraint

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!