Getting error " 'ga' requires Global Optimization Toolbox'' while running the global optimization command for a stalagmite function.
11 次查看(过去 30 天)
显示 更早的评论
clear all
close all
clc
%inputs
x = linspace(0,0.6,150);
y = linspace(0,0.6,150);
[xx, yy] = meshgrid(x,y);
for i = 1:length(xx)
for j = 1:length(yy)
vector(1) = xx(i,j);
vector(2) = yy(i,j);
f(i,j)= stalagmite(vector);
end
end
num_case = 50;
tic
%study_1 - Satistical behaviour
for i = 1:num_case
[inputs, fopt(i)] = ga(@stalagmite, 2);
xopt(i) = inputs(1);
yopt(i) = inputs(2);
end
study1_time = toc
figure(1)
subplot(2,1,1)
hold on
surfc(x,y,f)
shading interp
plot3(xopt,yopt,fopt,'marker','o','markersize',5,'markerfacecolor','r')
title('unbound inputs')
subplot(2,1,2)
plot(fopt)
xlabel('iteations')
ylabel('No of functions')
when i run this code i am getting the error as 'ga' requires Global Optimization Toolbox.
0 个评论
回答(1 个)
Walter Roberson
2021-11-23
The message is correct. The function ga() is part of the Global Optimization Toolbox. You need to have the Global Optimization Toolbox installed and licensed in order to use Mathwork's ga() function.
ga() is not part of basic MATLAB.
[If I recall correctly, the Global Optimization Toolbox requires that you have the Optimization Toolbox installed and licensed.)
2 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!