x1=sol(1); matlab里面总是提示这里有错误,哪位大侠看看,帮忙检查错误...
function[sol,eval]=f552(sol,options)x1=sol(1);x2=sol(2);r1=0.1;r2=0.8;%约束条件g1=x1-2*x2+1;g2=x1.^2\/4-x2.^2+1;%加惩罚项的适值if(g1>=0)&(g2>=0)eval=(x1-2).^2+(x2-1).^2;el...function [sol,eval]=f552(sol,options)x1=sol(1);x2=sol(2);r1=0.1;r2=0...
matlab遗传算法优化中总是出现Input argument "sol" is undefined._百度...
首先,将上述文件保存为f552.m。注意必须是这个文件名,即与函数名保持一致。然后,另写一个脚本调用之,比如:main.msol = [1 1];options = [];[sol, val] = f552(sol, options)