我在r600g驱动程序中草拟银行混合调度(它是inefficient 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&#34;输出&#34;行注释掉,但否则失败:
λ minizinc test.mzn
test.mzn:17:
MiniZinc: type error: invalid type in output item, expected `array[int] opt string'
有什么想法吗?
答案 0 :(得分:2)
当您在output
部分中使用决策变量时,您(可能)必须使用fix
来使用变量的值。此处PortOut[op]
需要fix
&#39; ed:
output [show(Regs[op]) ++ "." ++ show(Chans[op]) ++ " " | op in OPERANDS where fix(PortOut[op]) == 1]
++ [show(Regs[op]) ++ "." ++ show(Chans[op]) ++ " " | op in OPERANDS where fix(PortOut[op]) == 2]
++ [show(Regs[op]) ++ "." ++ show(Chans[op]) ++ " " | op in OPERANDS where fix(PortOut[op]) == 3];