I'm trying to use GEKKO to solve quite a large optimization problem locally (with remote=False
).
When running the code, I get the error:
Error: At line 463 of file custom.f90
Traceback: not available, compile with -ftrace=frame or -ftrace=full
Operating system error: Not enough memory resources are available to process this command.
Memory allocation failed
So that hints that the operating system doesn't let GEKKO use enough memory.
However, I'm using a 32GB RAM machine, with nearly 25 GB free, while the model probably don't even need 10GB.
I've tried using m.options.MAX_MEMORY = 10
, but this doesn't seem to matter.
Any thoughts on how to allow it to allocate more memory?
Here is some (simplified) code that triggers this error:
from gekko import GEKKO
quantiles = [(x+1)*.01 for x in range(300)]
#Initialize Model
m = GEKKO(remote=False)
#Set global options
m.options.IMODE = 3 #steady state optimization
m.options.SOLVER=3
m.options.MAX_ITER=100000
m.options.MAX_MEMORY = 10
m.options.REDUCE=10
#initialize variables
Est_array = m.Array(m.Var,(2, 16),value=1,lb=0,ub=48)
P_ij_t = m.Array(m.Var,(4, 16, 300), lb=0, ub=1)
Exp_ij_t = m.Array(m.Var,(4, 16, 300),value=1,lb=-36,ub=36)
C_t = m.Array(m.Var,300,lb=0,ub=5)
#Equations
for h in range(16):
for q in range(300):
m.Equation(m.sum([P_ij_t[i,h,q] for i in range(3)]) == 1)
for (q,t) in enumerate(quantiles):
m.Equation(C_t[q] == ( m.sum([P_ij_t[i+2,h,q]*(Est_array[i,h]-t)**2 for i in range(2) for h in range(16)]) + \
m.sum([P_ij_t[i,h,q]*(Est_array[1-i,15-h]-t)**2 for i in range(2) for h in range(16)])
)
)
#Objective
m.Minimize(C_t[0])
#Solve simulation
#m.open_folder()
m.solve()
#Results
print('C = ' + str(C_t[0].value[0]))
(All of the m.options.*
parameters are things that I tried to get the solver to run, but none seem to help with the memory allocation problem).
from GEKKO "Memory allocation failed"
No comments:
Post a Comment