如何在CP的Cplex中正确表达逻辑含义

问题描述 投票:0回答:1

我是 CPLEX 新手,我正在使用 CP 做一个项目。

我有一个多列表 A,它有 4 个参数:一个操作 o、一个外科医生 s、一个房间 r 和一个时间 t

A[o,s,r,t] == 1 
当且仅当手术o由外科医生s在房间r完成并在时间t

开始

而且我想说每个操作只能做一次,所以在约束中,我写道:

forall(o in Operations,s in Surgeons,r in Rooms,t in Times,s2 in Surgeons,r2 in Rooms,t2 in Times){
  ((s!=s2 || r!=r2 || t!=t2) && A[o,s,r,t] == 1) => A[o,s2,r2,t2]==0;
  //if an operation is done with some settings, it can't be done with any other settings 
 }  

逻辑是存在的,但我感觉我在要求 CPLEX 做 7 个嵌套循环,如何更有效地做到这一点?

constraints cplex cp constraint-programming implication
1个回答
0
投票

而不是逻辑约束

forall(o in Operations,s in Surgeons,r in Rooms,t in Times,s2 in Surgeons,r2 in Rooms,t2 in Times){
  ((s!=s2 || r!=r2 || t!=t2) && A[o,s,r,t] == 1) => A[o,s2,r2,t2]==0;
  //if an operation is done with some settings, it can't be done with any other settings 
 }  

你可以使用切片

forall(o in Operations,s in Surgeons,r in Rooms,t in Times,s2 in Surgeons,r2 in Rooms,t2 in Times:((s!=s2 || r!=r2 || t!=t2) ){
   (A[o,s,r,t] == 1) => (A[o,s2,r2,t2]==0);
  //if an operation is done with some settings, it can't be done with any other settings 
 }  
© www.soinside.com 2019 - 2024. All rights reserved.