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

1 view (last 30 days)
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');

Answers (2)

Torsten
Torsten on 15 Jan 2025
Moved: Torsten on 15 Jan 2025
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 Comments
dal
dal on 17 Jan 2025
good morning I have Matlab 2009a
if type optimoptions, the answer is:
??? Undefined function or variable 'optimoptions'.

Sign in to comment.


Walter Roberson
Walter Roberson on 15 Jan 2025

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 Comments
dal
dal on 15 Jan 2025
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

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!