variableIndices variable in global optimization toolbox GA
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi !
I have a question about a variable from global optimization toolbox genetic algorithm subroutine.
I am attempting to minimize a fitness function (RMSEP - Relative Mean Square Error of Prediction from Partial Least Squares) by selecting optimal subsets of my initial dataset, with a maximum of 6 variables in a subset. Basically I want to perform GA-PLS with the global optimization toolbox.
My fitness function gets processed normally, and it has as an output a single scalar, rmsep value.
However, in order to select the variables for the subset, naturally, I would think I have to use the variableIndices which are output of the GA. However, whichever creation function I use, the results are always in decimal form (e.g. 20.250...) and thus unusable for selection of subsets. I can use round(variableIndices), however I think that is not the solution.
My fitness function is:
function rmsep = gafit1(variableIndices,...
x_train,y_train,x_test,y_test)
% variableIndices=round(variableIndices)
y1=y_train;
x1=x_train;
[~,~,~,~,b] = plsregress(x1(:,variableIndices),y1,2);
y2=y_test;
x2=x_test(:,variableIndices);
yhat = [ones(size(x2,1),1) x2]*b;
rmsep=gafit0(y2,yhat)*100;
plot(y2,yhat,'.');
end
gafit0 is a routine which calculates rmsep.
Please help !!!
Best regards,
Petar
0 commentaires
Réponses (1)
Alan Weiss
le 18 Nov 2014
Use mixed-integer optimization along with the constraint that no more than 6 variables can exist, a linear constraint of the form
A*x <= 6
where x is a binary vector of the variables in the problem and A is a row vector of ones. If you have more variables than just the binary ones, put zeros in the corresponding columns of A for those variables.
Alan Weiss
MATLAB mathematical toolbox documentation
6 commentaires
Alan Weiss
le 20 Nov 2014
Once more I urge you to read in its entirety the first section I linked you to on mixed integer optimization. Please read it before asking any more questions. In particular, it states that you cannot have custom mutation or crossover functions. Yes, it is a pain and boring to read the documentation. But this particular documentation is quite relevant to what you are trying to do.
Also, do NOT use nonlinear constraints for the x and y variables, use LINEAR inequality constraints.
Alan Weiss
MATLAB mathematical toolbox documentation
Voir également
Catégories
En savoir plus sur Genetic Algorithm dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!