Gekko无法访问服务器,本地解决json文件错误

Gekko unreachable server, local solving json file error

我想我 运行 遇到了与此堆栈溢出相同的问题。

昨天我能够解决我的 Gekko 模型,今天我什至无法解决来自 Apmonitor 站点的示例。求解需要很长时间,我收到以下错误:

ImportError: No solution or server unreachable.
  Show errors with m.solve(disp=True).
  Try local solve with m=GEKKO(remote=False).

我尝试按照堆栈溢出中的建议在本地解决它 post 我在上面提到过:

m = GEKKO(remote=False)

但是,我收到以下错误:

Error: 'results.json' not found. Check above for additional error details
Traceback (most recent call last):

FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/mr/kgzm2xln40dcc10zkq06drhc0000gn/T/tmpzqxlyw7_gk_model0/options.json'

是不是服务器挂了,谁能帮我本地解决一下?

编辑,代码添加:

from gekko import GEKKO
m = GEKKO(remote=False)           # create GEKKO model
y = m.Var(value=2)    # define new variable, initial value=2
m.Equation(y**2==1)   # define new equation
m.options.SOLVER=1    # change solver (1=APOPT,3=IPOPT)
m.solve(disp=True)
print('y: ' + str(y.value)) # print variable value

本地解决错误remote=False 您引用的错误是因为求解器未能找到解决方案,或者因为您使用的是 MacOS 并且需要一些 gcc 的共享库。如果您使用的是 MacOS,请尝试安装 gcc 以获取 GitHub issue discussion for local solution on MacOS.

中提到的所需共享库
brew install gcc

如果是求解器问题,您可以在显示求解器输出时看到错误消息:

m.solve(disp=True)

由于 IPOPT 中线性求解器的许可限制,或者因为您的本地可执行文件没有求解器之一(例如,IPOPT 不适用于 [=26],本地求解有时与远程服务器求解不同=] 还)。如果请求的选项不可用,处理本地请求的 apm 可执行文件会自动恢复到下一个可用的求解器选项。您可以尝试 m.options.SOLVER=1 用于 APOPT 或 m.options.SOLVER=2 用于 BPOPT 作为不同的求解器。

此外,如果您想在求解器未成功找到解决方案时抛出异常,则应将调试级别保留在 1。否则,设置 debug=0 并使用 m.options.APPSTATUS 来确定求解器是否成功。

m.solve(disp=True,debug=0)
if m.options.APPSTATUS==0:
    print('Solver failed to find a solution')
else:
    print('Successful solution')

如果您可以 post minimal example that shows the issue.

,我们可以提供更具体的建议让您的程序在本地运行

云计算 remote=True

public 服务器今天有几个小时不可用,但现在已恢复。由于 Gekko 的流行,服务器有时会超载或因偶尔的维护活动而无法使用。如果您想在云中托管自己的系统或作为专用服务器,可以使用专用 APMonitor 服务器作为 compute server for Linux or as a compute server for Windows。如果您创建自己的服务器,请使用:

m = GEKKO(server='http://10.0.0.10',remote=True)

但用 10.0.0.10 代替服务器的 IP 地址。