Я создал решение, используя библиотеку Python Gurobi для решения для исследования операций, но моя модель остается пустоPython

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Я создал решение, используя библиотеку Python Gurobi для решения для исследования операций, но моя модель остается пусто

Сообщение 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)

Подробнее здесь: https://stackoverflow.com/questions/791 ... ch-solutio
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»