`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
Программы на Python
1730872525
Anonymous
`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)
Подробнее здесь: [url]https://stackoverflow.com/questions/79161459/i-created-a-solution-using-python-gurobi-library-for-operations-research-solutio[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия