`import gurobi`py as gp
from gurobipy import GRB
import pandas as pd
# Load data from Excel
excel_path = r"C:\Users\cansu\OneDrive\Desktop/YON.xlsx"
personnel_df = pd.read_excel(excel_path, sheet_name="Personnel Set")
machine_df = pd.read_excel(excel_path, sheet_name="Machine Set")
operation_df = pd.read_excel(excel_path, sheet_name="Operation Set")
performance_df = pd.read_excel(excel_path, sheet_name="Performance Set")
time_df = pd.read_excel(excel_path, sheet_name="Time Set")
difficulty_df = pd.read_excel(excel_path, sheet_name="Difficulty Set")
# Sets and parameters
P = list(personnel_df['Personnel'])
M = list(machine_df['Machine'])
O = list(operation_df['Operation'])
# Cycle time limit (13.1 minutes for each operation)
Ck = 13.1
# Personnel working time (430 minutes per day)
Ai = {p: 430 for p in P}
# Operation difficulty level
Difficulty = {row['Operation_ID']: row['Difficulty Level'] for _, row in difficulty_df.iterrows()}
#Define competent personnel with performance above the threshold
performance_threshold = 3
Eij = {}
#Create Eij matrix (updated with difficulty level)
for _, row in performance_df.iterrows():
personnel = row['Personnel']
for operation in range(1, 29): # Operations from 1 to 28
performance = row[operation]
if performance > performance_threshold and performance >= Difficulty[operation]: #Consider difficulty level
Eij[(personnel, operation)] = 1 # Competent
else:
Eij[(personnel, operation)] = 0 # Not competent
#Display Eij competency matrix
print("Eij Competency Matrix (updated with difficulty):", Eij)
# Create Sj matrix: Retrieve personnel and operation times
Sj = {}
# Retrieve time data from time_df table
for _, row in time_df.iterrows():
personnel = row['Personnel']
for operation in range(1, 29): # Columns for operations from 1 to 28
time = row[operation] # Get the time for this operation
Sj[(personnel, operation)] = time
# Add default time value of 0 for missing data
for i in P:
for j in O:
if (i, j) not in Sj:
Sj[(i, j)] = 0
# Display Sj time matrix
print("Sj Time Matrix:", Sj)
# Operation priority order
OT = {row['Operation']: row['Priority'] for index, row in operation_df.iterrows()}
# Create model
model = gp.Model("Line_Balancing")
print(model)
# Decision variable: Xijk, does personnel i perform operation j on machine k
Xijk = model.addVars(P, O, M, vtype=GRB.BINARY, name="Xijk")
# Objective function: Minimize cycle time
model.setObjective(gp.quicksum(Xijk[i, j, k] * Sj[i, j] for i in P for j in O for k in M), GRB.MINIMIZE)
# Constraints
# Constraint 1: Each personnel works up to 430 minutes per day
for i in P:
model.addConstr(gp.quicksum(Xijk[i, j, k] * Sj[i, j] for j in O for k in M)
Подробнее здесь: https://stackoverflow.com/questions/791 ... ch-solutio
Я создал решение, используя библиотеку Python Gurobi для решения для исследования операций, но моя модель остается пусто ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Java – установите флажок «Не пусто/пусто», иначе присвойте значение по умолчанию
Anonymous » » в форуме JAVA - 0 Ответы
- 45 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Java – установите флажок «Не пусто/пусто», иначе присвойте значение по умолчанию
Anonymous » » в форуме JAVA - 0 Ответы
- 26 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Я хочу создать страницу исследования, например Instagram, используя хранилище Firebase.
Anonymous » » в форуме Android - 0 Ответы
- 17 Просмотры
-
Последнее сообщение Anonymous
-