【问题标题】:Getting a table out of a GLPK solution throws error "Assertion failed: out != out"从 GLPK 解决方案中获取表会引发错误“断言失败:out != out”
【发布时间】:2018-07-10 22:38:26
【问题描述】:

我在文件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 索要结果表?

【问题讨论】:

  • 永远不应该达到断言。请将包含模型文件的邮件发送至 bug-glpk@gnu.org。参照。 lists.gnu.org/mailman/listinfo/bug-glpk
  • @Xypron 不,确实不应该!原因是我是 GLPK 的新手,在要求输出表格之前忘记添加 solve;。我写了这个作为答案。

标签: glpk


【解决方案1】:

请注意,带有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;

【讨论】:

    【解决方案2】:

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

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

    示例在:

    • 示例/csv
    • 例子/sql
    • 例子/dbf

    doc/gmpl.pdf 有一章是关于表格声明的。

    【讨论】:

    • 是的,我阅读了那一章并学习了语法,但在手册中仍然找不到有效的示例。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-27
    • 2021-03-07
    • 2021-12-04
    • 1970-01-01
    • 2019-10-12
    • 2017-08-12
    相关资源
    最近更新 更多