function [InitFunction, MainLevel, SubLevel, FeasibleTest] = SpeedReducer
InitFunction = @SpeedReducerInit;
MainLevel = @SpeedReducerMainLevel;
SubLevel = @SpeedReducerSubSystem;
return
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [Population, OPTIONS, Result] = SpeedReducerInit(OPTIONS)
% Define the range of different
% Range = [2.6, 3.6; 0.7, 0.8; 17 28; 7.3 8.3; 7.3, 8.3; 2.9, 3.9; 5.0, 5.5];
Range = [0, 10; 0, 5; 1 100; 5 10; 1, 20; 1, 20; 1, 10];
NumSubsystem = 5;
ParameterSubsystem = {[1, 2, 3, 4, 6] [1, 2, 3, 5, 7] [1, 2, 3] [2, 3, 4, 6] [2, 3, 5, 7]};
% Initialize population
for SubSystemIndex = 1:NumSubsystem
ParameterInUse = ParameterSubsystem{SubSystemIndex};
Population1 = [];
for popindex = 1 : OPTIONS.popsize
chrom = (Range(ParameterInUse,2) - Range(ParameterInUse,1))'.*rand(1,length(ParameterInUse)) + Range(ParameterInUse,1)';
Population1(popindex).chrom = chrom;
Population1(popindex).SubSystemID = SubSystemIndex;
end
Population{SubSystemIndex} = Population1;
end
SetPoint = (Range(:,2) - Range(:,1))'.*rand(1,length(Range(:,1))) + Range(:,1)';
OPTIONS.OrderDependent = false;
OPTIONS.ParameterSubystem = ParameterSubsystem;
OPTIONS.Range = Range;
OPTIONS.SetPoint = SetPoint;
OPTIONS.InitialIndicator = 1;
OPTIONS.StopIndicator = 0;
OPTIONS.ParameterSubsystem = ParameterSubsystem;
OPTIONS.NumSubsystem = NumSubsystem;
Result = [];
return
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [Result, OPTIONS] = SpeedReducerMainLevel(OPTIONS, Result)
% Compute the cost of each member in Population
global CostCall;
if OPTIONS.InitialIndicator == 1
Result.Main(1) = 0.7854 * OPTIONS.SetPoint(1) * OPTIONS.SetPoint(2)^2 * (3.3333*OPTIONS.SetPoint(3)^2 + 14.9334*OPTIONS.SetPoint(3) - 43.0934) - ...
1.5079 * OPTIONS.SetPoint(1) * (OPTIONS.SetPoint(6)^2 + OPTIONS.SetPoint(7)^2) + 7.477 * (OPTIONS.SetPoint(6)^3 + OPTIONS.SetPoint(7)^3) + ...
0.7854 * (OPTIONS.SetPoint(4) * OPTIONS.SetPoint(6)^2 + OPTIONS.SetPoint(5) * OPTIONS.SetPoint(7)^2);
Result.Main(2) = sqrt((745*OPTIONS.SetPoint(4)/(OPTIONS.SetPoint(2)*OPTIONS.SetPoint(3)))^2 + 1.69*10^7) / (0.1*OPTIONS.SetPoint(6)^3);
Result.Main(3) =sqrt((745*OPTIONS.SetPoint(5)/(OPTIONS.SetPoint(2)*OPTIONS.SetPoint(3)))^2 + 1.575*10^7) / (0.1*OPTIONS.SetPoint(7)^3) ;
CostCall = CostCall + 3;
Result.Chrom = OPTIONS.SetPoint;
Result.FeasibleIndicator = SpeedReducerFeasibleTest(Result.Chrom);
OPTIONS.InitialIndicator = 0;
else
TempChrom1 = [Result.SubSystem1.chrom(1), Result.SubSystem2.chrom(1), Result.SubSystem3.chrom(1)];
TempChrom2 = [Result.SubSystem1.chrom(2), Result.SubSystem2.chrom(2), Result.SubSystem3.chrom(2), Result.SubSystem4.chrom(1), Result.SubSystem5.chrom(1)];
TempChrom3 = [Result.SubSystem1.chrom(3), Result.SubSystem2.chrom(3), Result.SubSystem3.chrom(3), Result.SubSystem4.chrom(2), Result.SubSystem5.chrom(2)];
TempChrom4 = [Result.SubSystem1.chrom(4), Result.SubSystem4.chrom(3)];
TempChrom5 = [Result.SubSystem2.chrom(4), Result.SubSystem5.chrom(3)];
TempChrom6 = [Result.SubSystem1.chrom(5), Result.SubSystem4.chrom(4)];
TempChrom7 = [Result.SubSystem2.chrom(5), Result.SubSystem5.chrom(4)];
for t1 = 1:numel(TempChrom1)
for t2 = 1:numel(TempChrom2)
for t3 = 1:numel(TempChrom3)
for t4 = 1:numel(TempChrom4)
for t5 = 1:numel(TempChrom5)
for t6 = 1:numel(TempChrom6)
for t7 = 1:numel(TempChrom7)
TempChrom = [TempChrom1(t1), TempChrom2(t2), TempChrom3(t3), TempChrom4(t4), TempChrom5(t5), TempChrom6(t6), TempChrom7(t7)];
TempResult(1) = 0.7854 * TempChrom(1) * TempChrom(2)^2 * (3.3333*TempChrom(3)^2 + 14.9334*TempChrom(3) - 43.0934) - ...
1.5079 * TempChrom(1) * (TempChrom(6)^2 + TempChrom(7)^2) + 7.477 * (TempChrom(6)^3 + TempChrom(7)^3) + ...
0.7854 * (TempChrom(4) * TempChrom(6)^2 + TempChrom(5) * TempChrom(7)^2);
TempResult(2) = sqrt((745*TempChrom(4)/(TempChrom(2)*TempChrom(3)))^2 + 1.69*10^7) / (0.1*TempChrom(6)^3);
TempResult(3) = sqrt((745*TempChrom(5)/(TempChrom(2)*TempChrom(3)))^2 + 1.575*10^8) / (0.1*TempChrom(7)^3);
CostCall = CostCall + 3;
if ~exist('ChromSave')
ChromSave = TempChrom;
ResultSave = TempResult;
FeasibleIndicator = SpeedReducerFeasibleTest(TempChrom);
else
TempFeasibleIndicator = SpeedReducerFeasibleTest(TempChrom);
if TempFeasibleIndicator <= FeasibleIndicator
if FeasibleIndicator == TempFeasibleIndicator
NumIndex = 0;
for t8 = 1:numel(ResultSave)
if TempResult(t8) < ResultSave(t8)
NumIndex = NumIndex + 1;
end
end
if NumIndex > numel(ResultSave)/2
ChromSave = TempChrom;
ResultSave = TempResult;
FeasibleIndicator = TempFeasibleIndicator;
end
else
ChromSave = TempChrom;
ResultSave = TempResult;
FeasibleIndicator = TempFeasibleIndicator;
end
end
end
end
end
end
end
end
end
end
Result.Chrom = ChromSave;
Result.FeasibleIndicator = FeasibleIndicator;
Result.Main = ResultSave;
OPTIONS.SetPoint = ChromSave;
end
return
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [FeasibleIndicator] = SpeedReducerFeasibleTest(Chrom)
FeasibleIndicator = 0;
if 27 / (Chrom(1) * Chrom(2)^2 * Chrom(3)) - 1 > 0
FeasibleIndicator = FeasibleIndicator + 1;
end
if 397.5 / (Chrom(1)*Chrom(2)^2*Chrom(3)^2) - 1 > 0
FeasibleIndicator = FeasibleIndicator + 1;
end
if 1.93*Chrom(4)^3 / (Chrom(2)*Chrom(3)*Chrom(6)^4) - 1 > 0
FeasibleIndicator = FeasibleIndicator + 1;
end
if 1.93*Chrom(5)^3 / (Chrom(2)*Chrom(3)*Chrom(7)^4) - 1 > 0
FeasibleIndicator = FeasibleIndicator + 1;
end
if sqrt((745*Chrom(4)/(Chrom(2)*Chrom(3)))^2 + 1.69*10^7) / (0.1*Chrom(6)^3) - 1100 > 0
FeasibleIndicator = FeasibleIndicator + 1;
end
if sqrt((745*Chrom(5)/(Chrom(2)*Chrom(3)))^2 + 1.575*10^8) / (0.1*Chrom(7)^3) - 850 > 0
FeasibleIndicator = FeasibleIndicator + 1;
end
if Chrom(2) * Chrom(3) - 40 > 0
FeasibleIndicator = FeasibleIndicator + 1;
end
if Chrom(1) / Chrom(2) - 12 > 0
FeasibleIndicator = FeasibleIndicator + 1;
end
if -Chrom(1) / Chrom(2) + 4 > 0
FeasibleIndicator = FeasibleIndicator + 1;
end
if (1.5 * Chrom(6) + 1.9) / Chrom(4) - 1 > 0
FeasibleIndicator = Fe