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

1 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2018-8-14
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().

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2018-8-14
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 个评论
Honey Adams
Honey Adams 2018-8-14
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 2018-8-15
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Genetic Algorithm 的更多信息

产品


版本

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by