I want to use my own Genetic Algorithm (GA) to solve a Mixed Integer problem:
https://mintoc.de/index.php/Batch_reactor
Can I incorporate my solving method in GEKKO?
something like...
m = GEKKO()
.
.
.
m.options.SOLVER = 'my_GA'
GEKKO currently only supports gradient-based built-in solvers. If you are set on using a Genetic Algorithm (Chapter 6 for GA overview), you could run function evaluations with GEKKO to returns an objective value at different trial conditions. You would need to put an m.solve()
command inside a loop every new generation of the GA. In GEKKO, you would also need to use m.options.TIME_SHIFT=0
to not update the initial conditions. This would allow repeated evaluations as you change your design variables (e.g. T(t) from MintOC) to find the best objective function value (e.g. x2(tf) from MintOC).
m = GEKKO()
# define model
x2 = m.Var()
T = m.Param()
.
.
.
m.options.TIME_SHIFT=0
m.options.IMODE = 4 # or 7
# GA loop
for i in range(generations):
T.value = [values from GA]
m.solve()
obj = x2.value[-1] # objective
# additional GA steps to decide new T values
Here is some additional information from the documentation: SOLVER selects the solver to use in an attempt to find a solution. There are free solvers: 1: APOPT, 2: BPOPT, 3: IPOPT distributed with the public version of the software. There are additional solvers that are not included with the public version and require a commercial license. IPOPT is generally the best for problems with large numbers of degrees of freedom or when starting without a good initial guess. BPOPT has been found to be the best for systems biology applications. APOPT is generally the best when warm-starting from a prior solution or when the number of degrees of freedom (Number of Variables - Number of Equations) is less than 2000. APOPT is also the only solver that handles Mixed Integer problems. Use option 0 to compare all available solvers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With