Be the first to rate this file! 40 downloads (last 30 days) File Size: 29.1 KB File ID: #25499

gapolyfitn

by Richard Crozier

 

06 Oct 2009 (Updated 19 Oct 2009)

Code covered by the BSD License  

optimises the functional form of a multi-dimensional polynomial fit to model data

Download Now | Watch this File

File Information
Description

This function implements a method of using genetic algorithms to optimise the form of a polynomial, i.e. reducing the number of terms required in comparison to a least-squares fit using all possible terms, as described in the following paper:

Clegg, J. et al, "The use of a genetic algorithm to optimize the functional form of a multi-dimensional polynomial fit to experimental data", 2005 IEEE Congress on Evolutionary Computation, 928-934, Edinburgh, September, 2005

A general polynomial of n variables can be represented as follows:

a1 * x1^2 * x2^4 * x3^1 * xn^p + a2 * x_1^6 * x2^3 * x3^1 * xn^p + ...

A linear least-square fit can find the values of the coefficients, represented as 'a' above, such that the error between the function and a set of data is minimized. If the functional form of the data is not known in advance this can require that all possible combinations of terms and powers up to a given size are used. As the number of terms in a polynomial is given by (n+(m-1))! / (n!)(m-1)! where n is the maximum power used and m is the number of variables, the number of all possible terms can become very large for multivariable models. For example, a model with 12 variables of up to order 8 would require 75582 terms. Furthermore this can require the inversion of an extremely large matrix in order to evaluate the regression model.

This function generates a population of polynomial forms which are each a subset of the set of all possible terms and evaluates them for their fit to the model data as given by the R-squared value returned by the function polyfitn. The population is then evolved using a genetic algorithm based on their relative scores. Evolution is achieved by mating successful individuals and the introduction of random mutations.

The function makes use of the free GA toolbox from the University of Sheffield Evolutionary Computing Team in the uk available here:

http://www.shef.ac.uk/acse/research/ecrg/gat.html

but the crucial subfunctions objpolyfit, crtpolyp, recpoly and mutpoly could no doubt easily be used with the MATLAB Genetic Algorithm and Direct search toolbox.

This function can use the multicore package provided on the file exchange but it is not required, simply always use the options.MCORE = false option (the default in any case).

Required/Reccomended functions can be currently found here:

GA toolbox (required):
http://www.shef.ac.uk/acse/research/ecrg/gat.html

polyfitn (required):
http://www.mathworks.co.uk/matlabcentral/fileexchange/10065

gfit2 (required):
http://www.mathworks.co.uk/matlabcentral/fileexchange/22020

randMat (required):
http://www.mathworks.co.uk/matlabcentral/fileexchange/24712

muticore (optional):
http://www.mathworks.co.uk/matlabcentral/fileexchange/13775

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Polyfitn, Multicore - Parallel processing on multiple cores

MATLAB release MATLAB 7.6 (R2008a)
Other requirements GA toolbox from the University of Sheffield Evolutionary Computing Team in the uk available here: http://www.shef.ac.uk/acse/research/ecrg/gat.html
Zip File Content  
Other Files
gapolyfitn/crtpolyp.m,
gapolyfitn/gapolyfitn.m,
gapolyfitn/gapolyfitn_example_script.m,
gapolyfitn/gapolyfitnresplot.m,
gapolyfitn/generategapolyfitnoptions.m,
gapolyfitn/GenerateNewTerm.m,
gapolyfitn/HasTerm.m,
gapolyfitn/mutatepoly.m,
gapolyfitn/mutpoly.m,
gapolyfitn/objpolyfit.m,
gapolyfitn/objpolyfit_MCore.m,
gapolyfitn/PolyFitScore.m,
gapolyfitn/PolyFitScore_MCore.m,
gapolyfitn/PolyMultOps.m,
gapolyfitn/polyVec2polyfit.m,
gapolyfitn/recombinpoly.m,
gapolyfitn/recpoly.m,
gapolyfitn/ScorePolyFitAndEfficiency.m,
license.txt
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
07 Oct 2009

Updated description and acknowledgments properly this time!

15 Oct 2009

Substantial speed improvement of code

15 Oct 2009

Fixed major error which prevented more than 15 terms being used in polynomial due to some testing code not being removed, oops. Also added some more info printing to command prompt with VERBOSE option.

16 Oct 2009

Removed superfluous gapolyfitn.zip from uploaded directory

19 Oct 2009

Fixed error and added GRAPHS option, code should now be stable

Tag Activity for this File
Tag Applied By Date/Time
optimization Richard Crozier 07 Oct 2009 10:33:33
linear regression Richard Crozier 07 Oct 2009 10:33:33
modelling Richard Crozier 07 Oct 2009 10:33:33
genetic algorithm Richard Crozier 07 Oct 2009 10:33:33
ga Richard Crozier 07 Oct 2009 10:33:33
polynomial Richard Crozier 07 Oct 2009 10:33:33
curve Richard Crozier 07 Oct 2009 10:33:33
fit Richard Crozier 07 Oct 2009 10:33:33
interpolation Richard Crozier 07 Oct 2009 10:33:33
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com