trying to use a neural network in a genetic optimiser

3 次查看(过去 30 天)
hi, i have created a neural net using 6 inputs and one output, its for a project to optermize intake length and valve timings for an engine
i am happy that the network is working as i intended but i dont know how to generate a function from the network and then use this funtion in the genetic algorithm optimizer, any help would be appieciated
here is my code for the network
filename3 = 'data for network.xlsx';
%x1 = rpm
x1 = xlsread(filename3,'C4:AGW4');
%x2 = length
x2 = xlsread(filename3,'C5:AGW5');
%x3 = IVO timing
x3 = xlsread(filename3,'C6:AGW6');
%x4 = IVC timing
x4 = xlsread(filename3,'C7:AGW7');
%x5 = EVO timing
x5 = xlsread(filename3,'C8:AGW8');
%x6 = EVC timing
x6 = xlsread(filename3,'C9:AGW9');
%x = {x1;x2;x3;x4;x5;x6};
x25 = [x1;x2;x3;x4;x5;x6];
%y1 = hp
y1 = xlsread(filename3,'C10:AGW10');
net_hp = feedforwardnet(10);
net_hp = configure(net_hp,x25,y1);
net_hp = init(net_hp);
[net_hp,tr] = train(net_hp,x25,y1);

回答(1 个)

Abdolkarim Mohammadi
If I have understood you well, you want ga() to train your feedforward ANN. If so, you can read about it here:
  3 个评论
luke haworth
luke haworth 2021-3-28
basically i want the network/optimizer to find the best possible value for horsepower (highest value) and then show the network inputs for the best best (highest) output
Abdolkarim Mohammadi
编辑:Abdolkarim Mohammadi 2021-3-28
I think you have a surrogate model, that is, you have trained a network that gets inputs and returns the horsepower. If so, your job is very easy. Just put the network inside a function
function ObjectiveFunctionValue = ObjectiveFunction (x, net)
ObjectiveFunctionValue = net (x);
end
and pass it as the objective function to ga() or anything else. For example:
fun = @ (x) ObjectiveFunction (x, net);
nvars = % number of decision variables (inputs of the network)
[x, fval] = ga (fun, nvars);
Read more in ga() documentation.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by