Я создаю модель планирования для объекта смешивания в Mini Zinc. Я задавал подобный вопрос ранее, но с тех пор я прогрессировал. Я подведу итог тому, что, по моему мнению, должна делать существующая модель, было бы очень полезно, если бы кто-то мог исправить любые логические или синтаксические ошибки, которые я сделал. Модель в настоящее время дает ошибки, с несколькими случаями «ожидаемого конца файла». Кажется, это упрощает по сравнению с несколькими другими последовательными моделями планирования, которые я нашел. Ниже вы найдете код модели, прокомментированный с моим пониманием каждой строки.
Помимо обзора логики и синтаксиса, я ищу помощь по «отсутствующему ограничению» в этой модели, которое требует, чтобы массив blends [y] содержал не более объявленного целочисленного количества каждого смешивания .
Известные будущие цели для этой модели включают автоматическое создание матрицы стоимости смешивания, вывод массива расписания с учетом начального дня в матрицу из 5 столбцов, представляющую дни недели, и отображение имени смеси, а не номера смеси.
enum Blends = { A, B, C, D, E, F};
%Establish names for each blend and link them to their order number.
int: nb = count([Blends])
%Count the number of blends, plan to use later.
int: qA; %Error: syntax error, unexpected int, expecting end of file
int: qB;
int: qC;
int: qD;
int: qE;
int: qF;
int: sb;
%Call for inputs of the quantity of each of the blends needed, as well as the number/letter of the blend currently in the machine.
int: mc = qA + qB + qC + qD + qE + qF;
%Sum the blend quantities to determine total number of blends
[Blendcost] : [|1,2,2,2,2,2,|1,1,1,1,1,1,|1,1,1,1,1,1,|2,2,2,1,2,2,|1,1,1,1,1,1,|1,1,1,1,1,1,|]; %Error: syntax error, unexpected [|, expecting identifier
%Establishes a blend cost matrix, 6X6 depicting the transition costs from any blend A-F to any other blend A-F
array [Blends] of int: 1..6;
%Is this line needed to establish the link between A/1, B/2, C/3 etc;? Or is that taken care of when Blends is enumerated?
array [0..mc] of var 1..6: y;
%Create an array from 0 to the number of blends with potential values from 1-6, corresponding to the blend numbers.
%Missing constraint: [y] can contain no more than the quantity of each blend declared above, except for the blend declared in the starting blend, which will be allowed that blend quantity + 1
constraint y(0) = sb
%y(0) is set equal to the starting blend Letter/Number Defined earlier, used to determine the first transitionary cost.
array [1..mc] of int: x(i); %Error: syntax error, unexpected array, expecting end of file
%Create an array from 1 to number of blends, which will be filled with the transition costs in response to variations in y
constraint forall(i in x)(x(i) = Blendcost(y(i-1),y(i)))
%For each space in x, x will equal the blend cost value obtained from the previous blend in the y array vs the next blend in the y array
solve minimize sum (x); %Error: syntax error, unexpected solve, expecting end of file
%Solves this model attempting to minimize the sum of the x array, which should be filled with the transition costs.
show(y):
%Print the final array of blend numbers that has minimized blend cost transition.
%Error: unexpected end of file, expecting identifier.