我正在使用Governify-csp-tools来创建使用Minizinc建模的应用程序。我虽然无法将用Gecode编写的.mzn模型表示为JSON,但遇到了麻烦,但是我正在使用数组,int,一组int,数据表并已阅读
https://www.npmjs.com/package/governify-csp-tools
(“基本用法”部分)
我尝试将其表示为JSON,但没有结果。 .mzn的示例是
% The data is the set of
int: Products;
set of int: Test= 1..Products;
int: x;
int: y;
int: z;
int: k;
array[Test] of {0,1,5,15,30}: Ingredient_1;
array[Test] of {0,3,7,12}: Ingredient_2;
array[Test] of {0,3,6,1000}: Ingredient_3;
array[Test] of {0,3,6,1000}: Ingredient_4;
%decision variable%
var set of Test : occur;
constraint x=0-> forall (i in occur) (Ingredient_4 [i]= 0);
constraint y=7 \/ y=6 -> forall (i in occur)(Ingredient_1 [i]=30 );
constraint y=1 -> forall (i in occur)(Ingredient_1 [i]=0 ) ;
constraint z in 5..7 -> forall (i in occur)(Ingredient_4[i] !=0) ;
constraint k=7 \/ k=6 -> forall (i in occur)(Ingredient_2 [i] =12);
constraint k=5 -> forall (i in occur)(Ingredient_2 [i] =7);
constraint k=4 \/ k=3 -> forall (i in occur)(Ingredient_2 [i] !=0);
solve satisfy;
%Data Input
Products = 50;
y = 7;
x=0;
z=0;
k=4;
%All 50 values of Ingredients per product
Ingredient_1 = [30 , 30 , 30 , 15, 15, 15, 5 , 5 , 5 , 1, 1, 1, 30 , 30 , 30 , 15, 15, 15, 5 , 5 , 5 , 1, 1, 1, 30 , 30 , 30 , 15, 15, 15, 5 , 5 , 5 , 1, 1, 1, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0
];
Ingredient_2= [3 , 7 , 12, 3 , 7 , 12, 3 , 7 , 12, 3 , 7 , 12, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 3 , 3 , 3 , 7 , 7 , 7 , 12, 12, 12, 3 , 3 , 3 , 7 , 7
];
Ingredient_3 = [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 3 , 6 , 1000, 3 , 6 , 1000, 3 , 6 , 1000, 3 , 6 , 1000, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 3 , 6 , 1000, 3 , 6 , 1000, 3 , 6 , 1000, 0 , 0 , 0 , 0 , 0
];
Ingredient_4 = [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 3 , 6 , 1000, 3 , 6 , 1000, 3 , 6 , 1000, 3 , 6 , 1000, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 3 , 6 , 1000, 3 , 6
];
有什么想法吗? 可能的解决方法是使用更简单的mzn模型,该模型不会包含许多复杂的数据类型,例如int,但我认为这不是正确的方法。