-
Notifications
You must be signed in to change notification settings - Fork 18
/
tps_rbf_construct.m
28 lines (27 loc) · 1.27 KB
/
tps_rbf_construct.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
%==========================================================================
% A modular code for teaching Surrogate Modeling-Based Optimization
% Author: Yong Hoon Lee (ylee196@illinois.edu)
%==========================================================================
% Surrogate Model Construction using RBF with TPS Basis Function
% RBF: Radial Basis Function, TPS: Thin-Plate Spline
%==========================================================================
%
% [w,c] = TPS_RBF_CONSTRUCT(x,f)
% w: RBF Weights
% c: RBF Centers
% x: Known Design Points
% f: Known Objective Function Values
function [w,c] = tps_rbf_construct(x,f)
c = x; % Set RBF centers from known data
nc = size(x,1); % Number of RBF centers
phi = zeros(nc,nc); % Allocate for Gram matrix
for i = 1:nc
% Radii (=distance) between i-th point and the other points
rad = sqrt(sum((repmat(x(i,:),nc,1) - x(:,:)).^2,2));
% Thin-plate spline functions are computed for all radii
phi(:,i) = rad.^2.*log(rad); % thin-plate spline function
phi(rad<eps,i) = 0; % rad<eps: 2 points are identical
end
% RBF weight computation: weight = phi\fsamp (= pinv(phi)\f)
w = pinv(phi)*f;
end