如何修复数据文件中Minizinc模型的数组集变量的部分变量?

huangapple go评论94阅读模式
英文:

How to fix part of a variable of type array of set var in a data file for a Minizinc model?

问题

我有一个Minizinc模型和一个数据文件。我想将部分解决方案输入到我的模型中,但它一直报错。

以下是我的模型的简化版本:

enum pieces;
enum beams;
array[beams] of var set of pieces: b2p;
(约束条件)

以下是数据文件:

pieces={p1, p2, p3, p4, p5};
beams={b0, b1, b2};

我想要修复部分b2p变量,如下所示:

b2p[b0] = {p1};
英文:

I have a Minizinc model and I have a data file. I would like to feed part of a solution to my model, but it keeps giving my an error.

Here is a simplified version of my model.

enum pieces;
enum beams;
array[beams] of var set of pieces: b2p;
(constraints)

Here is the data file :

pieces={p1, p2, p3, p4, p5};
beams={b0, b1, b2};

I would like to fix part of b2p variable like so :

b2p[b0] = {p1};

答案1

得分: 1

你可以使用以下的赋值方式来给b2p数组赋值:

b2p = [{p1}, _, _];

即将{p1}赋值给向量的第一个元素,并将其余部分保持不变。

英文:

You can use the following assignment to b2p array

b2p = [{p1}, _, _];

that is assign {p1} to the first element of the vector and leave the rest unfixed.

huangapple
  • 本文由 发表于 2023年2月14日 22:02:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/75448938.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定