我在文件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索要结果表?
发布于 2018-07-10 22:38:26
请注意,带有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;
https://stackoverflow.com/questions/51274858
复制