简体   繁体   English

Eclipse CLP标签:排除排列

[英]Eclipse CLP labeling: exclude permutations

I am solving a scheduling problem (briefly described here: SWI Prolog CLP(FD) scheduling switched to ECLP). 我正在解决一个调度问题(在此简要描述: SWI Prolog CLP(FD)调度切换到ECLP)。

I am able to get some solution quickly, but now I want to incorporate some optimization task. 我能够快速获得一些解决方案,但是现在我想合并一些优化任务。

A part of the problem/schedule row looks like D1,D2,N1,N2,A0,A1,A2,..,A9 where some cost for this variables is C1,C1,C1,C1,C2,C2,C2,...,C2 . 问题/时间表行的一部分看起来像D1,D2,N1,N2,A0,A1,A2,..,A9 ,其中此变量的一些成本为C1,C1,C1,C1,C2,C2,C2,...,C2 So from this point of view any permutation of assignments to A0..A9 has the same cost. 因此,从这个角度来看,对A0..A9任何分配置换A0..A9具有相同的成本。 But, obviously, during the labeling process the solver backtracks through all the possibilities. 但是,很显然,在标记过程中,求解器会回溯所有可能性。

Short note: I am calculating this only in my head, but I think the search space only for this described part is like number of subsets of size 10 from domain of size 15 * 10! 简短说明:我只是在脑子里计算这个,但是我认为仅是针对此描述部分的搜索空间就像来自大小为15 * 10的 域的大小为10的子集数量一样 . This is quite some amount of space to backtrack through. 这是要回溯的相当大的空间。 And from the point of view of cost/optimization as well as the constraint satisfaction, each permutation has the same cost/satisfiability - the order of variables does not matter. 并且从成本/优化以及约束满足的角度来看,每个排列都具有相同的成本/可满足性-变量的顺序无关紧要。

Can I somehow affect the labeling/search procedure to do not bother with order of variables within some list? 我可以以某种方式影响标签/搜索过程,以免打扰某些列表中的变量顺序吗? Or can you provide some way how to remodel the problem to be able to work this way? 还是可以提供一些方法来重塑问题以这种方式工作?

What you are talking about is the issue of symmetry in modelling, and there is a whole research area dedicated to it. 您正在谈论的是建模中的对称性问题,并且有一个专门针对它的整个研究领域。 I would say there are essentially three ways of addressing this: 我要说的是解决问题的三种方法:

  1. reformulate the model with different variables such that there are inherently fewer ways of representing equivalent solutions 用不同的变量重新构建模型,以便本质上减少表示等效解的方法
  2. add symmetry-breaking constraints to reduce the total number of solutions but keep at least one of each equivalence class. 增加打破对称性的约束以减少解的总数,但保留每个等价类中的至少一个。 This is typically done with arithmetic or lexicographic ordering constraints, which effectively define how a "canonical" representation of a solution should look like. 通常使用算术或词典顺序约束来完成此操作,这些约束有效地定义了解决方案的“规范”表示形式。
  3. try a dynamic symmetry breaking technique that your system provides, such as ldsb . 尝试使用系统提供的动态对称破坏技术 ,例如ldsb These typically take a description of the symmetry, and try to do something about it (but don't expect wonders). 这些通常会描述对称性,并尝试对此做些事情(但不要指望奇迹)。

In your case, I would start with point 1: you currently have variables A[I,D]=W meaning "slot I of type A on day D is filled with worker W" although all your A-slots are equivalent. 在您的情况下,我将从点1开始:您当前拥有变量A [I,D] = W,这意味着“在D天类型A的插槽I被工作人员W填满”,尽管您所有的A插槽都是等效的。

You could instead have binary variables JobA[D,W]=1 "worker W does a job of type A on day D", together with a constraint sum(JobA[D,*])#=10 to make sure you have 10 slots filled. 您可以改为使用二进制变量JobA [D,W] = 1 “工人W在D天完成A类型的工作”,以及约束条件sum(JobA[D,*])#=10以确保您有10插槽已满。

Another model I can imagine is having variables Job[D,W]=T "worker W does job of type T on day D" (encoding your job types T as 1..3) and use occurrences/3 or gcc/2 constraints to enforce your various conditions. 我可以想象的另一个模型是变量Job [D,W] = T “工人W在D天完成T类型的工作”(将您的T类型的工作编码为1..3),并使用了次数/ 3gcc / 2约束加强您的各种条件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM