Algorithm Minizin错误:无效的类型说明:应为'float';,实际“var浮动';

Algorithm Minizin错误:无效的类型说明:应为'float';,实际“var浮动';,algorithm,traveling-salesman,constraint-programming,minizinc,integer-programming,Algorithm,Traveling Salesman,Constraint Programming,Minizinc,Integer Programming,我有下面的Minizing计划,这是一项正在进行的工作,旨在解决旅行商问题(TSP)。我知道它所缺少的不仅仅是修复这个错误,但我仍然想理解为什么会出现这个错误。可复制的示例如下: include "globals.mzn"; % Input Parameters int: NUM_POINTS; float: MAX_TOTAL_DISTANCE; array[0..NUM_POINTS-1] of int: points; array[0..NUM_POINTS-1, 0..NUM_POI

我有下面的Minizing计划,这是一项正在进行的工作,旨在解决旅行商问题(TSP)。我知道它所缺少的不仅仅是修复这个错误,但我仍然想理解为什么会出现这个错误。可复制的示例如下:

include "globals.mzn";

% Input Parameters 
int: NUM_POINTS;
float: MAX_TOTAL_DISTANCE;
array[0..NUM_POINTS-1] of int: points;
array[0..NUM_POINTS-1, 0..NUM_POINTS-1] of float: distance_matrix;

% Decision Variable: where to go next, from each point (indexed on points)
array[0..NUM_POINTS-1] of var 0..NUM_POINTS-1: next_point;  

% Constraints that define a valid tour
constraint alldifferent(next_point);  % each point only visited once
constraint next_point[NUM_POINTS-1] == points[0];  % not sure if this is helpful or not?

% see if we can find a feasible solution below max-total-distance
float: total_distance = sum(p in points)(distance_matrix[points[p],next_point[p]]);
constraint total_distance < MAX_TOTAL_DISTANCE;
solve satisfy;

output[show(total_distance) ++ "\n" ++ show(next_point)];

如何使用和声明
的一个问题是:它被声明为单个数组,但在“数据”部分它被定义为二维矩阵。第二列(包含0.5的值)的用途是什么?

如何使用和声明
点的一个问题是:它被声明为单个数组,但在“数据”部分被定义为2d矩阵。第二列的值是0.5,它有什么用?当然,谢谢hakank!我最初被赋予
作为x.y坐标,但当我意识到x,y坐标仅对计算距离矩阵有价值时,我将
更改为代码中的整数数组。但我不小心把它们像那样留在了数据文件中。现在就把它们移除,太好了。我添加了一个“正式”的答案,所以你可以接受。当然,谢谢哈坎克!我最初被指定为x.y坐标,但当我意识到x,y坐标仅对计算距离矩阵有价值时,我在代码中将点更改为int数组。但我不小心把它们像那样留在了数据文件中。删除了它们,从而消除了此错误
% DATA (in my setup this is in a dzn file)
NUM_POINTS = 5;
points = [|
0, 0|
0, 0.5|
0, 1|
1, 1|
1, 0|];
distance_matrix = [|
0.0, 0.5, 1.0, 1.41, 1.0 |
0.5, 0.0, 0.5, 1.12, 1.12 |
1.0, 0.5, 0.0, 1.0, 1.41 |
1.41, 1.12, 1.0, 0.0, 1.0 |
1.0, 1.12, 1.41, 1.0, 0.0 |];