0

我正在尝试编写如图所示的约束,但无法达到预期的结果。

在此处输入图像描述

结果将是,如果任务使用电力,那么二进制变量将为 1,它在另一个约束中将二进制变量x强制为 1。delta因此,任务必须使用电力,直到任务运行时结束。

这里 k 是任务开始的时间 o_{i,j} 是任务的总运行时间。

我试过这个:

    m.addConstrs((x[t, u, app, task]<= x[time_slots[t_index + each_task_time], u, app, task]+ 1 - delta[t, u , app, task]  
for t_index, t in enumerate(time_slots) 
for u in users for app in appliances 
for task in task_appliances[app] 
for each_task_time in range(int(task_time[app][task])+1)
if t_index < (len(time_slots)- task_time[app][task])), 
name = "task_end_electricity1")

task_time[app, task]设备 i 的任务 j 的运行时间在哪里。

二进制变量

x[t, u, app, task] : indicates whether task j of appliance i of user u at time slot k processed by electricity or not; 1 = processed, 0 = not processed

delta[t, u , app, task] : that takes value 1, if the task j of appliances i of user u starts running at time t. Or O if it doesn't start.

示例数据:

time_slots = ['k1', 'k2','k3', 'k4', 'k5']
users = ['u1', 'u2', 'u3', 'u4', 'u5']
appliances = ['washingmachine', 'dryer', 'dishwasher']
task_appliances = {'washingmachine':['movement', 'heating','washing'],
                   'dryer': ['drying1', 'drying2'], 
                   'dishwasher': ['movement', 'heating1', 'wash']}

task_time = {'washingmachine':{'movement': 1 , 'heating': 1, 'washing': 1}, 
             'dryer':{'drying1': 1, 'drying2': 1}, 
             'dishwasher': {'movement': 1, 'heating1': 1,'wash': 1}}

有人可以纠正我吗?

4

0 回答 0