Eric-Bradford / TS-EMO

This repository contains the source code for “Thompson sampling efficient multiobjective optimization” (TSEMO).
BSD 2-Clause "Simplified" License
93 stars 16 forks source link

Error using * #8

Open FrankDeussens opened 1 year ago

FrankDeussens commented 1 year ago

Hey! I am recieving the following error very frequently:

"Error using Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use '.'.

Error in TSEMO_V4>hypervolumemonte (line 633) P=P*diag(1./r); ..."

Any idea how to fix this? Let me know if further elaboration is requiered.

Protoplanetary-Fish commented 6 months ago

I've not encoutered that error.

But I would recommend everyone to use this vectorized version of that function (if compatible with your MatLab version). It should be around 12-20x faster (at the cost of a bit of memory) than the one in the original codebase as it is a bottleneck on execution speed if you are pushing the algorithm.

function v = hypervolumemonte(P,r,N)

% Check input and output
narginchk(2,3);
nargoutchk(0,1);

P=P*diag(1./r);
[~,d]=size(P);

if nargin<3
    N=1000;
end
if ~isscalar(N)
    C=N;
    N=size(C,1);
else
    C=rand(N,d);
end

C_expanded = permute(C, [1 3 2]);
P_expanded = permute(P, [3 1 2]);
domination_checks = all(C_expanded > P_expanded, 3);
fDominated = any(domination_checks, 2);

v=sum(fDominated)/N;
return