Matrix dimension problems in Genetic programming. N.B I am not referring to Genetic algorithm
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Honey Adams
el 13 de Ag. de 2018
Comentada: Honey Adams
el 15 de Ag. de 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 comentarios
Walter Roberson
el 14 de Ag. de 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().
Respuesta aceptada
Walter Roberson
el 14 de Ag. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Genetic Algorithm en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!