class PartPeriod:
def __init__(self):
pass
def run(self, dict_in, demand):
# Füllen der Variablen aus Start_Dictionary
dem = demand
kf = dict_in["fixedCost"]
kv = dict_in["varCost"]
pp = len(dem)
p = 0 # aktuelle Periode
i = 0
orders = [0 for i in range(pp)]
orders1 = [0 for i in range(pp)]
# Hilfsvariablen Kosten summieren
cost = 0
cost_i = 0
cost_v = 0
# testen ob "Null-Perioden am Anfang vorliegen
while dem[p] == 0:
orders1[p] = 0
p = p + 1
if p == pp:
p = p - 1
break
i = p
while p < pp: # solange wie aktuelle Periode kleiner Anzahl PlanungsPerioden
cost = cost + demand[p] * kv * (p - i) # Formel Stückausgleichkostenverfahren
if cost < kf:
orders[p] += demand[p]
lot = sum(orders) - sum(orders1)
cost_v = cost
else:
cost_i = cost_v + cost_i
orders1[i] = lot
i = p
p = p - 1
cost = 0
cost_v = 0
p = p + 1
orders1[i] = lot
x = orders1.count(0)
fix = (pp - x) * kf
# print(cost_i)
# print(fix)
cost_i + fix + cost_v
# print("total cost: " + str(total_c))
# print(x)
# print(sum(orders1))
return np.array(orders1)