[英]How to know how long GEKKO took to solve my model?
How can I get an output from GEKKO on how long it took to solve my model?我怎样才能从 GEKKO 获得 output 解决我的 model 需要多长时间? I know based off of Measure time elapsed in Python that I can get my code to print the total time taken to run my code but I do not know how to isolate the solver time.
我知道基于Python 中经过的测量时间,我可以让我的代码打印运行我的代码所花费的总时间,但我不知道如何隔离求解器时间。
from gekko import GEKKO
import time
start = time.time()
m = GEKKO(remote=False)
x = m.Var(value=0)
y = m.Var(value=1)
m.Equations([x + 2*y==0, x**2+y**2==1])
s1 = time.time()
m.solve(disp=True)
e1 = time.time()
print([x.value[0],y.value[0]])
end = time.time()
print('Total Elapsed: ' + str(end-start))
print('Solver Time 1: ' + str(e1-s1))
Solver Time 1 is listed as 0.18468
sec but this is different than the IPOPT reported time of 0.0156
sec.求解器时间 1 列为
0.18468
秒,但这与 IPOPT 报告的0.0156
秒时间不同。 How can I programmatically get the solver reported time?如何以编程方式获取求解器报告的时间?
EXIT: Optimal Solution Found.
The solution was found.
The final value of the objective function is 0.
---------------------------------------------------
Solver : IPOPT (v3.12)
Solution time : 0.0156 sec
You can see the solver reported time with m.options.SOLVETIME
such as:您可以使用
m.options.SOLVETIME
查看求解器报告的时间,例如:
print('Solver Time 2: ', m.options.SOLVETIME)
Solver Time 1
includes the setup and solution transfer. Solver Time 1
包括设置和解决方案传输。 You can speed up the total time by not displaying the solver output with disp=False
and solving locally instead of on a remote server with remote=False
.您可以通过不使用
disp=False
显示求解器 output 并在本地求解而不是使用remote=False
在远程服务器上求解来加快总时间。 A local solve generally reduces the amount of time it takes to send to a server and retrieve a solution but there are fewer solver options with a local solve.本地解决方案通常会减少发送到服务器和检索解决方案所需的时间,但本地解决方案的求解器选项较少。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.