why using pattrensearch with genetic algorithm gives error while fminunc not

조회 수: 1 (최근 30일)
Dear All,
I'm using ga from matlab and I need to improve my result so I decided to use local search with GA. I used fminunc it gave almost the same result. So I tried to use patternsearch, but it gave error. Down I wrote my code
function [x,fval,exitflag,output,population,score] = PGA(nvars,PopulationSize_Data,Generations_Data,InitialPopulation_Data)
% This is an auto generated MATLAB file from Optimization Tool.
%%Start with the default options
options = gaoptimset;
%%Modify options setting
options = gaoptimset(options,'PopulationSize', PopulationSize_Data);
options = gaoptimset(options,'Generations', Generations_Data);
options = gaoptimset(options,'InitialPopulation', InitialPopulation_Data);
options = gaoptimset(options,'Display', 'off');
options = gaoptimset(options,'PlotFcns', { @gaplotbestf @gaplotbestindiv});
[x,fval,exitflag,output,population,score] = ...
ga(@FP,nvars,[],[],[],[],[],[],[],[],options)
To here my original code finish, so I add the next code for fminunc, when I write the code to use fminunc it gives result
fminuncOptions = optimoptions(@fminunc,'Display','iter','Algorithm','quasi-newton');
options = gaoptimset(options,'HybridFcn',{@fminunc, fminuncOptions});
[y,fval] = ga(@FP,nvars,[],[],[],[],[],[],[],options);
while for patternsearch I got error, in fact I want to use pattern search using poll to get better result.
options = optimoptions(@patternsearch,'Display','off');
options = gaoptimset(options,'HybridFcn', {@patternsearch,options});
[y,fval] = ga(@FP,nvars,[],[],[],[],[],[],[],[],options);
Can anyone help me with it please?
Thanks in advance.
Nadia
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2015년 9월 13일
Nadia - what is the error that you are observing?
nadia nadi
nadia nadi 2015년 9월 15일
편집: per isakson 2015년 9월 16일
Dear Geoff,
Thanks for replying, I got this
Error using optimoptions (line 114)
Invalid solver specified. Provide a solver name or handle (such as 'fmincon' or @fminunc).
Type DOC OPTIMOPTIONS for a list of solvers.
%
Error in PGA (line 25)
options = optimoptions(@patternsearch,'Display','off');
Error in SimulationPerm (line 38)
[z,fval,exitflag,output,population] = PGA(n,10,10,Res);
I hope you can sort it. I need to use pattern search poll. Many thanks in advance.
Nadia.

댓글을 달려면 로그인하십시오.

채택된 답변

Alan Weiss
Alan Weiss 2015년 9월 16일
Currently, you cannot use optimoptions to set options for patternsearch. Use psoptimset to set patternsearch options.
Alan Weiss
MATLAB mathematical toolbox documentation
  댓글 수: 5
nadia nadi
nadia nadi 2015년 9월 19일
편집: nadia nadi 2015년 9월 20일
Dear Alan,
Thanks for replying, I used your options and it works thanks, in fact I wrote the same before but with this line
psoptions = psoptimset(@patternsearch,'Display','off');
so it gave me error. Dear I wanted to improve my solution but it seems even with your code its the same so I decided to use
options = psoptimset('SearchMethod',{@GPSPositiveBasis2N, @FP});
[y, fval] = ga(@FP,nvars, [],[],[],[],[],[],[],options)
is this option correct to use pattern search poll with ga ?, because it doesn't improve the solution also. Another thing using the hybrid make the ga running agian and that's takes along time so can I merge the two options and make it run for one time.
Many thanks,
Nadia
Alan Weiss
Alan Weiss 2015년 9월 21일
I would not use patternsearch with a search method, I would use a poll method only. And GPSPositiveBasis2N is the default poll method, so there is no reason to set it or to pass any other nondefault options to patternsearch.
I do not understand your question about the hybrid function causing ga to run multiple times. I believe that a hybrid function runs after ga terminates. Perhaps you were confused because you were using a search function for patternsearch, which I think you should not do.
Alan Weiss
MATLAB mathematical toolbox documentation

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Direct Search에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by