你如何在 Gekko 中使用 apm_get?

问题描述

对 Gekko 输出进行故障排除时,如何访问 infeasibilities.txt 文件?我在用着 m = GEKKO(remote=False) 所以我不知道 serverapp 参数在 apm_get(server,app,'infeasibilities.txt') 函数中使用什么。

解决方法

如果您在公共服务器上使用 remote=True 求解,那么您可以从服务器检索文件。

from gekko.apm import get_file
print(m._server)
print(m._model_name)
f = get_file(m._server,m._model_name,'infeasibilities.txt')
f = f.decode().replace('\r','')
with open('infeasibilities.txt','w') as fl:
    fl.write(str(f))

如果您使用 remote=False 求解,则无需从服务器获取文件。它将在运行文件夹 m.path 中可用或使用 m.open_folder() 查看。有关 How to retrieve the 'infeasibilities.txt' from the gekko

的更多详细信息