Clear Filters
Clear Filters

请问这个报错该如何处理?

3 views (last 30 days)
俊辉 李
俊辉 李 on 10 Apr 2024
Answered: cdarling on 17 Jul 2024 at 3:30

Answers (1)

cdarling
cdarling on 17 Jul 2024 at 3:30
报错信息如下:
将使用 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 行向量
因此请检查自定义函数的逻辑,让它对于不同的输入值,它的返回值具有确定的大小

Tags

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!