Skip to content

Do Google OR tools support sensitivity analysis? #3595

Closed Answered by asmaier
asmaier asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you for your hints. It seems slack can be calculated by subtracting the activities from the upper bound of the constraint. With that I managed to convert the example from https://machinelearninggeek.com/sensitivity-analysis-in-python/ written in Python PuLP into Google OR Tools:

import pandas as pd
from ortools.linear_solver import pywraplp
from ortools.init import pywrapinit

solver = pywraplp.Solver.CreateSolver('GLOP')
A = solver.NumVar(0.0, solver.infinity(), "A")
B = solver.NumVar(0.0, solver.infinity(), "B")
solver.Add(4 * A + 10 * B <= 100, "c0")
solver.Add(2 * A + 1 * B <= 22, "c1")
solver.Add(3 * A + 3 * B <= 39, "c2")

solver.Maximize(60 * A + 50 * B )

status = solver.Solve

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@Regista6
Comment options

@asmaier
Comment options

Answer selected by asmaier
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants