Matrix dimension problems in Genetic programming. N.B I am not referring to Genetic algorithm
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Honey Adams
le 13 Août 2018
Commenté : Honey Adams
le 15 Août 2018
I am implementing the genetic programming toolbox version 2 from https://sites.google.com/site/gptips4matlab/home to generate model structures for a set of data. In the zip folder, I have my dataset and configuration file as well as my function file labelled as Opinionmining_dataset, gpdemo5_config.m and gpdemo5.m . By following the examples specifically demo4. I made my own demo which is the demo5. The problem I have now is when I run the mygpdemo5.m. it runs to a certain point and gives me the error below. I would be glad if anyone could assist. Thank you.
Index exceeds matrix dimensions.
Error in gpmodel2struct>regressmulti_fitfun_full_stats (line 477)
eval(['geneOutputsTest(:,ind)=' evalstr{i} ';']);
Error in gpmodel2struct (line 253)
gpmodel = regressmulti_fitfun_full_stats(gpmodel,evaltreestrs,gp,rtnVals,tbxStats);
Error in gpfinalise (line 63)
gpmodel = gpmodel2struct(gp,i,false,false,false);
Error in rungp (line 148)
gp = gpfinalise(gp);
5 commentaires
Walter Roberson
le 14 Août 2018
I did run the code. It fails on
eval(['geneOutputsTest(:,ind)=' evalstr{i} ';']);
when evalstr{i} is 'minus(minus(gp.userdata.xtest(:,5),exp(gp.userdata.xtest(:,3))),square(square(gp.userdata.xtest(:,4))))' but gp.userdata.xtest is something with only one column instead of 5.
I traced back, and the use of eval() is hard-wired into the way that the code works. It generates random character vectors and does random text replacement on them, and does mutations and cross-overs at the text level. The code would require some concerted effort to be rewritten to avoid using eval().
Réponse acceptée
Walter Roberson
le 14 Août 2018
You have
gp.userdata.ytest = tstS;
gp.userdata.xtest = tsty;
gp.userdata.xval = ValS;
gp.userdata.yval = Valy;
in the second block of code, the variable ending with 'y' is assigned to a field mentioning 'y', and the variable ending with 'S' is assigned to a field mentioning 'x'. But in the first block of code, the variable ending with 'y' is assigned to a field mentioning 'x', and the variable ending with 'S' is assigned to a field mentioning 'y'. There are no comments that might explain why tstS corresponds to Valy and tsty corresponds to ValS.
The xtest that gets assigned is 2 x 1. The ytest that gets assigned is 2 x 5.
The code that runs errors out when trying to access column 5 of xtest.
We can speculate that you made a mistake related to the data or to this section of the code.
5 commentaires
Plus de réponses (0)
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!