when I run the GEKKO optimization, I got a 'FileNotFoundError', please let me know how to handle it. Is there any problem in my code? Y is Binary Integer Decision Variable.
#initialize gekko
model = GEKKO(remote=False)
#APOPT is an Mixed Integer Nonlinear Problem solver
model.options.SOLVER = 1
model.time
#optional solver settings with APOPT
model.solver_options = ['minlp_maximum_iterations 500', \
# minlp iterations with integer solution
'minlp_max_iter_with_int_sol 10', \
# treat minlp as nlp
'minlp_as_nlp 0', \
# nlp sub-problem max iterations
'nlp_maximum_iterations 50', \
# 1 = depth first, 2 = breadth first
'minlp_branch_method 1', \
# maximum deviation from whole number
'minlp_integer_tol 0.05', \
# covergence tolerance
'minlp_gap_tol 0.01']
#parameter
X = total_PV_set
k = len(X)
eq = model.Param(value=len(X))
eq1 = model.Param(value=1)
#Decision Variable
# N = model.Var(value=1, lb=1, ub=k, integer=True)
N = 3
Y = model.Array(model.Var, (N, k), lb=0, ub=1, integer=True)
V = model.Array(model.Var, (N, 1))
W = model.Array(model.Var, (N, 1))
vary = model.Array(model.Var, (N, 1))
covary = model.Array(model.Var, (N, 1))
#Constraints
for i in range(N):
vary_buff = 0
for j in range(k):
vary_buff += model.Intermediate(variance(X[j]) * Y[i][j])
model.Equation(vary[i] == vary_buff)
for i in range(N):
covary_buff = 0
for j in range(k):
for e in range(k-1):
if j < (e+1):
covary_buff += model.Intermediate(2*covariance(X[j], X[e+1])*Y[i][j]*Y[i][e+1])
model.Equation(covary[i] == covary_buff)
for i in range(N):
model.Equation(V[i] == model.Intermediate(vary[i]+covary[i]))
for i in range(N):
model.Equation(W[i] == model.Intermediate(model.sum(Y[i][:])))
model.Equation(model.sum(Y) == eq)
for i in range(k):
model.Equation(model.sum(Y[:, i]) == eq1)
cc = model.Intermediate(model.sum([(W[i]*V[i]) for i in range(N)]))
model.Obj(cc/model.sum(W))
#minimize objective
# model.options.IMODE = 3
# model.options.MEAS_CHK = 0
model.solve()
#Print the results
print ('--- Results of the Optimization Problem ---')
print('Y: '+str(Y))
print('N: '+str(N))
print('V: '+str(V))
print('W: '+str(W))
print('Objective: '+str(model.options.objfcnval))
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32 runfile('C:/Users/chldj/EOJIN/VPP_test.py', wdir='C:/Users/chldj/EOJIN') Backend TkAgg is interactive backend. Turning interactive mode on. C:/Users/chldj/EOJIN/VPP_test.py:91: DeprecationWarning: elementwise comparison failed; this will raise an error in the future. model.Equation(vary[i] == vary_buff) C:/Users/chldj/EOJIN/VPP_test.py:98: DeprecationWarning: elementwise comparison failed; this will raise an error in the future. model.Equation(covary[i] == covary_buff) C:/Users/chldj/EOJIN/VPP_test.py:100: DeprecationWarning: elementwise comparison failed; this will raise an error in the future. model.Equation(V[i] == model.Intermediate(vary[i]+covary[i])) C:/Users/chldj/EOJIN/VPP_test.py:102: DeprecationWarning: elementwise comparison failed; this will raise an error in the future. model.Equation(W[i] == model.Intermediate(model.sum(Y[i][:]))) ---------------------------------------------------------------- APMonitor, Version 0.9.2 APMonitor Optimization Suite ----------------------------------------------------------------
Error: Exception: Access Violation At line 2391 of file custom_parse.f90 Traceback: not available, compile with -ftrace=frame or -ftrace=full Error: 'results.json' not found. Check above for additional error details Traceback (most recent call last): File "<input>", line 1, in <module> File "C:\pycharm\PyCharm Community Edition 2019.2.2\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile pydev_imports.execfile(filename, global_vars, local_vars) # execute the script File "C:\pycharm\PyCharm Community Edition 2019.2.2\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "C:/Users/chldj/EOJIN/VPP_test.py", line 114, in <module> model.solve() File "C:\python\lib\site-packages\gekko\gekko.py", line 2145, in solve self.load_JSON() File "C:\python\lib\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: 'C:\\Users\\chldj\\AppData\\Local\\Temp\\tmpdgnw5ovqgk_model0\\options.json'
Is it means that the solution is infinity? I think 1st iteration's sum(W) will be a 0. so it can make objective function 'infinity'. how can I fix it?