How can I do this example?
Show older comments
Now, I want to solve Multi-objective problem. So I found this example. URL : https://kr.mathworks.com/help/optim/ug/generate-and-plot-a-pareto-front.html
But I cannot solve the example. I want to second method for Plot a Pareto Front. I operate the function.
#1.function f = simple_mult(x)
f(:,1) = sqrt(1+x.^2);
f(:,2) = 4 + 2*sqrt(1+(x-1).^2);
#2.function z = pickindex(x,k)
z = simple_mult(x); % evaluate both objectives
z = z(k); % return objective k
#3.k = 1;
[min1,minfn1] = fminbnd(@(x)pickindex(x,k),-1,2);
k = 2;
[min2,minfn2] = fminbnd(@(x)pickindex(x,k),-1,2);
goal = [minfn1,minfn2];
nf = 2; % number of objective functions
N = 50; % number of points for plotting
onen = 1/N;
x = zeros(N+1,1);
f = zeros(N+1,nf);
fun = @simple_mult;
x0 = 0.5;
options = optimoptions('fgoalattain','Display','off');
for r = 0:N
t = onen*r; % 0 through 1
weight = [t,1-t];
[x(r+1,:),f(r+1,:)] = fgoalattain(fun,x0,goal,weight,...
[],[],[],[],[],[],[],options);
end
figure
plot(f(:,1),f(:,2),'k.');
xlabel('f_1')
ylabel('f_2')
I create 3 script. And insert #1, #2, #3. and then operation. But cannot operating. XD;;
1 Comment
Learning Student
on 23 May 2018
Answers (0)
Categories
Find more on Develop Apps Using App Designer 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!