从 GLPK 解决方案中获取 table 会引发错误 "Assertion failed: out != out"

Getting a table out of a GLPK solution throws error "Assertion failed: out != out"

我在文件 lp 中有一个线性程序,GLPK 使用此命令求解:

glpsol --math -m lp

屏幕上的部分输出是:

Generating priority_words...
Model has been successfully generated
...
Long-step dual simplex will be used
+   770: mip =     not found yet <=              +inf        (1; 0)
Solution found by heuristic: 1569225
...
INTEGER OPTIMAL SOLUTION FOUND
...
Writing MIP solution to 'result'...

文件 result 未格式化,我想以 CSV 格式保存结果。所以我在最后一个约束之后和 end; 关键字之前添加了一行将结果输出到 table:

...
s.t. priority_words{w in words}: include[w] >= priority[w];

table num{u in unicodes} OUT "CSV" "num.csv": u~unicode, number_of_characters[u]~count;

end;

而 GLPK 给出了这个错误:

Generating priority_words...
Writing num...
Assertion failed: out != out
Error detected in file mpl/mpl3.c at line 5072
Abort trap: 6

分发版中的 wikibook 和 gmpl 手册(位于 doc/gmpl.pdf)都没有从 GLPK 中获取 table 的示例。

求解模型后如何向 GLPK 询问 table 结果?

请注意,带有 table OUT 语句的代码的输出没有行 Model has been successfully generated。因此GLPK试图在解决问题之前写出table的结果!示例代码in this thread表明GLPK需要知道什么时候解决问题,否则最后解决。所以只需在 table:

之前添加 solve;
...
s.t. priority_words{w in words}: include[w] >= priority[w];
solve;
table num{u in unicodes} OUT "CSV" "num.csv": u~unicode, number_of_characters[u]~count;
end;

Neither the wikibook nor the gmpl manual in the distribution (at doc/gmpl.pdf) have an example of getting a table out of GLPK.

当前的 GLPK 版本是 4.65。以下几行与此版本有关。

示例位于:

  • examples/csv
  • examples/sql
  • examples/dbf

doc/gmpl.pdf 有一章是关于 table 语句的。