필터 지우기
필터 지우기

GA optimisation how to find maxima instad of minima.

조회 수: 3 (최근 30일)
BioZ
BioZ 2021년 11월 18일
댓글: Jan 2021년 11월 18일
Greetings, I have the following code;
I use "ga" of Global Optimisation Toolbox and it works.
My only problem here is that the ga is trying to find the minima where as I want to find the maxima. How can I set the ga optimisation to find the maxima of y(1) ?
(The only way I found is to put a minus in the y(1) equation.)
SquareF.m
function y = SquareF(x)
%y(1) = (x+2)^2 - 10;
Lt = 10; %Total Length
A = Lt*x; % Side A
B = Lt-A; % Side B
y(1) = A*B;
rL = A+B;
end
Optim.m
clc; clear all; close all
FitnessFunction = @SquareF;
numberOfVariables = 1;
A = []; b = [];
Aeq = []; beq = [];
lb = 0;
ub = 1;
options = optimoptions(@ga,'PlotFcn',{@gaplotpareto,@gaplotscorediversity});
[x,Volume] = ga(FitnessFunction,numberOfVariables,A,b,Aeq,beq,lb,ub)

채택된 답변

Jan
Jan 2021년 11월 18일
(The only way I found is to put a minus in the y(1) equation.)
This is the perfect solution already.
  댓글 수: 2
BioZ
BioZ 2021년 11월 18일
Ok, I thought perhaps there was an option that would dictate ga function to find minama or maxima.
Jan
Jan 2021년 11월 18일
All optimizers are minimizers. This is a convention without a deeper meaning. Changing the sign of the cost function is a cheap solution - equivalent to cups for left-handers.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by