Demos
Different use cases of the Optimal Experimental Design Toolbox are illustrated here with an example with one model parameter and one-dimensional measurements.
Contents
Create the model and the solver object
p = 1; % True parameter of the model p0 = (1 + rand()) * p % Guessed parameter value n = 5; % Number of different selectable measurements t_var = (0:1/(n-1):1)' % Selectable measurements v_var = 10^-2 * ones(1, n)' % Variances of measurement results at these measurements model = model_explicit('p*t', 'p', 't'); % Create the model object sol = solver(model, p0, t_var, v_var); % Create the solver object
p0 =
1.6948
t_var =
0
0.2500
0.5000
0.7500
1.0000
v_var =
0.0100
0.0100
0.0100
0.0100
0.0100
Calculate optimal measurements
max = 3; % Maximal number of measurements to choose t_opt = sol.get_optimal_measurements(max) % Calculate the optimal measurements of the selectable measurements
t_opt =
0.5000
0.7500
1.0000
Calculate quality of measurements
The smaller the value, the better the quality.
w_opt = sol.get_optimal_weights(max) % Calculate the optimal weights of the selectable measurements quality_opt = sol.get_quality(w_opt) % Calculate quality resulting from optimal measurements w_subopt = [ones(max, 1); zeros(n-max, 1)] % Suboptimal weights quality_subopt = sol.get_quality(w_subopt) % Calculate quality resulting from suboptimal measurements
w_opt =
0
0
1
1
1
quality_opt =
0.0019
w_subopt =
1
1
1
0
0
quality_subopt =
0.0111
Estimate model parameter from accomplished measurements
m = 5; % Number of accomplished measurements t_fix = t_opt; % Accomplished measurements v_fix = v_var(w_opt); % Variances of measurement results at these measurements eta = model_util.get_fictitious_measurement_results(model, p, t_fix, v_fix); % Measurement results of the accomplished measurements sol.set_accomplished_measurements(t_fix, v_fix, eta); % Pass accomplished measurements to the solver object p_lb = 0; % Lower bound of model parameter p_ub = 2; % Upper bound of model parameter p_opt = sol.get_optimal_parameters(p_lb, p_ub) % Optimize model parameter from accomplished measurements
p_opt =
0.9941
Calculate gain of additional measurements
sol.set_initial_parameter_estimation(p_opt); % Update parameter estimation w_opt = sol.get_optimal_weights(max)'; % Calculate the optimal weights of the selectable measurements quality_old = sol.get_quality(zeros(n, 1)) % Calculate quality without additional measurements quality_new = sol.get_quality(w_opt) % Calculate quality resulting from optimal additional measurements
quality_old =
0.0056
quality_new =
0.0028
Calculate optimal measurements with constraints
We are constraining the choice of measurements in such a way that distance between two chosen measurements has to be at least 0.5.
A = diag(ones(n, 1)) + diag(ones(n-1, 1), 1) % Matrix for the constraints of the measurements b = ones(n, 1) % Vector for the constraints of the measurements t_opt = sol.get_optimal_measurements(A, b) % Calculate the optimal measurements of the selectable measurements considering the constraints
A =
1 1 0 0 0
0 1 1 0 0
0 0 1 1 0
0 0 0 1 1
0 0 0 0 1
b =
1
1
1
1
1
t_opt =
0
0.5000
1.0000