how can i validate my optimization algorithm?

35 visualizzazioni (ultimi 30 giorni)
I am using Genetic algorithm, Particle swarm, simulated annealing for comparative study. I want to validate the model. for this purpose let's suppose i have two variable x, y.
their actual values are x = 10, y= 20. and their function returns value 1.33.
in order to validate what i am doing is i am setting lower and upper bound in the range of their respective value. for example for x my lower and upper bound is [5 15] and for y [15 25] and after optimizing these i got 1.55. then i calculate percentage error from estimated and predicted value.
is this is the correct way for validation for model?

Risposte (2)

Andreas Apostolatos
Andreas Apostolatos il 5 Mag 2022
Hi Harsh,
From your description I understand that your cost function f depends on (x,y), namely f = f(x,y) and that f(10, 20) = 1.33 is your initial guess.
If the objective function is non-convex, then it may contain multiple minima/maxima. In such a case constraining your design space might yield only one of these minima/maxima ignoring the rest of the design space. This can help convexify the problem at hand, but it may yield not the most optimal solution in terms of the objective value.
The algorithms you mentioned, namely, the genetic algorithm, the particle swarm, and the simulated annealing are all algorithms of the Global Optimization Toolbox and best suited for problems where the global minimum/maximum is sought (oftentimes one seeks only local minima/maxima where other algorithms are better suited).
My guess would be that if all these algorithms yield the same result, then it is very likely that the solution found is indeed the global optimum. The reason for this argumentation is that these algorithms are inherently different and thus having all of them yield the same result would be a good indication that the converged solution is indeed an optimum.
Since your problem is two dimensional, you can select a set of points (x_i,y_j), compute the value of the objective function at these points f(x_i,y_j) and then plot the objective function as a surface using for instance function surf. You can then plot also the solution from the latter algorithms on this graph and visually verify that the point (x,y) found by these algorithms is a stationary point. You can also compute the gradient of the converged point at that location by means of Finite Differences or so (you would need some points around the converged solution for this and then use function diff for instance) to verify that this is a stationary point.
I hope this information helps.
Kind regardds,
Andreas
  1 Commento
harsh Brar
harsh Brar il 6 Mag 2022
Modificato: harsh Brar il 6 Mag 2022
hey postolatos ! thank you for the information.
Can you please help me validation through plotting. I am quite new to matlab.
This is my function
function t=strength(x)
t(1) = -3.802+0.00.*x(1)+0.001.*x(2)+0.00.*x(3)+0.009.*x(4)-0.027.*x(5)+0.008.*x(6)-0.001.*x(7)+0.004.*x(8)-0.208.*x(9)+0.040.*x(10)-0.007.*x(11)+0.023.*x(12)-0.503.*x(13);
end
and this is my PARTICLE SWARM OPTIM. algorithm.
clc
clear all
tic
options = optimoptions('particleswarm','SwarmSize',100,'Display','iter','HybridFcn',@patternsearch,'PlotFcn','pswplotbestf');
obj = @(x)strength(x);
lb = [226 239 0 0 0 213 638 956 0.45 4 30 17 0];
ub = [230 242 0 0 0 215 640 959 0.45 4 30 17 0];
rng default % For reproducibility
nvars = 13
[x,fval,exitflag,output] = particleswarm(obj,nvars,lb,ub,options)
display(fval)
toc
Can you help me with writing the code for this
"you can select a set of points (x_i,y_j), compute the value of the objective function at these points f(x_i,y_j) and then plot the objective function as a surface using for instance function surf. You can then plot also the solution from the latter algorithms on this graph and visually verify that the point (x,y) found by these algorithms is a stationary point. You can also compute the gradient of the converged point at that location by means of Finite Differences or so (you would need some points around the converged solution for this and then use function diff for instance) to verify that this is a stationary point".

Accedi per commentare.


Alan Weiss
Alan Weiss il 6 Mag 2022
Your objective function is smooth. Therefore, you should not be using particleswarm or ga or simulannealbnd, but instead should use a gradient-based solver from Optimization Toolbox™ such as fmincon. See Table for Choosing a Solver. And I think that you made a typo giving the upper and lower bounds the same values, which will keep any algorithm from moving from that point.
The only possible thing to explore is the multiple minima of your objective function, if there are multiple minima. To do so you can use MultiStart, started from a large number of points because you have a lot of dimensions in your problem.
Alan Weiss
MATLAB mathematical toolbox documentation
  2 Commenti
harsh Brar
harsh Brar il 6 Mag 2022
thanks for the info.
but that i just used for example. my real problem is:-
This is my function
ThemeCopy
function t=strength(x)
t(1) = -3.802+0.00.*x(1)+0.001.*x(2)+0.00.*x(3)+0.009.*x(4)-0.027.*x(5)+0.008.*x(6)-0.001.*x(7)+0.004.*x(8)-0.208.*x(9)+0.040.*x(10)-0.007.*x(11)+0.023.*x(12)-0.503.*x(13);
end
and this is my PARTICLE SWARM OPTIM. algorithm.
clc
clear all
tic
options = optimoptions('particleswarm','SwarmSize',100,'Display','iter','HybridFcn',@patternsearch,'PlotFcn','pswplotbestf');
obj = @(x)strength(x);
lb = [226 239 0 0 0 213 638 956 0.45 4 30 17 0];
ub = [230 242 0 0 0 215 640 959 0.45 4 30 17 0];
rng default % For reproducibility
nvars = 13
[x,fval,exitflag,output] = particleswarm(obj,nvars,lb,ub,options)
display(fval)
toc
Andreas Apostolatos
Andreas Apostolatos il 7 Mag 2022
Hi,
As Alan just mentioned, a gradient-based solver is more suitable for optimization problems whose cost function is smooth, which appears to be the case for you also. You can actually reproduce the solution from particleswarm function using fmincon with the following lines of code,
options_fmincon = optimoptions('fmincon', 'Display', 'iter', 'PlotFcn', 'optimplotx', 'StepTolerance', 1e-12, 'OptimalityTolerance',1e-12);
x0 = mean(lb + ub, 1);
[x_fmincon, fval_fmincon, exitflag_fmincon, output_fmincon] = ...
fmincon(obj, x0, [], [], [], [], lb, ub, [], options_fmincon)
It is not possible to know in advance whether your cost function has multiple optima, especially for high dimensional design spaces as in your case. Citing again Alan's answer above, the only way to methodologically check for multiple minima would be to use the MultiStart starting from a large number of points, see the following documentation page,
I hope this helps.
Kind regards,
Andreas

Accedi per commentare.

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by