% % Written by: % -- % John L. Weatherwax 2006-08-28 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- clear; close all; %clc; addpath('../Chapter3'); % get our continous genetic algorithm % Parameters used in the genetic algorithm % N_pop = 300; % the population size X_rate = 0.5; % selection rate mu = 0.02; % the mutation rate max_number_of_iterations = 20; % method to select mates: % 1=> pairing from top to bottom % 2=> random pairing % 3=> random pairing (rank weighting) % 4=> weighted random pairing (cost weighting) % 5=> tournament selection % parent_selection_method = 3; % method used to do crossover: % 1=> single point crossover % 2=> double point crossover % 3=> uniform crossover % 4=> blending method (3.9) % 5=> blending method (3.13) or the books suggested method % crossover_method = 5; % extract points on the pareto front: % x_pareto = []; wArray = 0.1:0.1:0.9; bounds = [ 1., +2 ; 1, +2 ; 1., +2 ; 1, +2 ]; % the objective functions input domain for ii = 1:length(wArray) disp( ['finding optimum of blended function with w= ', num2str(wArray(ii)) ] ); wfn = @(x) chap_5_prob_2_scaled_fn(x, wArray(ii)); [pop,pop_costs,best_fn_values,avg_fn_values] = continuous_GA( wfn, bounds, N_pop, X_rate, mu, max_number_of_iterations, parent_selection_method, crossover_method ); x_pareto = [ x_pareto; pop(1,:) ]; % extract the best solution found for each w value: end Fs = chap_5_prob_2_original_fns(x_pareto); % evaluate the raw function at the optimal points (f_1(x^*),f_2(x^*)): figure; ph_prob_2 = plot( Fs(:,1), Fs(:,2), '.-b', 'linewidth', 3 ); xlabel('objective function f_1'); ylabel('objective function f_2'); title('pareto front');