problem using GA to optimize an image processing index in MATLAB?
5 ビュー (過去 30 日間)
古いコメントを表示
Hi everyone, I have a problem using GA to optimize an image processing index. the GA optimization works but does not respond to stop criteria and seems to be running forever no matter what i do.
So, I wanted to fit two graphs using SSIM index. The function that i wrote creates the model in another program, used for nonlinear structural engineering (OpenSEES), then plots and saves the model as a .png file. like the one below:
The general idea of the code is to give the function MIK a set of parameters P (in this case 14 parameters) and calculate and minimize the error value using SSIM index.
function error = MIK2(P)
. % this part opens opensees runs the model
. % plots the model and saves it as a .png file
A = imread('Model_Output.png');
B = imread('Experimet_Data.png');
error = 1-ssim(A,B);
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/766056/image.png)
After opening the GA toolbox and setting the stop criteria to only run for 10 populations i noticed that GA does not even count the steps and basically reports nothing and responds to nothing I literally have to close MATLAB to stop the optimization! :)
Any help would be appreciated... tnx :)
0 件のコメント
回答 (1 件)
Alan Weiss
2021 年 10 月 13 日
I suspect that the problem is your objective function takes too long, possibly it does not even finish.
I assume that you have defined the nvar and lb and ub argumentts for ga. (I assume that you have finite bounds.) If so, see how long it takes to run your objective function on a random point:
pt = lb + rand(size(lb)).*(ub - lb);
% Or, if you have no bounds, pt = randn(1,nvar);
tic
error = MIK2(pt);
toc
If this returns in a reasonable amount of time, then to help us understand what is going on, please show your ga call and any options that you are passing.
Alan Weiss
MATLAB mathematical toolbox documentation
2 件のコメント
Alan Weiss
2021 年 10 月 19 日
This is strange. In order to have more control over what is happening, I wonder if you can try running the optimization at the command line instead of using the Optimization App. Something like this:
options = gaoptimset('Generations',10,'Display','iter');
nvar = 14;
options = gaoptimset(options,'InitialPopulation',randn(1,nvar)); % Put in the real init pop here
lb = zeros(1,nvar); % Put in your real bounds here
ub = ones(1,nvar); % Put in your real bounds here
[x,fval,exitflag] = ga(@MIK2,nvar,[],[],[],[],lb,ub,[],options)
Running this way you can put break points in the code and see what is going on more easily.
Alan Weiss
MATLAB mathematical toolbox documentation
参考
カテゴリ
Help Center および File Exchange で Genetic Algorithm についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!