Ich folgte eine tutorial von Python PLUP, aber ein anderes Ergebnis. StattUnerwartetes Ergebnis mit Python PLUP
Optimal weekly number of soldiers to produce: 20
Optimal weekly number of trains to produce: 60
Ich habe:
Optimal weekly number of soldiers to produce: 0
Optimal weekly number of trains to produce: 0
aber die Reste gleich sind ... Wenn Sie wissen wollen, dass; s der Code (fast Kopieren und Einfügen):
prob = pulp.LpProblem('Giapetto', pulp.LpMinimize)
soldiers = pulp.LpVariable('soldiers', lowBound=0, cat='Integer')
trains = pulp.LpVariable('trains', lowBound=0, cat='Integer')
raw_material_costs = 10 * soldiers + 9 * trains
variable_costs = 14 * soldiers + 10 * trains
revenues = 27 * soldiers + 21 * trains
profit = revenues - (raw_material_costs + variable_costs)
prob += profit
carpentry_hours = soldiers + trains
prob += (carpentry_hours <= 80)
finishing_hours = 2*soldiers + trains
prob += (finishing_hours <= 100)
prob += (soldiers <= 40)
print(prob)
optimization_result = prob.solve()
assert optimization_result == pulp.LpStatusOptimal
for var in (soldiers, trains):
print('Optimal weekly number of {} to produce: {:1.0f}'.format(var.name, var.value()))
Irgendwas falsch?
Sieht für mich wie Sie es gesagt, um den Gewinn zu minimieren, und es hat erfolgreich den Gewinn minimiert. – user2357112