Filter löschen
Filter löschen

Matrix dimension problems in Genetic programming. N.B I am not referring to Genetic algorithm

1 Ansicht (letzte 30 Tage)
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 Kommentare
Walter Roberson
Walter Roberson am 14 Aug. 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().
Honey Adams
Honey Adams am 14 Aug. 2018
awwww.I contacted the Developer but I haven't gotten any response yet.I hope to hear from him soon.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 14 Aug. 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 Kommentare
Honey Adams
Honey Adams am 14 Aug. 2018
I use Matlab2014a and I have the symbolic math toolbox installed. That should suffice for now. The code works with my current version since I don't have the newer versions of Matlab.
Honey Adams
Honey Adams am 15 Aug. 2018
Hello Walter, I posted a subquestion on the toolbox here https://www.mathworks.com/matlabcentral/answers/414768-developing-a-fitness-function-for-evolved-models-in-genetic-programming. I would be glad if you could check it out.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2014a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by