How to link the outcome of an ANN model with GA or SA algorithms?
Show older comments
Dear Matlab Co-workers, I would like to link the Neural Network's fitting and modeling outcome to an optimization algorithm, in order to optimize a predicted dependent varible.
My problem consists of 3 independent variables and a dependent variable. The code for prediction using ANN is given below:
.................................................................................................
%% Input - input data composed of three variables
% Output - target data.=Objective to minimize
inputs = [80 80 80 80 80 80 80 80 80 150 150 150 150 150 150 150 150 150 220 220 220 220 220 220 220 220 220; 0.05 0.05 0.05 0.1 0.1 0.1 0.15 0.15 0.15 0.05 0.05 0.05 0.1 0.1 0.1 0.15 0.15 0.15 0.05 0.05 0.05 0.1 0.1 0.1 0.15 0.15 0.15; 5 10 15 5 10 15 5 10 15 5 10 15 5 10 15 5 10 15 5 10 15 5 10 15 5 10 15]
targets = [4264 4127 3775 2872 3137 3218 2320 2537 2671 3808 4172 4290 2843 3085 3654 2497 2661 3131 4783 5037 5590 3126 3756 4386 2655 3134 3100]
% Create a Fitting Network
hiddenLayerSize = 10;
net = fitnet(hiddenLayerSize);
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
net.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};
net.divideFcn = 'dividerand'; net.divideMode = 'sample'; % Divide up every sample
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
net.trainFcn = 'trainlm';
net.performFcn = 'mse';
net.plotFcns = {'plotperform','plottrainstate','ploterrhist', ... 'plotregression', 'plotfit'};
[net,tr] = train(net,inputs,targets);
outputs = net(inputs);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs)
trainTargets = targets .* tr.trainMask{1};
valTargets = targets .* tr.valMask{1};
testTargets = targets .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,outputs)
valPerformance = perform(net,valTargets,outputs)
testPerformance = perform(net,testTargets,outputs)
view(net) figure, plotperform(tr)
figure, plottrainstate(tr)
figure, plotfit(net,inputs,targets)
figure, plotregression(targets,outputs)
figure, ploterrhist(errors)
.................................................................................................
The question: Anyone has an idea how to minimize the predicted above target with GA or any other optimization functions?
Thanks
W. Albrecht
Answers (0)
Categories
Find more on Get Started with MATLAB 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!