Sensitivity Analysis of a Multi-objective Optimization Model
Photo by Markus Spiske on Unsplash

Sensitivity Analysis of a Multi-objective Optimization Model

We have developed a multi-objective optimization model using goal programming with Gurobi in Python in the previous article. Next step is sensitivity analysis.

It is important to check how "sensitive" the model is to changes in inputs

The change can be objective function coefficients (such as cost to reach a customer) or right hand side (RHS) values of constraints. In this article, we will simulate how the change in RHS value -- budget affect the objective value -- profit. Recall our budget constraint as:

the total budget constraint

Gurobi provides multiple scenarios function, but unfortunately does not support multi-objective model (as of version 9.0). Instead, we can write a Python function to change RHS values. The code is pretty self-explanatory.

def change_rhs(constraint_name, value):
    # Get the original values
    constraint = m.getConstrByName(constraint_name)
    lhs = m.getRow(constraint)
    sense = constraint.Sense
    rhs = value

    # Replace the constraint
    m.remove(constraint)
    m.addConstr(lhs, sense, rhs, name)

Next, we create a for loop to solve a total of 40 times, from budget +- $1000 at a step of 50. RHS value and the objective value (profit) are appended to two lists for further analysis.

# Sensitivity analysis of the RHS values
rhs_list = []
result_list = []


for n in range(budget-1000, budget+1001, 50):
    rhs_list.append(n)
    change_rhs('budget constraint', n)

    # Solve
    m.update()
    m.optimize()

    # Calculate the objective value
    if m.status == GRB.OPTIMAL:
        decision = m.getAttr('x')
        result = (df['CustomerCount'] * df['ExpectedRevenue'] \
                  * df['Probability']) @ decision
        result_list.append(result)
    else:
        result_list.append(0)

By plotting the profit against marketing budget, we can visualize easily the diminishing return by fitting a polynomial curve. This gives more supporting data for making decisions about budget change (hopefully not reduction).

No alt text provided for this image


Great article, very helpful!

Like
Reply

To view or add a comment, sign in

More articles by Corvus L.

Explore content categories