surf can not be drawn/how triple objective function is written in same page with ga solver?
Show older comments
I define this triple objective function in separate sheet ,but how I can define this with ga solver in same sheet?
%%%%%multiobjective(triple) optimization problems
function Z= tripleobjectivefunction(x,y)
f1 = 0.5.*(x.^2+y.^2) +sin(x.^2+y.^2);
f2 =((3.*x-2.*y+4).^2./8)+((x-y+1).^2)/27+15;
f3 =1/(x.^2+y.^2+1)-1.1.*exp(-(x.^2+y.^2));
Z=[f1,f2,f3];
end
I want to have surf but this is not possible since the function Z is unrecognized.
clc;
clear all;
close all;
nvars = 2;
lb = [-3 -3];
ub = [3 3];
%initial population
%crossover and mutation
options=optimoptions("gamultiobj",'InitialPopulationRange',[1;100],"PopulationSize",50,"MaxGenerations",100,"MaxStallGenerations",100,"FunctionTolerance",1e-4,"MutationFcn",{@mutationadaptfeasible,2},"CrossoverFcn",{@crossoverintermediate, 2},"PlotFcn",{@gaplotpareto ,@gaplotselection ,@gaplotbestf});
[x,fval,exitflag,output,population,score] = gamultiobj(@(x) tripleobjectivefunction(x(1),x(2)),nvars,[],[],[],[],lb,ub,[],options);
optimal_solution = x;
objective_functions = fval;
figure(1)
hold on
box on
plot3(fval(:,1),fval(:,2),fval(:,3),'mo')
figure(2)
[X,Y]=meshgrid(x,fval);
surf(X,Y,length(Z),'FaceAlpha',0.5)
hold off
1 Comment
sogol bandekian
on 27 May 2022
Accepted Answer
More Answers (0)
Categories
Find more on Solver-Based Optimization Problem Setup in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


