Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何为大型数组建模,例如“array[1..10000000] of int: A;” 它有很多 0 作为默认值。有没有办法为 MiniZinc 指定“默认”值以减少数据文件的大小?
MiniZinc 是一种声明性语言,您不能在其中更改已分配变量的值。这让问题有点奇怪,因为变量的值不能改变,所以不需要默认值。
我会使用数组理解[if i == 3 then i else 0 endif | i in 1..10000000]并根据您的需要切换 if 语句的条件和结果。
[if i == 3 then i else 0 endif | i in 1..10000000]
可能有另一种表示数组的方式?大部分为空的数组听起来不是很有效。