can you try on zdt4? if yes give me full code clc; clear; close all; % Problem…
Rate quality
Private research annotation
Sign in to add a private research label or note.
- User
can you try on zdt4? if yes give me full code clc; clear; close all;
% Problem parameters dim = 30; lb = zeros(1, dim); ub = ones(1, dim);
% Run MOEMA NPop_MOEMA = 50; T_MOEMA = 200; [paretoFront_MOEMA, ~] = MOEMA(NPop_MOEMA, T_MOEMA, lb, ub, dim, @zdt2);
% Run NSGA-II NPop_NSGA2 = 50; T_NSGA2 = 200; [paretoFront_NSGA2, ~] = NSGA2(NPop_NSGA2, T_NSGA2, lb, ub, dim);
% True Pareto front x1 = linspace(0, 1, 100); true_pareto_front = [x1', 1 - (x1.^2)'];
% Reference point for hypervolume calculation reference_point = [1.1, 1.1];
% Calculate metrics for MOEMA gd_MOEMA = calculate_gd(paretoFront_MOEMA, true_pareto_front); spread_MOEMA = calculate_spread(paretoFront_MOEMA); hv_MOEMA = calculate_hypervolume(paretoFront_MOEMA, reference_point); convergence_MOEMA = calculate_convergence(paretoFront_MOEMA, true_pareto_front);
% Calculate metrics for NSGA-II gd_NSGA2 = calculate_gd(paretoFront_NSGA2, true_pareto_front); spread_NSGA2 = calculate_spread(paretoFront_NSGA2); hv_NSGA2 = calculate_hypervolume(paretoFront_NSGA2, reference_point); convergence_NSGA2 = calculate_convergence(paretoFront_NSGA2, true_pareto_front);
% Display Comparison disp('Comparison Table:'); disp('-----------------------------------------------------------'); disp('| Metric | MOEMA | NSGA-II |'); disp('-----------------------------------------------------------'); fprintf('| GD | %-14.4f | %-14.4f |\n', gd_MOEMA, gd_NSGA2); fprintf('| Spread | %-14.4f | %-14.4f |\n', spread_MOEMA, spread_NSGA2); fprintf('| Hypervolume | %-14.4f | %-14.4f |\n', hv_MOEMA, hv_NSGA2); fprintf('| Convergence | %-14.4f | %-14.4f |\n', convergence_MOEMA, convergence_NSGA2); disp('-----------------------------------------------------------');
% Plotting Results figure; plot(paretoFront_MOEMA(:,1), paretoFront_MOEMA(:,2), 'ro', 'DisplayName', 'MOEMA'); hold on; plot(paretoFront_NSGA2(:,1), paretoFront_NSGA2(:,2), 'bo', 'DisplayName', 'NSGA-II'); plot(true_pareto_front(:,1), true_pareto_front(:,2), 'k-', 'DisplayName', 'True Pareto Front'); xlabel('f1'); ylabel('f2'); title('Comparison of MOEMA and NSGA-II on zdt2'); legend('show'); grid on;
% Plotting Results figure;
% MOEMA vs True Pareto Front subplot(1, 2, 1); % 1 row, 2 columns, first plot plot(paretoFront_MOEMA(:,1), paretoFront_MOEMA(:,2), 'ro', 'DisplayName', 'MOEMA'); hold on; plot(true_pareto_front(:,1), true_pareto_front(:,2), 'k-', 'DisplayName', 'True Pareto Front'); xlabel('f1'); ylabel('f2'); title('MOEMA vs True Pareto Front for zdt2'); legend('show'); grid on;
% NSGA-II vs True Pareto Front subplot(1, 2, 2); % 1 row, 2 columns, second plot plot(paretoFront_NSGA2(:,1), paretoFront_NSGA2(:,2), 'bo', 'DisplayName', 'NSGA-II'); hold on; plot(true_pareto_front(:,1), true_pareto_front(:,2), 'k-', 'DisplayName', 'True Pareto Front'); xlabel('f1'); ylabel('f2'); title('NSGA-II vs True Pareto Front for zdt2'); legend('show'); grid on;
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.