Finding four input combinations with the same output value by interpolation method, and find the one that minimizes the cost function.
Show older comments
A(x,y,z,w) is 4-D dobule data, for example A(1,1,1,1) is determined as the specific value. each dimension length is 60, so the number of data is 60^4.
B(x,y,z,w) is also 4-D double data like A.
I want to find a solution, (x_sol,y_sol,z_sol,w_sol), that minimizes B(x,y,z,w) among the combinations of (x,y,z,w) that satisfy an arbitrary A*=A(x,y,z,w).
I've been able to find solutions using meshgrid and interp2 for data with 2-D variables, but I'm having trouble with data with 4-D variables.
Below shows the desired solution for A and B with 2-D variables. I want to solve the same problem for A and B extended to 4-D.
X_interp = 0 : 0.01 : 29.99; % tighter spaced linear array for interpolation
[X_mesh,Y_mesh] = meshgrid(X,Y);
min_B=zeros(1,length(Astar_arr)-1);
for i = 1:length(Astar_arr)-1
XY_temp = contour(X,Y,A',[Astar_arr(i) Astar_arr(i)],ShowText="on");
XY=XY_temp(:,2:end);
Y_interp = interp1(XY(1,:),XY(2,:),X_interp);
XY_interp(:,i) = Y_interp;
B_interp(:,i) = interp2(X_mesh,Y_mesh,B',X_interp,Y_interp);
idx_min_B(:,i)=find(B_interp(:,i)==min(B_interp(:,i)));
min_B(i)=min(B_interp(:,i));
end
How can I solve this problem?
Answers (1)
John D'Errico
on 20 Jun 2023
0 votes
Um, your technique will not really solve the problem. It approximates the solution. Regardless, you will now have difficulties extending it to higher dimensions.
What you did was to generate a contour path for each value of A*. So you got a list of points that form a piecewise linear approximation to the solution A(x,y)==A*. Those points are just a subset of the locus of all such values.
Then you chose the point from that set that minimized B(x,y). Again, it is not really a true solution, but an approximation.
But to extend that idea to 4 independent variables, you need to solve for a 4-d iso-surface.
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!