Unable to convert expression into double array, in Gamultiobj

1 view (last 30 days)
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.

Accepted Answer

Walter Roberson
Walter Roberson on 1 Dec 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 Comments
Alberto Chavez
Alberto Chavez on 1 Dec 2021
Yes, after playing a bit with the constraints (keeping inequalities, or equalities), everything seems ok. It was just that my problem is too constrained, that's probably why the population converges at an "obvious" local point.
Thanks for the help.
Walter Roberson
Walter Roberson on 2 Dec 2021
You might want to experiment with increasing your population size using the gamultiobj options.

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with Optimization Toolbox in Help Center and File Exchange

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!