I just got started with GEKKO. I am trying to optimize a 3D array with 200 variables, but they only take binary values (0 or 1). This is what my code looks like (it's a bit ugly, but I'm not sure if there's a better way to define 200 variables reliably):
params = []
m = GEKKO()
m.options.SOLVER = 1
for i in range(1,201):
exec('x'+str(i)+'=m.Var(value=1, lb=0, ub=1, integer=True)')
exec('params.append(x'+str(i)+')')
m.Obj(solve_and_measure(*params)) # function I wish to minimize
m.solve(disp=True)
The full code can be found here.
I'm no expect in which optimization algorithm might be most suitable for my problem, but the problem I'm facing is the optimizer appears to call the function once, and never again.
This is the output - any idea why it doesn't continue to the second iteration?
--- FUNCTION CALLED ---
--- FUNCTION OUTPUT --- [dB]: 0.010252837676577073
apm 79.129.195.6_gk_model0 <br><pre> ----------------------------------------------------------------
APMonitor, Version 1.0.1
APMonitor Optimization Suite
----------------------------------------------------------------
--------- APM Model Size ------------
Each time step contains
Objects : 0
Constants : 0
Variables : 200
Intermediates: 0
Connections : 0
Equations : 1
Residuals : 1
Number of state variables: 200
Number of total equations: - 0
Number of slack variables: - 0
---------------------------------------
Degrees of freedom : 200
----------------------------------------------
Steady State Optimization with APOPT Solver
----------------------------------------------
Iter: 1 I: 0 Tm: 0.00 NLPi: 1 Dpth: 0 Lvs: 0 Obj: 1.03E-02 Gap: 0.00E+00
Successful solution
---------------------------------------------------
Solver : APOPT (v1.0)
Solution time : 1.290000000153668E-002 sec
Objective : 1.025283767657707E-002
Successful solution
---------------------------------------------------