Let me explain the problem clearly. I asked it as an anology for my real case. If i remember extra constraints that must be met i will edit the code but this is it for now.
a = excel_mat1; % rocks in diff shapes and materials and contain [0,0] row (size 30x3)
b = excel_mat2; % rocks in diff shapes and materials and contain [0,0] row (size 30x3)
c = excel_mat3; % rocks in diff shapes and materials and contain [0,0] row (size 30x3)
d = excel_mat4; % rocks in diff shapes and materials and contain [0,0] row (size 30x3)
e = excel_mat5; % rocks in diff shapes and materials and contain [0,0] row (size 30x3)
f = excel_mat6; % rocks in diff shapes and materials and contain [0,0] row (size 30x3)
g = excel_mat7; % rocks in diff shapes and materials and contain [0,0] row (size 30x3)
h = excel_mat8; % rocks in diff shapes and materials and contain [0,0] row (size 30x3)
i = excel_mat9, % rocks in diff shapes and materials and contain [0,0] row (size 30x3)
j = excel_mat10; % fluid types (size 10x3)
%% [Volume;density;ID] for all
aa = size(a,1);
bb = size(b,1);
cc = size(c,1);
dd = size(d,1);
ee = size(e,1);
ff = size(f,1);
gg = size(g,1);
hh = size(h,1);
ii = size(i,1);
max_bucket_vol = user_defined_value;
%% this bucket has various things whose values are known inside
volume_initial = vol1; %constant volume of materials inside bucket at first
density_initial= den1; %constant density of materials inside bucket at first
number_of_rocks = size([a;b;c;d;e;f;g;h;i],1);
available_fluids = size(j,1);
max_volume_of_available_fluids = j(:,1);
max_weight_of_available_fluids = j(:,1).*j(:,2); %density in second column
ings = [a;b;c;d;e;f;g;h;i];
volume_vector = ings(:,1);
density_vector= ings(:,2);
optchoice = optimproblem;
optrocksol = optimvar('optrocksol',number_of_rocks,'Type','integer','LowerBound',0,'UpperBound',1);
optfluidsol= optimvar('optfluidsol',available_fluids,'LowerBound',0,'UpperBound',1);
optchoice.Objective = (sum(optrocksol.*volume_vector.*density_vector)+sum(optfluidsol.*max_weight_of_available_fluids)+vol1*den1)...
/(sum(optrocksol.*volume_vector)+sum(optfluidsol.*j(:,1)+vol1);
optchoice.Constraints.s0 = sum(optrocksol.*volume_vector)+sum(optfluidsol.*j(:,1)+vol1 <= max_bucket_vol;
optchoice.Constraints.s1 = sum(optrocksol(1:aa)) == 1;
optchoice.Constraints.s2 = sum(optrocksol(aa+1:aa+bb)) == 1;
optchoice.Constraints.s3 = sum(optrocksol(aa+bb+1:aa+bb+cc)) == 1;
optchoice.Constraints.s4 = sum(optrocksol(aa+bb+cc+1:aa+bb+cc+dd)) == 1;
optchoice.Constraints.s5 = sum(optrocksol(aa+bb+cc+dd+1:aa+bb+cc+dd+ee)) == 1;
optchoice.Constraints.s6 = sum(optrocksol(aa+bb+cc+dd+ee+1:aa+bb+cc+dd+ee+ff)) == 1;
optchoice.Constraints.s7 = sum(optrocksol(aa+bb+cc+dd+ee+ff+1:aa+bb+cc+dd+ee+ff+gg)) == 1;
optchoice.Constraints.s8 = sum(optrocksol(aa+bb+cc+dd+ee+ff+gg+1:aa+bb+cc+dd+ee+ff+gg+hh)) == 1;
optchoice.Constraints.s9 = sum(optrocksol(aa+bb+cc+dd+ee+ff+gg+hh+1:aa+bb+cc+dd+ee+ff+gg+hh+ii)) == 1;
s = solve(optchoice); % solving for most dense or least dense bucket for defined max volume