How to extract the input values for an optimized output value in a GA optimizer
Show older comments
Dear community ,
I am currently working on optimizing a an airofoil
I have an data sheet with 6 elements with 120 samples as an input and 1 element with 120 samples respectively which is the ouput/ target.
Now I have constructed an ANN model with 12 number of hidden neurons in the hidden layer.
The Neural fitting app generates a respective program to provide the matrix only fucntion program which then can be utilized in the GA optimizer tool
Once I save the program and add the progroam as the objective function in the GA optimizer APP with variable as 1
I have an optimized single value for my output data .
But I also need what were the input values to produce the optimized output value.
The below attached program is the Objective function.
function [y1] = myNeuralNetworkFunction1(x1)
%MYNEURALNETWORKFUNCTION neural network simulation function.
%
% Generated by Neural Network Toolbox function genFunction, 16-Nov-2022 11:40:39.
%
% [y1] = myNeuralNetworkFunction(x1) takes these arguments:
% x = 6xQ matrix, input #1
% and returns:
% y = 1xQ matrix, output #1
% where Q is the number of samples.
%#ok<*RPMT0>
% ===== NEURAL NETWORK CONSTANTS =====
% Input 1
x1_step1.xoffset = [0;0;0;0;0;0];
x1_step1.gain = [2;2;2;2;2;2];
x1_step1.ymin = -1;
% Layer 1
b1 = [-1.5405239961044094876;-1.5273808353399593862;1.3260615608441381763;-1.5672656908495641304;-0.52463531414582453838;-0.28562547291621864787;-0.92600523410297119753;0.94836491891548213573;0.60413286072586980247;1.3812775835551660553;-0.98746545414147057773;1.8537659554345575774];
IW1_1 = [0.694735700484934382 1.0822554083725968166 0.58162355947880228779 -0.03182512671079117117 -0.35594714793451137647 -0.42115056541279694002;1.7126774333679974927 0.38541323476327671305 0.79165816668606570072 -0.58420613872381599307 0.47446011946542465676 -0.77321888761387003175;-0.47022972931769457805 1.3575902664213252979 -0.022964776251181699684 0.98954132183856580163 -1.3141641243687507412 0.26303920875519415379;0.50570618121209287565 -0.021764214642695456359 -0.17241505384885658092 -1.6282392397915912419 0.35958459771516887438 0.65811302429996787478;0.61453749200090124205 -0.58597896420739203904 0.628444680629517749 0.10933592079163188815 0.64514255935658848529 1.6220061225237449865;-0.93738364435824672594 0.32630035707491461539 -0.99320598793569225826 0.62830932212865575615 -1.1012636140809652918 1.2068758779914174895;-0.36250296717830537974 0.94937094400320753973 0.99760130900678023469 0.70186338551042104505 -1.1900576806232499028 -0.210153503141659731;-0.075593817872469382113 0.24277422296966821857 -1.0955800396372881167 1.2464066543147362953 -0.2124800541687666966 -0.78058215295044663939;0.62073106044722403674 0.12362028693823426395 -0.098384844666925347356 -0.63298401375966018012 0.15725136244761661608 -0.11174225226285876278;0.97877205494941077468 -0.49569157152645215714 -1.7661741788009719389 0.76245089960480827429 -0.875109689249058742 -0.47742261438667982221;-0.50331411621013577573 0.87483246760882549253 -1.2072547488793210491 -0.91121672594314229165 0.77339529988332500476 1.6743937944334255086;1.1929761368367524099 0.99724807116224178927 0.72139890919897775579 0.76024416241570236252 -1.2847855749809071746 -0.19326786300070347702];
% Layer 2
b2 = 0.23670804816455365271;
LW2_1 = [0.16518424966462744163 0.060203722234422205051 0.094778695751439587247 0.48904037181873094564 0.027025074991859011214 -0.042606777963060948888 0.23347377085036169486 0.063412372907630298879 0.41374384009683085051 -0.25859598579246850791 0.034358285747008235345 0.12452529500120101957];
% Output 1
y1_step1.ymin = -1;
y1_step1.gain = 435.824798431031;
y1_step1.xoffset = 0.010163;
% ===== SIMULATION ========
% Dimensions
Q = size(x1,2); % samples
% Input 1
xp1 = mapminmax_apply(x1,x1_step1);
% Layer 1
a1 = tansig_apply(repmat(b1,1,Q) + IW1_1*xp1);
% Layer 2
a2 = repmat(b2,1,Q) + LW2_1*a1;
% Output 1
y1 = mapminmax_reverse(a2,y1_step1);
end
% ===== MODULE FUNCTIONS ========
% Map Minimum and Maximum Input Processing Function
function y = mapminmax_apply(x,settings)
y = bsxfun(@minus,x,settings.xoffset);
y = bsxfun(@times,y,settings.gain);
y = bsxfun(@plus,y,settings.ymin);
end
% Sigmoid Symmetric Transfer Function
function a = tansig_apply(n,~)
a = 2 ./ (1 + exp(-2*n)) - 1;
end
% Map Minimum and Maximum Output Reverse-Processing Function
function x = mapminmax_reverse(y,settings)
x = bsxfun(@minus,y,settings.ymin);
x = bsxfun(@rdivide,x,settings.gain);
x = bsxfun(@plus,x,settings.xoffset);
end
Can you guys please guide me how to overcome the same.
Thanks & Regards.
Answers (1)
You have not shown us the code for the GA app that you are using, but generally speaking, there should be a line in there which calls ga() and which returns the optimum x (and optionally the objective function value fval) that is being iterated over,
So, maybe you can modify the app code with that in mind.
Categories
Find more on Deep Learning Toolbox 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!