필터 지우기
필터 지우기

Unable to convert expression into double array, in Gamultiobj

조회 수: 1 (최근 30일)
Alberto Chavez
Alberto Chavez 2021년 12월 1일
댓글: Walter Roberson 2021년 12월 2일
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.

채택된 답변

Walter Roberson
Walter Roberson 2021년 12월 1일
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
Alberto Chavez
Alberto Chavez 2021년 12월 1일
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 2021년 12월 2일
You might want to experiment with increasing your population size using the gamultiobj options.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by