sameCommonSubsequence

对一对序列变量的二元约束。 约束说明区间变量的某些相关子集的相对位置在两个序列(seq1 和 seq2)中是相同的。

上下文 类型
模型文件 (.mod) - 在 CPLEX 约束块中不允许使用。 Boolean(1 表示约束为 true,0 表示为 false)

语法

dvar sequence seq1 in ...;
dvar sequence seq2 in ...;
dvar interval a1[...] ...; // Reordering of a subset of the interval variables of seq1
dvar interval a2[...] ...; // Reordering of a subset of the interval variables of seq2

constraints {
  sameCommonSubsequence(seq1, seq2, a1, a2); // relates a1[i] to a2[i]
  sameCommonSubsequence(seq1, seq2); // intervals are related according to their order in the definition of the sequences
}

描述

此函数在序列变量 seq1seq2 之间创建“相同公共子序列”约束。 序列变量 seq1seq2 应该是大小相同。 这两个序列的区间变量之间的映射是由序列定义中使用的数组 a1a2 中区间变量顺序来确定。 The constraint states that the sub-sequences defined by seq1 and seq2 by only considering the pairs of present intervals (a1[i], a2[i]) are identical, modulo the mapping between intervals a1[i] and a2[i]. 缺省情况下,约束名称是空字符串,但您可以指定自己选择的名称。

注释:不能在元约束中使用此约束。

示例

这些约束生效的两个用例示例:

  • 先进/先出和无旁路约束

  • 基于方案的方法,针对含不确定性的方案

更多信息,请参阅sameSequence 中的示例说明。