function Y = uq_Ex08_BermBreakwater_cost(X)
%% 1. Cost function
% 1.1 Input and optimized variables
% 1.1.1 Design variables
B = X(:,1);
hb = X(:,2);
Ns = X(:,3);
hf = X(:,4);

% 1.1.2 fix variables
dd = 16.3;
h = hb + dd;
Hsd = 5.03;
ro_sd = 2.45;
ro_wd = 1.025;
Dnd = (Hsd/(((ro_sd/ro_wd)-1)*Ns));
hc = 2 .* Dnd;
u = (0.8 .* Dnd); 
C = 17.8; 
alpha_s = 33.7; 
alpha_l = 33.7;
Cw = (4.* Dnd);
Bc = 12.2;

% 1.2 Volume calculation
% 1.2.1 Calculate Varmor
Varmor = B .* h + (hc .* (hf + C) ./ sind(alpha_s)) + hc .* Cw + ...
          (hc.^2 ./ 2) .* (1 ./ tand(alpha_s) + 1 ./ tand(45));

% 1.2.2 Calculate Vfilter
Vfilter = Bc .* hf + (C .* u + hf .* u) .* (1 ./ sind(alpha_s) + 1 ./ sind(alpha_l)) - ...
           0.5 .* hf.^2 .* (1 ./ tand(alpha_s) + 1 ./ tand(alpha_l));
       
% 1.2.3 Calculate Vcore
Vcore = (C.^2 ./ 2) .* (1 ./ tand(alpha_s) + 1 ./ tand(alpha_l)) + C .* Bc;

delta_D = Dnd/1.6;
% delta_B = (B./10)^0.25;

% delta_D = 1.0;
delta_B = 1.0;

Y = (20  * delta_D * delta_B * Varmor + 15 * Vfilter + 10 * Vcore);

end