Code: Select all
import pulp
print(pulp.listSolvers())
print(pulp.listSolvers(onlyAvailable=True))
< /code>
Die erste Druckanweisung enthält mir eine Liste von Löser, aber die zweite Anweisung gibt mir eine leere Liste. []
Code: Select all
from pulp import LpProblem, LpMinimize, LpVariable, LpConstraint, lpSum, value
# Define the problem
prob = LpProblem("Minimize_Operating_Cost", LpMinimize)
# Define decision variables
x1 = LpVariable("Hours_Facility_1", lowBound=0)
x2 = LpVariable("Hours_Facility_2", lowBound=0)
# Objective function: Minimize cost
prob += 120 * x1 + 220 * x2, "Total_Cost"
# Constraints
prob += 300 * x1 + 350 * x2 >= 4500, "Regular_Detergent_Constraint"
prob += 220 * x1 + 450 * x2 >= 5200, "Concentrate_Detergent_Constraint"
# Solve the problem
prob.solve()
# Extract results
x1_opt = value(x1)
x2_opt = value(x2)
min_cost = value(prob.objective)
#
# Display results
x1_opt, x2_opt, min_cost