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

6 visualizzazioni (ultimi 30 giorni)
Paul Safier il 9 Ago 2022
Commentato: Paul Safier il 11 Ago 2022
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
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Walter Roberson il 9 Ago 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 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Paul Safier il 11 Ago 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.

Accedi per commentare.

### Categorie

Scopri di più su Particle Swarm in Help Center e File Exchange

R2022a

### Community Treasure Hunt

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

Start Hunting!

Translated by