function [y_pred_ensv,w_v] = ensemble_valid(y,y_pred) % This function builds an ensemble of metamodels by minimizing validation % error. This method was developed by % Acar, E. and Rais-Rohani, M. “Ensemble of Metamodels with Optimized % Weight Factors," Structural and Multidisciplinary Optimization, % Vol. 37, No. 3, 2008, pp. 279-294. % ---Variable Descriptions--- % y = function values at each test point or cross validation point % y_pred = predictions of each metamodel type at each test point or % cross validation point % in an [ num. of points by num. of models] matrix. % y_pred_ensv= ensemble prediction at each test or cross validation point % w_v = optimized weight multiplying each of the stand-alone % metamodel predictions. global Nm; Nm = size(y_pred,2); % number of metamodels %Ensemble - based on validation error minimization w_v = get_w(y,y_pred); y_pred_ensv = y_pred*w_v'; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function w = get_w(y,y_pred) global Nm; warning off A = []; b = []; Aeq = []; beq = []; lb = zeros(1,Nm); ub = ones(1,Nm); % Initial point and options x0 = 1/Nm*ones(1,Nm); options = optimset('MaxFunEvals',10000,'TolFun',1e-8,'MaxIter',2000); % Solve the optimization problem fvalmin = Inf; index=0; for i=1:1 [ww,fval,exitflag,output] = fmincon(@get_gmse,x0,A,b,Aeq,beq,lb,ub,... @get_constraints,options,y,y_pred); if exitflag>0 && fval