请教遗传算法优化离散变量
程序代码:
目标函数: function f=litifun(x) x =[14 23 0.6 29.33 12 13]; a=4.75*x(1)*x(2)*x(2)*x(3)*x(3); b=85*x(1)*x(2)*x(3)*x(3); c=85*x(1)*x(3)*x(3); d=0.92*x(1)*x(6)*x(6); e=x(1)*x(5)*x(5); f=0.8*x(1)*x(2)*x(3)*x(6); h=1.6*x(1)*x(3)*x(6); k=x(4)*x(5)*(5); w=x(4)*x(6)*x(6); f=0.78539815*(a+b-c+d-e+f-h+k+w+28*x(5)*x(5)+32*x(6)*x(6)); 约束条件: function [c,ceq]=lifun(x) c(1)=17-x(2); c(2)=x(2)*x(3)-30; c(3)=0.2-x(3); c(4)=16-x(1)/x(3); c(5)=x(1)/x(3)-35; c(6)=10-x(5); c(7)=x(5)-15; c(8)=13-x(6); c(9)=x(6)-20; c(10)=x(1)+0.5*x(6)-x(4)+4; c(11)=43854/(x(2)*x(3)*sqrt(x(1)))-855; c(12)=7098/(x(1)*x(2)*x(3)^2*(0.169+0.006666*x(2)-0.0000854*x(2)^2))-261; c(13)=7098/(x(1)*x(2)*x(3)^2*(0.169+0.00177*x(2)-0.0000394*x(2)^2))-213; c(14)=0.01233*x(4)^3/(x(2)*x(3)*x(5)^4)-0.003*x(4); c(15)=29050*x(4)*sqrt(1+0.29709*x(2)^2*x(3)^2/x(4)^2)/(x(2)*x(3)*x(5)^3)-55; c(16)=29050*x(4)*sqrt(1+0.29709*x(2)^2*x(3)^2/x(4)^2)/(x(2)*x(3)*x(6)^3)-55; ceq=[]; 输入函数: ObjectiveFunction = @litifun; nvars = 6; % Number of variables x=[0.5 20 0.6 30 12 15]; lb=[5 17 0.3 3 10 13]; ub=[40 100 2 50 15 20]; [c,ceq]=lifun(x) ConstraintFunction = @lifun; options=gaoptimset( 'PopulationSize',200,'Generations',200, 'CrossoverFraction',0.7 ,'MigrationFraction',0.01,'PopInitRange',[0;120],'InitialPopulation',x,'Display','iter'); [x,fval]=ga(ObjectiveFunction,nvars,[],[],[],[],lb,ub,ConstraintFunction,options) 怎样修改才能使得怎样修改才能使得X1取(5 40)之间的正整数,X2取(17 100)之间的正整数,X3只在(0.3,0.35,0.4,0.5,0.6,0.8,0.9,1,1.25,1.5,1.75,2)这些数中取值,X4、X5、X6不限