here is the code for moema tested on zdt1 problem, can you try to test it on CEC 2009? %…
- User
here is the code for moema tested on zdt1 problem, can you try to test it on CEC 2009?
% MOEMA optimization % Main script to run MOEMA optimization clc; clear; close all; % Set problem parameters NPop = 100; % Population size T = 200; % Number of iterations dim = 30; % Number of decision variables lb = zeros(1, dim); % Lower bound ub = ones(1, dim); % Upper bound
% Run MOEMA [paretoFront, paretoSet, Trajectories, fitness_history, position_history] = MOEMA(NPop, T, lb, ub, dim, @zdt1);
% Plot the Pareto front figure; plot(paretoFront(:,1), paretoFront(:,2), 'ro'); xlabel('f1'); ylabel('f2'); title('Pareto Front for ZDT1 using MOEMA');
% Calculate and display metrics disp(['Number of solutions in Pareto Front: ', num2str(size(paretoFront, 1))]); disp(['Minimum f1: ', num2str(min(paretoFront(:,1)))]); disp(['Minimum f2: ', num2str(min(paretoFront(:,2)))]);
% Plot the convergence of the Pareto front figure; for i = 1:T front = squeeze(fitness_history(:,i,:)); [~, unique_idx] = unique(front, 'rows'); front = front(unique_idx,:); plot(front(:,1), front(:,2), 'bo', 'MarkerSize', 2); xlabel('f1'); ylabel('f2'); title(['Pareto Front Evolution at Iteration ', num2str(i)]); xlim([0 1]); ylim([0 1]); drawnow; pause(0.05); end
% Plot the trajectory of a random solution figure; plot(1:T, Trajectories(1,:)); xlabel('Iteration'); ylabel('x1 value'); title('Trajectory of x1 for a Random Non-dominated Solution');
function [paretoFront, paretoSet, Trajectories, fitness_history, position_history] = MOEMA(NPop, T, lb, ub, dim, FITNESSFCN) % Multi-Objective Evolutionary Mating Algorithm (MOEMA) % MOEMA attempts to solve multi-objective problems of the following form: % min F(X) = [f1(X), f2(X), ..., fm(X)] subject to: lb <= X <= ub %
% FITNESSFCN - function handle of the multi-objective fitness function % lb - lower bounds on X % ub - upper bounds on X % T - number of iterations % NPop - size of the population (class size)
% paretoFront - set of non-dominated solutions in objective space % paretoSet - set of non-dominated solutions in decision space % Trajectories - best solution trajectory over iterations % fitness_history - history of fitness values % position_history - history of population positions% Preallocation fitness_history = zeros(NPop, T, 2); % Assuming 2 objectives position_history = zeros(NPop, T, dim); Trajectories = zeros(dim, T);
% Generation of initial population pop = initialization(NPop, dim, ub, lb); pop_dad = pop(1:NPop/2, :); % Eqn (1) in the paper pop_mum = pop(NPop/2+1:end, :); % Eqn (2) in the paper
% Evaluation of objective function for initialization obj_dad = evaluate_population(pop_dad, FITNESSFCN); obj_mum = evaluate_population(pop_mum, FITNESSFCN); obj = [obj_dad; obj_mum];
% Initialize archive with non-dominated solutions archive = update_archive([], [], pop, obj);
- Assistant
- User
here is uf1 problem. now try it on my moema code. please show full code
classdef UF1 < PROBLEM % <large/none> % Unconstrained benchmark MOP %------------------------------- Reference -------------------------------- % Q. Zhang, A. Zhou, S. Zhao, P. N. Suganthan, W. Liu, and S. Tiwari, % Multiobjective optimization test instances for the CEC 2009 special % session and competition, School of CS & EE, University of Essex, Working % Report CES-487, 2009. %------------------------------- Copyright -------------------------------- % Copyright (c) 2024 BIMK Group. You are free to use the PlatEMO for % research purposes. All publications which use this platform or any code % in the platform should acknowledge the use of "PlatEMO" and reference "Ye % Tian, Ran Cheng, Xingyi Zhang, and Yaochu Jin, PlatEMO: A MATLAB platform % for evolutionary multi-objective optimization [educational forum], IEEE % Computational Intelligence Magazine, 2017, 12(4): 73-87". %-------------------------------------------------------------------------- methods %% Default settings of the problem function Setting(obj) obj.M = 2; if isempty(obj.D); obj.D = 30; end obj.lower = [0,zeros(1,obj.D-1)-1]; obj.upper = ones(1,obj.D); obj.encoding = ones(1,obj.D); end %% Calculate objective values function PopObj = CalObj(obj,X) J1 = 3 : 2 : obj.D; J2 = 2 : 2 : obj.D; Y = X - sin(6repmat(X(:,1),1,obj.D)+repmat(1:obj.D,size(X,1),1)mean(Y(:,J1).^2,2); PopObj(:,2) = 1-sqrt(X(:,1)) + 2*mean(Y(:,J2).^2,2); end %% Generate points on the Pareto front function R = GetOptimum(obj,N) R(:,1) = linspace(0,1,N)'; R(:,2) = 1 - R(:,1).^0.5; end %% Generate the image of Pareto front function R = GetPF(obj) R = obj.GetOptimum(100); end end end
- Assistant