I'm building a GEKKO model where I try to minimize a functional. This is done by 2D-fourier expanding the function and explicitly calculating the Riemann Sum of said functional. After increasing the number of fourier coefficients and the number of gridpoints, I run into an issue:
my code looks something like this (I've neglected some sums and the complex part):
m = GEKKO(remote=false)
ur_x_t =[m.Var(value=param[i][2],lb=-0.01,ub=0.01) for i in range(nG)]
ur_y_t =[m.Var(value=param[i][3],lb=-0.01,ub=0.01) for i in range(nG)]
for i in range(nG):
m.Minimize(b*ur_x_t[i]*g(i)[0] + ... )
def G_u(point):
return m.sum( (G_x * ur_x_t[i] + G_y*ur_y_t[i])*m.cos(np.dot(g(i),point) ) for i in range(nG) )
for point in gridpoints:
m.Minimize(a*m.cos( np.dot(g(0),point) + G_u(point) )
here a, b, G_x
and G_y
are just some numbers. The g(i)
are the vectors used to fourier expand the function, but can just be treated as some 2D-vector. param
is an array of good initial guesses to speed up the simulation. If I increase my number of gridpoints to 10000 and my number of fourier coefficients/m.Var to about 50 I run into the problem :
Error: 'results.json' not found. Check above for additional error details
Traceback (most recent call last):
File "/import/homes/user/Documents/reconstruction2.py", line 168, in <module>
m.solve()
File "/import/homes/user/.local/lib/python3.6/site-packages/gekko/gekko.py", line 2227, in solve
self.load_JSON()
File "/import/homes/user/.local/lib/python3.6/site-packages/gekko/gk_post_solve.py", line 13, in load_JSON
f = open(os.path.join(self._path,'options.json'))
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpn_uao1d8gk_model0/options.json'
The problem stems from the second for loop since the first one can be run with many more fourier coefficients. What can I do here?
Also I have another question regarding parallelization of my problem: Could I set up a parallelization of my programm and if I could how would I proceed about doing that? Sadly I'm not a computer scientist and not too apt with python, so it's quite hard for me to read the documentation about this. I'd like to multithread my Riemann sums, so the second for loop. Is this possible with gekko?