Borrar filtros
Borrar filtros

Getting error " 'ga' requires Global Optimization Toolbox'' while running the global optimization command for a stalagmite function.

20 visualizaciones (últimos 30 días)
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.

Respuestas (1)

Walter Roberson
Walter Roberson el 23 de Nov. de 2021
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.)

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by