英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论