Question: Instructions for Sensitivity Analysis Using gurobipy 1 ) Formulate and Implement the Linear Program in Gurobi and respond to question by solving and responding to
Instructions for Sensitivity Analysis Using gurobipy
Formulate and Implement the Linear Program in Gurobi and respond to question
by solving and responding to all questions
Before answering any of the questions, we need to set up the LP model in Gurobi. Here's how you can set up your model:
Install Gurobi on Google Colab if you have not:
pip install gurobipy
Create a Python script that sets up the decision variables, objective function, and constraints for your problem following the model we did in class:
import gurobipy as gp
from gurobipy import GRB
# Create a new model
model gpModelfurnituremanufacturing"
Access Sensitivity Information and Shadow Prices
In this step, you will gather information on how sensitive the objective coefficients revenue from tables and constraints machine availability are to changes. You will also calculate the shadow prices for the constraints. Gurobi provides attributes SAObjUp SAObjLow SARHSUp SARHSLow and Pi that can help in determining how the solution changes when these values are modified.
Instruction:
Use the following code to access and print both the sensitivity information and shadow prices for each variable and constraint:
# Access and print sensitivity information for objective coefficients
print
Sensitivity Information for Objective Coefficients
for v in model.getVars:
printfVariable: vvarName
printf SAObjUp Upper Sensitivity: vSAObjUp
printf SAObjLow Lower Sensitivity: vSAObjLow
# Access and print sensitivity information for RHS values
print
Sensitivity Information for RightHand Side RHS Values
for c in model.getConstrs:
printfConstraint: cConstrName
printf SARHSUp RHS Upper Sensitivity: cSARHSUp
printf SARHSLow RHS Lower Sensitivity: cSARHSLow
# Access and print shadow prices dual values
print
Shadow Prices Dual Values for Constraints
for c in model.getConstrs:
printfConstraint: cConstrName
printf Shadow Price Dual Value: cPi
Interpretation:
SAObjUp and SAObjLow indicate how much the objective coefficients eg selling price per
table can increase or decrease before the optimal solution changes.
SARHSUp and SARHSLow indicate how much the righthand side of a constraint eg machine time availability can increase or decrease before the optimal solution changes.
The shadow price Pi provides the rate at which the objective function eg profit increases or decreases with a oneunit increase in the RHS of a constraint.
Use Sensitivity Data for Specific Questions
Now that you have the model optimized and the sensitivity analysis data, you can address specific questions. Follow the instructions below to extract relevant sensitivity information from Gurobi.
Instruction: For each question, refer to the relevant sensitivity or shadow price information gathered in Step :
a If the company could get more units of routing capacity, should they do it How much should they be willing to pay for it
Guidance:
Look at the SARHSUp value for the Router constraint.
If more units of routing capacity are within the SARHSUp range, the solution will not change, and the shadow price Pi for the Router constraint will tell you how much the company should be willing to pay per additional unit of routing capacity.
b If the company could get more units of sanding capacity, should they do it How much should they be willing to pay for it
Guidance:
Look at the SARHSUp value for the Sander constraint.
If the additional units are within the SARHSUp range, the shadow price Pi for the Sander constraint will indicate how much the company should be willing to pay per unit of sanding capacity.
c If the polishing time for country tables could be reduced from to minutes, how much should the company be willing to pay for this improvement?
Guidance:
Check the SAObjUp and SAObjLow values for CountryTables If the reduction in time leads to an increase in production, the company should consider the potential increase in profit. Use the sensitivity information to gauge how much this improvement is worth.
d If contemporary tables sell for $ by how much would the selling price have to decrease before we no longer produce contemporary tables?
Guidance:
Look at the SAObjLow value for ContemporaryTables This will tell you the amount by which the selling price can decrease before contemporary tables are no longer produced in the optimal solution.
Sensitivity Analysis with Gurobi in Google Colab for Advertising Problem
Set Up Google Colab for Gurobi
Before running the model, ensure that you have Gurobi installed on Google Colab.
pip install gurobipy
Define the Problem: Advertising Allocation
Implement the Linear Program in Gurobi
Create a Python script that sets up the decision variables, objective func
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
