kindly solve the error' index at position 1 exceedes the array bounds

조회 수: 2 (최근 30일)
Preeti Panchta
Preeti Panchta 2022년 9월 20일
편집: KSSV 2022년 9월 20일
function Output = multi_objective_function(Input)
x(1) = Input(1); % variable 1
x(2) = Input(2); % variable 2
x(3) = Input(2); % variable 3
x(4) = Input(2); % variable 4
F1 = 84718*x(1)+72627.42*x(2)+41021.98*x(3)+58077.44*x(4); % objective 1
F2 = -1124.424*x(1)-1004.247*x(2)-8.40858*x(3)-10.52292*x(4); % objective 2
F3 = -51.524*x(1)-47.666*x(2)-19.136*x(3)-19.134*x(4); % objective 3
Output = [F1 F2 F3];
function [x,fval,exitflag,output,population,score] = multi_objective_genetic_algorithm_solver(nvars,Aeq,beq,Aineq,bineq,lb,ub,PopulationSize_Data,MaxGenerations_Data,MaxStallGenerations_Data,FunctionTolerance_Data,ConstraintTolerance_Data)
options = optimoptions('gamultiobj');
options = optimoptions(options,'PopulationSize', PopulationSize_Data);
options = optimoptions(options,'MaxGenerations', MaxGenerations_Data);
options = optimoptions(options,'MaxStallGenerations', MaxStallGenerations_Data);
options = optimoptions(options,'FunctionTolerance', FunctionTolerance_Data);
options = optimoptions(options,'ConstraintTolerance', ConstraintTolerance_Data);
options = optimoptions(options,'CrossoverFcn', { @crossoverintermediate [] });
options = optimoptions(options,'Display', 'off');
[x,fval,exitflag,output,population,score] = ...
gamultiobj(@multi_objective_function,nvars,[],[],Aineq,bineq,[],[],[],options);
clc
clear
close all
nvars = 4;
Aineq =[1 1 1 1; 220.086 210.356 92.672 135.994; 464.75 203.194 261.548 206.638];
bineq = [49.9; 660; 1136];
PopulationSize_Data = 500;
MaxGenerations_Data = 100;
MaxStallGenerations_Data = 100;
FunctionTolerance_Data = 0;
ConstraintTolerance_Data = 0;
[x,fval,exitflag,output,population,score] = multi_objective_genetic_algorithm_solver(nvars,[],[],Aineq,bineq,[],[],PopulationSize_Data,MaxGenerations_Data,MaxStallGenerations_Data,FunctionTolerance_Data,ConstraintTolerance_Data);
optimal_solution = x;
objective_functions = fval;
plot3(fval(1,:),fval(2,:),fval(3,:),'o')

답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by