请问这个报错该如何处理?
    7 views (last 30 days)
  
       Show older comments
    
Answers (1)
  cdarling
    
 on 17 Jul 2024
        报错信息如下:
将使用 gamultiobj 求解问题。
无法执行赋值,因为左侧的大小为 1×1,右侧的大小为 1×4。
出错 objAndConVectorizer (第 34 行)
                Fvals(i,:) = thisFval(:)';
出错 gamultiobjMakeState (第 107 行)
        [Score,C,Ceq,isFeas] = objAndConVectorizer(state.Population(initScoreProvided+1:end,:), ...
出错 gamultiobjsolve (第 20 行)
state = gamultiobjMakeState(GenomeLength,FitnessFcn,ConstrFcn,output.problemtype,options);
出错 gamultiobj (第 342 行)
[x,fval,exitFlag,output,population,scores,residuals] = gamultiobjsolve(FitnessFcn,nvars, ...
出错 optim.problemdef.OptimizationProblem/callSolver
出错 optim.internal.problemdef.ProblemImpl/solveImpl
出错 optim.problemdef.OptimizationProblem/solve
出错 pt (第 10 行)
x1=solve(problem)
原因:
    Failure in user-supplied fitness function evaluation. Cannot
    continue.
可能是函数的输出大小不确定造成的,比如:
question(ones(6,5))
结果是 1x6 大小的:
ans =
        1184        1189        1189        1184        1184        1189
而如果输入全是零
question(zeros(6,5))
结果就是 1x0 的空集
ans =
  空的 1×0 double 行向量
因此请检查自定义函数的逻辑,让它对于不同的输入值,它的返回值具有确定的大小
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

