Skip to content

Instantly share code, notes, and snippets.

@pabloazurduy
Created April 26, 2020 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pabloazurduy/10f599cf56c0287430981fb9798cc231 to your computer and use it in GitHub Desktop.
Save pabloazurduy/10f599cf56c0287430981fb9798cc231 to your computer and use it in GitHub Desktop.
a snippet that shows the implementation of the qp appx
from helpers.mip import get_quadratic_appx
# get a new variable that represents u^2 = qa_u
qa_u = {}
for i in stores:
for t in days:
qa_u[(i,t)] = get_quadratic_appx(model = mdl,
var = u[(i,t)],
id_name = 'qpu_{}_{}'.format(i,t),
min_interval = 0, # lower value where we estimate that u will be moving
max_interval = 100, # higher value where we estimate that u will be moving
num_linspace = 5 # number of points of discretization or interest
)
mdl.objective = mip.xsum(qa_u[(i,t)] for i in stores for t in days)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment