Hey there,
I have a question concerning GA. I want to optimize several parameter at once by using a function handle. One example is the optimization for a set-up of 2 variables. Each vector consists of 10 possible values so an exhaustive search would comprise 100 trials. Instead of the exhaustive search I want to use GA which for example only needs 20 trials to find the optimal set-up. The optimization function has to be a classification function whose error value should be minimized. How can I implement the 2 variables into the function?
Thanks a lot in advance
Danyo
This page gives an example of ga optimization over integer variables
http://www.mathworks.com/help/gads/mixed-integer-optimization.html
The example with Rastrigin's Function is a 2 variable problem and shows you how to make one of the variables integer-variable, though of course you could make them both integers if you wished.
It is a binary target variable with the same length as the input features of Merkmale_MA... Without GA it works, so there should not be an error..
svmtrain isn't receiving the input that you think it is receiving. Use DBSTOP to trap the error and to investigate what values are being fed to svmtrain when the error occurs.
I trapped it, it was because of the "global". I have fixed it but now Matlab complains that Merkmale_MA and KLASSE_1 are unkown in the fitness function cause there are not input variables to the function...
??? Error using ==> makeState at 50 GA cannot continue because user supplied fitness function failed with the following error: Input argument "Merkmale_MA" is undefined.
I figured it out. And I have changed the set-up to: options=gaoptimset('Vectorized', 'off') ; [x fval] = ga(@fitness, 2,[],[],[],[],lb,ub,[],options);
Bur Matt, this take forever, and the range for C and Sigma is not even large yet. Is there a way to speed it up? like discrete values as input for C and Sigma so that GA does only have to combine to find the best solution for the SVM?
Many thanks, I know it must sound really stupid, but I am really new to GA especially in MATLAB
5 Comments
Direct link to this comment:
http://www.mathworks.com/matlabcentral/answers/80665#comment_157592
How do you conclude that GA would only require 20 trials?
Direct link to this comment:
http://www.mathworks.com/matlabcentral/answers/80665#comment_157596
I don't conclude it but I would set the maximum to 20 e.g.
Direct link to this comment:
http://www.mathworks.com/matlabcentral/answers/80665#comment_157600
I'm not sure I understand the question. Are you asking how to do a GA on two variables?
Direct link to this comment:
http://www.mathworks.com/matlabcentral/answers/80665#comment_157601
I just want to implement the GA to optimize the fitness function (classification task) which needs to optimize two variables, C and Sigma for the RBF-SVM.
Direct link to this comment:
http://www.mathworks.com/matlabcentral/answers/80665#comment_157638
Your question isn't specific enough for us to know what to advise you other than "do what the GA documentation says". Have you done
What are you looking for beyond what's written there?