def createTimeIndexedVariable(self, name, v_type, coefficient=0.0, interval=1, lb=0.0, ub=1000000): numVars = 0 for i in range(self.currentDay, self.finalDay, interval): v = Variable() v.name = name + str(i) v.col = self.numCols v.instant = i v.type = v_type self.variables[v.name] = v self.lp.variables.add(obj=[coefficient], lb=[lb], ub=[ub], names=[v.name]) self.numCols += 1 numVars += 1 return numVars
def createRepositionVariable(self): numVars = 0 repositionDays = [rDay for rDay in self.pData.repositionDays if rDay >= self.currentDay and rDay < self.finalDay] for i in repositionDays: v = Variable() v.name = "r" + str(i) v.col = self.numCols v.instant = i v.type = Variable.v_reposition self.variables[v.name] = v self.lp.variables.add(obj=[-params.unitCost], names=[v.name]) self.numCols += 1 numVars += 1 return numVars
def createDemandVariable(self): numVars = 0 t0 = self.currentDay for t in range(self.currentDay, self.finalDay): v = Variable() v.name = "d" + str(t) v.col = self.numCols v.instant = t v.type = Variable.v_demand demand = self.pData.getForecast(t0, t) self.variables[v.name] = v self.lp.variables.add(obj=[params.unitPrice], lb=[demand], ub=[demand], names=[v.name]) self.numCols += 1 numVars += 1 return numVars
def createStockVariable(self): numVars = 0 # the s variables are for each scenario and for each t of current horizon for scenario in self.scenarios: for t in range(self.currentDay, self.finalDay): # create the variable v = Variable() v.type = Variable.v_stock v.name = "s_" + scenario.id + "_" + str(t) v.col = self.numCols v.instant = t v.scenario = scenario.id self.variables[v.name] = v self.lp.variables.add(names=[v.name]) self.numCols += 1 numVars += 1 return numVars
def createRepositionVariable(self): numVars = 0 repositionDays = [rDay for rDay in self.pData.repositionDays if rDay >= self.currentDay and rDay < self.finalDay] # get the maximum forecast for using it as upper bound for r variable maxDemand = max(s.maxForecast for s in self.scenarios) # The reposition variable remains only for each t in the current planning horizon for i in repositionDays: v = Variable() v.type = Variable.v_reposition v.name = "r_" + str(i) v.col = self.numCols v.instant = i self.variables[v.name] = v self.lp.variables.add(names=[v.name]) self.numCols += 1 numVars += 1 return numVars
def createRepositionVariable(self): numVars = 0 repositionDays = [ rDay for rDay in self.pData.repositionDays if rDay >= self.currentDay and rDay < self.finalDay ] # get the maximum forecast for using it as upper bound for r variable maxDemand = max(s.maxForecast for s in self.scenarios) # The reposition variable remains only for each t in the current planning horizon for i in repositionDays: v = Variable() v.type = Variable.v_reposition v.name = "r_" + str(i) v.col = self.numCols v.instant = i self.variables[v.name] = v self.lp.variables.add(names=[v.name]) self.numCols += 1 numVars += 1 return numVars