我试图写出如图所示的约束,但是无法达到预期的结果。
如果任务用电,则结果为
x
二进制 变量将为1,在另一个变量中将delta
二进制变量强加为1 约束。所以任务必须用电直到结束 任务运行时。这里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}}
有人可以纠正我吗?