Я использую Governify-CSP-инструменты для создания приложения, которое использует моделирование Minizinc.У меня проблемы с представлением модели .mzn, записанной в Gecode, в JSON, я использую массивы, int, набор int, таблицы данных и прочитал это
https://www.npmjs.com/package/governify-csp-tools
(BasicРаздел использования)
Я пытаюсь представить его в 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, но я не думаю, что это правильный подход.