[HELP] fmincon to ga
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hi guys,
I have a o object function that i write for fmincon.
What should i change to minimize same object function by a ga(genetic algorithm) any tips,suggestions will be amazingly help me.
I explained the functions/problem/object (fitness) function better in comments below.
채택된 답변
Sean de Wolski
2012년 7월 31일
1 개 추천
You shouldn't have to change anything!
In fact you can use ga as the coarse minimization method and then use fmincon as a 'HybridFcn' for the finer tuned minimization after ga has gotten close.
doc gaoptimset
댓글 수: 10
E K
2012년 7월 31일
Thank you for your answer Sean,
but i call my optimization process by;
[x,fval,exitflag,output,lambda,grad,hessian] = ... fmincon(@(x) helper.objFcn(x,dimensions.R),x0,[],[],[],[],lb,ub,[],options);
as you know fmincon starts by initial points x0, so i am pretty lost in turning optimisation method to ga. should i use x0 as initial population? or do some weird stuff for ga.
I am really sorry if my question is silly. I am pretty new in both optimisation and ga.
Sean de Wolski
2012년 7월 31일
편집: Sean de Wolski
2012년 7월 31일
ga() will generate its own x0.
Sean de Wolski
2012년 7월 31일
You could give it an 'InitialPopulation' which I believe is the equivalent of x0.
Sorry to bother you guys (esspecially Sean) again but when i try to feed ga optimization tool like
[ x,fval,exitflag,output] = ...
ga(@(x) helper.objFcn(x,dimensions.R),70,[],[],[],[],lb,ub,[],options);
i cant get any solution, and get Optimization terminated: maximum number of generations exceeded.
even though i set maximum number of generations to 1000.
and fmincon manage to optimize the problem in just 38 iteration.
and when i try to feed initalpopulation with x0 (which are a vector of base station positions x1 y1 x2 y2 ....)
i get
Incorrect size of InitialPopulation
error
Sean de Wolski
2012년 7월 31일
So your objective function is a function of 70 variables? How good are your intial guesses. How big is what you are feeding for 'InitialPopulation'?
Hi again sean and thank for your patience and help. i am pretty lost in these optimisation processes.
i am pasting some codes to make a clear explanation
This is my setup/initial function (or where the problem begins) i got the parts of the code from an example.
%{
function [dim,lb,ub,x0] = celltowersetup(N,up,seed)
% CELLTOWERSETUP creates a randomly generated celltower problem.
% [dim,lb,ub,x0] = CELLTOWERSETUP(N, SIDE, SEED)
%
% Input:
% N : number of towers
% SIDE : length of the side of area
% SEED : random seed for initial cell location (integer)
% Output:
% dim.R : radius of cell tower coverage
% dim.xL : 0 % for plotting
% dim.xU : SIDE % for plotting
% dim.yL : 0 % for plotting
% dim.yU : SIDE % for plotting
% lb : lower bound values for x, y (based on the radius)
% ub : upper bound values for x, y (based on the radius)
% x0 : initial center points (x, y pairs)
low = 0;
st = RandStream('mcg16807', 'Seed', seed);
R = rand(st, N,1)+1; % allocate array
% Generate bound constraints
xL = low; xU = up;
yL = low; yU = up;
% 2*N variables in the order [x1,y1,x2,y2...,xn,yn]'
lb = zeros(2*N,1);
ub = lb;
lb(1:2:2*N) = xL + R;
lb(2:2:2*N) = yL + R;
ub(1:2:2*N) = xU - R;
ub(2:2:2*N) = yU - R;
% Random start point
x0 = up*rand(st, 2*N,1);
dim = struct('R', R, 'xL', xL, 'xU', xU, 'yL', yL, 'yU', yU);
}%
and my object function have the form of
f = objFcn(x, R)
which f is an integer , both x and R are vectors. where x are base station coordinates. R is their radius.
i am able to optimize the problem by using
[x,fval,exitflag,output,lambda,grad,hessian] = ...
fmincon(@(x) helper.objFcn(x,dimensions.R),x0,[],[],[],[],lb,ub,[],options);
and what i want to do is just optimize the problem by using ga.
Sean de Wolski
2012년 8월 1일
편집: Sean de Wolski
2012년 8월 1일
Well fmincon is using gradient information to help is converge quickly. ga does not have this luxury; it needs to breed and cull many generations in order to have a good solution evolve. However, it can handle things that fmincon can't for this reason.
You may wish to try using more generations, perhaps 10000. Genetic algorithms do require tuning in order to be effective. You may instead wish to change the 'EliteCount' so that more good candidates survive. This would especially be the case if you think you have a good starting point.
patternsearch might be another place to look as well.
E K
2012년 8월 1일
Yes sean you are right it took a lot more time and generations for GA to find the optimal solution. In the end it found a little bit solution with trade of time and more function calculation.
Thank you very much.
Sean de Wolski
2012년 8월 1일
This is why I suggest maybe using a 'HybridFcn'. Let ga find the valley that contains the global minimum and then use fmincon to hone in on the minimum of this valley really quickly.
Nouhaila Lazaar
2020년 11월 3일
Hello,
I want to do the same thing, have you managed to do it? Actually, when I use ga, the program doesn't find a feasible point, I couldn't solve the problem. Can you please tell me what options I can use to solve my problem? Any suggestion will be helpful.
Thank you in advance,
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Genetic Algorithm에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
