GLPK:默认设置表达式必须具有维度 2 而不是 1

GLPK: set expression following default must have dimension 2 rather than 1

我有一个 AMPL 模型文件,我正在努力将其转换为 GLPK。开始:

param n;        # The number of nodes in the graph
set V := {1 .. n};  # The set of vertices in the graph
set E within V cross V; # The set of edges in the graph
set NE within V cross V := {i in V, j in V: i < j} diff E;
set FIXED within V cross V default {}; # The set of demand pairs with fixed flow

当运行这个时候,我得到以下错误:

_test.mod:5: set expression following default must have dimension 2 rather than 1
Context:  : i < j } diff E ; set FIXED within V cross V default { } ;
MathProg model processing error

这一定是 MathProg 及其超集 AMPL 之间的句法差异——运行 AMPL 中的代码可以完美运行。如何在 MathProg 中表达二维空集?

好的,解决方案的窍门是:

set FIXED within V cross V default {i in V, j in V: 1 < 0};

输入明显错误的条件。它将具有您想要的维度并且仍然是空的。