gamultiobj n by m fitness function evaluation

3 views (last 30 days)
I am trying to optimise 120 parameters using gamultiobj function.
My fitness function output is a matrix with 300 by 88 points, but it seems that the gamultiobj function accepts a single vector as the output of the fitness function since, when I track the error, it tries to assign a matrix of 1 by 26400 to 300 by 88 which through error. 1 by 26400 is calculated inside the gamultiobj function using numel(scorese), which is 300x88=26400.
To clarify: I face the error saying that it is impossible to assign 300 by 88 to 1-26400.
Can anyone help me with how to resolve this?
Thank you in advance
Here is the error:
Unable to perform assignment because the size of the left side is 1-by-26400 and the size of
the right side is 300-by-88.
Error in objAndConVectorizer (line 33)
Fvals(i,:) = feval(objFcn,(pop(i,:)));
Error in gamultiobjMakeState (line 85)
[Score,C,Ceq,isFeas] =
objAndConVectorizer(state.Population(initScoreProvided+1:end,:), ...
Error in gamultiobjsolve (line 20)
state = gamultiobjMakeState(GenomeLength,FitnessFcn,ConstrFcn,output.problemtype,options);
Error in gamultiobj (line 304)
[x,fval,exitFlag,output,population,scores] = gamultiobjsolve(FitnessFcn,nvars, ...
Error in OptimiseParameters_GenAL (line 186)
Error in CameraCalibration (line 100)
OptimiseParameters_GenAL(imagePath, nImages, nCameras, boardWidth, boardHeight,
squareSize, calibrationID, thresh, maxIter)
Caused by:
Failure in user-supplied fitness function evaluation. Cannot continue.

Accepted Answer

Walter Roberson
Walter Roberson on 14 Aug 2021
reshape() the array into a vector as the last operation.
There is no point in trying to fight gamultiobj() to get it to accept an objective function returning an array: it is not designed for that.
Walter Roberson
Walter Roberson on 16 Aug 2021
No, ga() techniques do not use gradient or hessians, just one position component and one velocity component for every entry. You could use any (consistent) scrambling of the output and ga() and gamultiobj() would not notice or care.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by