从GLPK解决方案中获取表会引发错误“声明失败:out!= out”

时间:2018-07-10 22:38:26

标签: glpk

我在文件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;关键字之前添加了一行以将结果输出到表中:

...
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中获取表的示例。

求解模型后,如何向GLPK索取结果表?

2 个答案:

答案 0 :(得分:0)

请注意,带有table OUT语句的代码的输出中没有行Model has been successfully generated。因此,GLPK试图在解决问题之前写出结果表!示例代码in this thread表明GLPK需要知道何时解决问题,否则最终将解决问题。因此,只需在表之前添加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;

答案 1 :(得分:0)

  

发行版中的Wikibook和gmpl手册(在doc / gmpl.pdf中)都没有从GLPK中获取表格的示例。

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

示例在:

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

doc / gmpl.pdf在表格声明中有一章。