This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import mip | |
def get_quadratic_appx(model , | |
var, | |
id_name = None, | |
min_interval = 0, | |
max_interval = 100, | |
num_linspace = 100, | |
M = 1e7 ): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the LP model | |
import mip | |
mdl = mip.Model(sense=mip.MINIMIZE, solver_name=mip.CBC) | |
# sets | |
days = list(range(len(demand[1]))) | |
stores = list(demand_parameters.keys()) | |
# variables |