trying to use a neural network in a genetic optimiser

조회 수: 1(최근 30일)
luke haworth
luke haworth 2021년 3월 27일
편집: Abdolkarim Mohammadi 2021년 3월 28일
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);


Abdolkarim Mohammadi
Abdolkarim Mohammadi 2021년 3월 28일
If I have understood you well, you want ga() to train your feedforward ANN. If so, you can read about it here:
  댓글 수: 3
Abdolkarim Mohammadi
Abdolkarim Mohammadi 2021년 3월 28일
편집: 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);
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.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by