Hi Angga,
I understand that you are facing this error in your objective function.
I tried to analyze your objective function, that is defined as:
cost = (InvCost'*X1) + (DelCost'*X2);
Here, InvCost is a column vector (5x1), and X1 is a matrix (5x1) of optimization variables. Their product, InvCost'*X1, is a scalar, which is correct.
However, DelCost is a matrix (5x7), and X2 is also a matrix (5x7) of optimization variables. Their product, DelCost'*X2, will result in a matrix (5x7), not a scalar, which is the source of the error.
To correct the error, you need to ensure that the entire expression for cost results in a scalar. For the delivery cost part, you want to sum all elements of the product of DelCost and X2 to get a total delivery cost. This can be achieved by element-wise multiplication followed by summing all elements.
Here's how you can correct it:
% Corrected Objective Function
cost = sum(InvCost'*X1) + sum(sum(DelCost.*X2));
I hope it helps to resolve your error!