Unable to convert expression into double array, in Gamultiobj
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Alberto Chavez
il 1 Dic 2021
Commentato: Walter Roberson
il 2 Dic 2021
Greetings, I need some help with figuring out how to make functions for optimization tools which accept symbolic handles (or so I think). I been trying with many solutions in this community but none seem to fit my problem. Most, if not all revolve around functions with limited symbolic variables that are not dynamic.
My problem is that I have 2 objective linear vectors Z_1 and Z_2 which can have many variables (from 82 to 1k or more), and trying to use the gamultiobj tool, I have the matrices and their vectors, the only thing that I can't figure out is how to make the fit function work. Here is the relevant code:
yy=sym([]); % I start with making the fit function as symbolic as suggested by many other solutions.
yy(:,1)=Z_1*sym('x',[1,size(Z_1,2)])'; % I try to vectorize the fitness function for Z_1 (which I think here is the problem) making the variables 'x1',..., 'xn'
yy(:,2)=Z_2*sym('x',[1,size(Z_1,2)])'; % And Z_2
[x,fval]=gamultiobj(@(x)yy,size(Z_1,2),MatrixInequality,VectorInequality,MatrixEquality,VectorEquality)
I think the problem is the vectorized fit function which may seem easy to fix if you are making only 3 or 8 or so variables (by hand) but if it's very dynamic, how can I make it work?
I attached the Z_1, Z_1 vectors as well as the matrices with their vectors if you need to take a closer look.
0 Commenti
Risposta accettata
Walter Roberson
il 1 Dic 2021
Use matlabFunction() to convert yy to a numeric function. Be sure to use the 'vars' option to bundle all of the inputs into a single row vector
4 Commenti
Walter Roberson
il 2 Dic 2021
You might want to experiment with increasing your population size using the gamultiobj options.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Get Started with Optimization Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!