Skip to content

Instantly share code, notes, and snippets.

@pcyu16
Last active January 6, 2025 16:41
Show Gist options
  • Select an option

  • Save pcyu16/fc86b4993bb442ff4edffbd5fe1bb846 to your computer and use it in GitHub Desktop.

Select an option

Save pcyu16/fc86b4993bb442ff4edffbd5fe1bb846 to your computer and use it in GitHub Desktop.
# Define the total production capacity function
def calculate_total_production(a, b, c, ex, ez):
# Calculate X, Y, Z
work_speed = 155 # 75+50+30
work_speed_nocturnal = 175 # 75+50+30+20
X = work_speed * 10 * a + work_speed_nocturnal * 5 * ex + work_speed * 3
Y = work_speed * 10 * b
Z = work_speed_nocturnal * (10 * c + 3 * ez)
p = min (X,Y,Z) / Z # product quantity reduction
# Calculate base product quantity
base_product_quantity = p * ( 3 * 10 * c + 2 * 3 * (ex + ez)) / 30 * (100 + 35 * (ex+ez)) / 100
# Total production capacity
total_capacity = min(X, Y, Z) / work_speed * base_product_quantity
return total_capacity
# Initialize results for the revised problem
revised_results = []
# Iterate through n from 4 to 50
for n in range(4, 51):
max_capacity = -999
best_solution = None
# Iterate through all possible values of a, b, c, ex, ez
for a in range(n):
for b in range(n):
for c in range(n):
for ex in range(n):
ez = n - a - b - c - ex - 1
if ez >= 0 and min (b, c + ez) != 0: # Ensure all variables are non-negative integers and has profits
total_capacity = calculate_total_production(a, b, c, ex, ez)
if total_capacity > max_capacity:
max_capacity = total_capacity
best_solution = (a, b, c, ex, ez)
# Store the best solution for this n
if best_solution:
revised_results.append((n, best_solution, max_capacity, max_capacity / n))
print(revised_results)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment