我正在草拟 r600g 驱动程序中的银行调酒计划(这是低效的 ATM,我正在弄清楚限制条件):
enum CHANS = {x,y,z,w};
enum REGS = {R1, R2, R3, R4}; % for starters
% args
enum OPERANDS = {src1, src2, src3, src4};
array[OPERANDS] of REGS: Regs = [R1, R2, R1, R3];
array[OPERANDS] of CHANS: Chans = [x, x, y, x];
array[OPERANDS] of 1..4: Inst = [1,1,2,2];
array[OPERANDS] of 1..3: Port = [1,2,1,2];
% the rest
array[OPERANDS] of var 1..3: PortOut;
constraint sum(i in PortOut where i = 1)(1) <= 3;
constraint sum(i in PortOut where i = 2)(1) <= 3;
constraint sum(i in PortOut where i = 3)(1) <= 3;
output [show(Regs[op]) ++ "." ++ show(Chans[op]) ++ " " | op in OPERANDS where PortOut[op] == 1]
++ [show(Regs[op]) ++ "." ++ show(Chans[op]) ++ " " | op in OPERANDS where PortOut[op] == 2]
++ [show(Regs[op]) ++ "." ++ show(Chans[op]) ++ " " | op in OPERANDS where PortOut[op] == 3];
solve satisfy;
它适用于注释掉的 3 个“输出”行,否则它会失败:
λ minizinc test.mzn
test.mzn:17:
MiniZinc: type error: invalid type in output item, expected `array[int] opt string'
有任何想法吗?