Can one of MATLAB's optimization algorithms (e.g. particle swarm optimization) take the place of this brute force parameter sweep iteration?

4 visualizaciones (últimos 30 días)
I want to find an optimal set of parameters but the time to run through every combination (in a brute force parameter sweep) will be too much computation time. Can particle swarm optimization (or another algorithm) be used instead? The code is not written stricly as a function like the documentation examples use...
I want the values of var1, var2 and var3 that minimize the output value, out1.
var1 = (-60:0.1:60)';
var2 = (-110:0.1:110)';
var3 = (3.5:0.1:18.5)';
% Set up the design matrix, desMat
desMat = {var1,var2,var3};
[desMat{:}]=ndgrid(desMat{:});
n=length(desMat);
desMat = reshape(cat(n+1,desMat{:}),[],n);
parfor kk = 1:NS
var1a = desMat(kk,1); var2a = desMat(kk,2); var3a = desMat(kk,3);
[out1] = Function_Pd(var1a,var2a,var3a);
end

Respuesta aceptada

Walter Roberson
Walter Roberson el 9 de Ag. de 2022
In theory, NO, none of those functions can take the place of a parameter sweep for a generalized calculation.
There are calculations for which it can be proven that knowing the value of a function at any finite number of locations does not give you information about the value of the function at a given location.
There are functions that there is no known way to calculate, such as the list of locations at which the prime number estimate function swaps between being an overestimate and underestimate.
So, it cannot always be done.
Whether it is possible for your calculation depends upon what you are calculating.
There is a set of functions for which unconstrained Genetic Algorithm is guaranteed to converge. It has been rather some time since I last looked at the relevant theory; my vague memory is that it is not much better than Quadratic functions. Unless, that is, you go by definitions such as https://www.researchgate.net/publication/220616519_Convergence_Criteria_for_Genetic_Algorithms which says that provided that you mutate long enough that you will get convergence (they give upper bounds on number of iterations for some conditions, but I cannot read the paper myself.)
  1 comentario
Paul Safier
Paul Safier el 11 de Ag. de 2022
@Walter Roberson thanks for your input and tip! I was able to couch the function into the form that MATLAB's particle swarm optimization requires and it worked to provide a pretty good result. I don't know if it's the absolute best (global minimum), but it is definitely sufficient for what I need. I may try a genetic algorithm as well and see what that can offer. Thanks again.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Particle Swarm en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by