mono- objective optimization and multiopjective optimisation, I would like to use GA with option but there is a fault that I can't to resolve

조회 수: 3 (최근 30일)
objective = @(x) 1.002 - ((1 - exp(-0.00003 * x)) ./ (0.00003 * (x + 1.5) + 0.00063 * (1 - exp(-0.00003 * x))));
[a,b]=[24:720];
options = optimoptions('ga', 'PopulationSize', 50, 'MaxGenerations', 100, 'Display', 'iter');
[x_opt, fval] = ga(objective, 1, [], [], [], [], a, b, [], options);
disp('Résultat optimal :');
the results are:
??? Undefined function or method 'optimoptions' for input arguments of type 'char'.
Error in ==> obj_1 at 10
options = optimoptions('ga', 'PopulationSize', 50, 'MaxGenerations', 100, 'Display', 'iter');

답변 (2개)

Torsten
Torsten 2025년 1월 15일
이동: Torsten 2025년 1월 15일
You mean
objective = @(x) 1.002 - ((1 - exp(-0.00003 * x)) ./ (0.00003 * (x + 1.5) + 0.00063 * (1 - exp(-0.00003 * x))));
a = 24;
b = 720;
%[a,b]=[24:720];
options = optimoptions(@ga, 'PopulationSize', 50, 'MaxGenerations', 100, 'Display', 'iter');
%options = optimoptions('ga', 'PopulationSize', 50, 'MaxGenerations', 100, 'Display', 'iter');
[x_opt, fval] = ga(objective, 1, [], [], [], [], a, b, [], options)
Single objective optimization: 1 Variables Options: CreationFcn: @gacreationuniform CrossoverFcn: @crossoverscattered SelectionFcn: @selectionstochunif MutationFcn: @mutationadaptfeasible Best Mean Stall Generation Func-count f(x) f(x) Generations 1 100 0.01208 0.01488 0 2 147 0.01208 0.01327 0 3 194 0.01208 0.0131 0 4 241 0.01208 0.01302 0 5 288 0.01208 0.0126 1 6 335 0.01208 0.0121 0 7 382 0.01207 0.01208 0 8 429 0.01207 0.01208 1 9 476 0.01207 0.01208 2 10 523 0.01207 0.01208 0 11 570 0.01207 0.01207 0 12 617 0.01207 0.01207 0 13 664 0.01207 0.01207 1 14 711 0.01207 0.01207 0 15 758 0.01207 0.01207 1 16 805 0.01207 0.01207 0 17 852 0.01207 0.01207 0 18 899 0.01206 0.01207 0 19 946 0.01206 0.01207 1 20 993 0.01206 0.01207 2 21 1040 0.01206 0.01207 0 22 1087 0.01206 0.01207 0 23 1134 0.01206 0.01207 0 24 1181 0.01206 0.01206 0 25 1228 0.01206 0.01206 0 26 1275 0.01206 0.01206 0 27 1322 0.01206 0.01206 1 28 1369 0.01206 0.01206 0 29 1416 0.01206 0.01206 1 30 1463 0.01206 0.01206 2 Best Mean Stall Generation Func-count f(x) f(x) Generations 31 1510 0.01206 0.01206 0 32 1557 0.01206 0.01206 0 33 1604 0.01206 0.01206 0 34 1651 0.01206 0.01206 1 35 1698 0.01206 0.01206 0 36 1745 0.01205 0.01206 0 37 1792 0.01205 0.01206 0 38 1839 0.01205 0.01206 0 39 1886 0.01205 0.01205 1 40 1933 0.01205 0.01205 0 41 1980 0.01205 0.01205 0 42 2027 0.01205 0.01205 0 43 2074 0.01205 0.01205 0 44 2121 0.01205 0.01205 0 45 2168 0.01205 0.01205 1 46 2215 0.01205 0.01205 0 47 2262 0.01205 0.01205 0 48 2309 0.01205 0.01205 0 49 2356 0.01205 0.01205 0 50 2403 0.01205 0.01205 0 51 2450 0.01205 0.01205 0 ga stopped because the average change in the fitness value is less than options.FunctionTolerance.
x_opt = 322.6320
fval = 0.0120
?
  댓글 수: 4
dal
dal 2025년 1월 17일
good morning I have Matlab 2009a
if type optimoptions, the answer is:
??? Undefined function or variable 'optimoptions'.

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


Walter Roberson
Walter Roberson 2025년 1월 15일

You do not have the Optimization Toolbox installed, and you do not have the Global Optimization Toolbox installed.

You probably do not have them licensed either.

  댓글 수: 2
dal
dal 2025년 1월 15일
if I use this Editod:
function y=obj1(x)
a=1-exp(-0.00003*x);
b=0.00003*(x+1.5);
c=0.00063*a;
d=b+c;
e=a/d;
f=1.002;
y=f-e;
% command window:
[x y]=ga(@obj_dal,1,[],[],[],[],24,720)
% résults:
x=315.25
y=0.0121
but I need use options in order to change populations
Walter Roberson
Walter Roberson 2025년 1월 15일
optimoptions requires R2013a or later. Perhaps you are using an earlier release?

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

카테고리

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