def __init__(self, forElements, distributionTransportTime, distributionSafetyStock, elementList, moduleList, distributionsProvider, **additionalSettings): self.__forElements = forElements self.checkForRequirement("arc", moduleList) transportTime = generateJointly( forElements=forElements, distributionSettings=distributionTransportTime, elementList=elementList, distributionsProvider=distributionsProvider).rename( columns={"_value": "transportTime"}) safetyStock = generateJointly( forElements=forElements, distributionSettings=distributionSafetyStock, elementList=elementList, distributionsProvider=distributionsProvider).rename( columns={"_value": "safetyStock"}) arc = moduleList["arc"].getValues() transportValuesOnArcs = (transportTime.merge(safetyStock).merge(arc)) # only include rows that correspond to existing arcs filteredTransportValues = ( transportValuesOnArcs[transportValuesOnArcs.existing == 1].drop( columns=["existing"])) self.__values = filteredTransportValues
def __init__(self, forElements, distributions, elementList, moduleList, distributionsProvider, **additionalSettings): self.__forElements = forElements if not "demand" in moduleList: raise ValueError( "The module allocation requires a demand module initialized before" ) # shipping cost door to port dtp = generateJointly( forElements=forElements, distributionSettings=distributions, elementList=elementList, distributionsProvider=distributionsProvider).rename( columns={"_value": "shippingCost_dtp"}) # shipping cost port to door ptd = generateJointly( forElements=forElements, distributionSettings=distributions, elementList=elementList, distributionsProvider=distributionsProvider).rename( columns={"_value": "shippingCost_ptd"}) self.__values = pd.merge(dtp, ptd).assign(shippingCost=lambda df: df[ "shippingCost_dtp"] + df["shippingCost_ptd"])
def __init__(self, forElements, distributions, elementList, moduleList, distributionsProvider, **additionalSettings): self.__forElements = forElements self.checkForRequirement("demand", moduleList) self.checkForRequirement("arc", moduleList) allWeights = generateJointly( forElements=forElements, distributionSettings=distributions, elementList=elementList, distributionsProvider=distributionsProvider).rename( columns={"_value": "_weight"}) # Filter to only the existing arcs arc = moduleList["arc"].getValues() weightArcs = pd.merge(allWeights, arc) filteredWeights = weightArcs[weightArcs.existing == 1] demandElements = moduleList["demand"].forElements() weightSumsFiltered = (filteredWeights.groupby( demandElements, as_index=False).sum().rename(columns={ "_weight": "_weightSum" }).drop(columns=["existing"])) weightsAndSums = pd.merge(weightArcs, weightSumsFiltered) combined = pd.merge(weightsAndSums, moduleList["demand"].getValues()) self.__values = combined.assign( allocation=lambda df: df["existing"] * df["_weight"] / df[ "_weightSum"] * df["demand"]).drop( columns=['_weight', '_weightSum', 'demand', 'existing'])
def __init__(self, forElements, distributions, elementList, moduleList, distributionsProvider, **additionalSettings): self.__forElements = forElements self.checkForRequirement("demand", moduleList) self.checkForRequirement("allocation", moduleList) additionalCapacity = generateJointly( forElements=forElements, distributionSettings=distributions, elementList=elementList, distributionsProvider=distributionsProvider).rename( columns={"_value": "additionalCapacity"}) if not hasAllElements(moduleList["allocation"].forElements(), of=forElements): raise ValueError( "The allocation needs to have all keys that appear also in the capacity" ) allocation = moduleList["allocation"].getValues() # the capacity needed so that the allocation is just feasible minimalCapacity = allocation.groupby( forElements, as_index=False).sum().rename( columns={"allocation": "minimalCapacity"}) self.__values = pd.merge( minimalCapacity, additionalCapacity).assign(capacity=lambda df: df[ "minimalCapacity"] + df["additionalCapacity"]).drop( columns=["minimalCapacity", "additionalCapacity"])
def __init__(self, forElements, distributions, elementList, moduleList, distributionsProvider, **additionalSettings): self.__forElements = forElements self.__values = generateJointly( forElements=forElements, distributionSettings=distributions, elementList=elementList, distributionsProvider=distributionsProvider)
def __init__(self, fromElements, toElements, distributions, elementList, moduleList, distributionsProvider, **additionalSettings): self.__forElements = fromElements + toElements toElementsCombinations = createDataFrameWithKeys( toElements, elementList ) # Make sure that the solution is feasible # by having at least one arc # for every combination of the *toElements* skeletonArcs = toElementsCombinations.assign(**{ element: [choice(elementList[element].members()) for _ in range(len(toElementsCombinations))] for element in fromElements }).assign( existing = 1 ) forElements = fromElements + toElements if distributions == "default": # At default, choose all arcs to be existing indicators = ( createDataFrameWithKeys(forElements, elementList) .assign(existing = 1) ) else: indicators = generateJointly( forElements = forElements, distributionSettings = distributions, elementList = elementList, distributionsProvider = distributionsProvider ).rename(columns = {"_value": "existing"}) # set an arc to existing status # if it is existing in the skeleton arcs or # the random indicators arcs = pd.concat( [ skeletonArcs, indicators ], sort = True ).groupby( forElements, as_index = False ).max() self.__values = arcs