Multi objective genetic algorithm: Loading variables in function handles

I am currently using the multi-objective genetic algorithm function 'gamultiobj' to solve a system with 2 variables and 3 objective functions.
I have created an objective function .m file called function_objective.m, which I'm giving a function handle to as
obj=@function_objective;
This objective function file has all three objective functions y(1), y(2) and y(3). One of the objective functions is to minimize a certain parameter that requires the input of 3 large arrays from the workspace (a vector of 525600 values each). I noticed that this function, being called as a handle by gamultiobj, is not able to recognize any variables in the workspace, and the vectors being so big, I cannot just copy it into the file. What I ended up doing is load the .mat files containing those vectors at the beginning of the 'function_objective.m' file. After running the profile viewer, I noticed that this step is taking by far the most time in the whole simulation. So my question is, is there a way for the function handles to be able to recognize the variables in the workspace? Otherwise, is there a way to just load the .mat files once instead of every time for each variable at each generation?
Thank you!
I can share the whole code if needed.
Ali

 채택된 답변

Steven Lord
Steven Lord 2018년 8월 30일

0 개 추천

The Note in the first subsection of the Description section on the gamultiobj function documentation page gives a link to a page showing how to pass additional parameters into your objective function. Use one of those techniques to pass the 3 large arrays from the workspace into your objective function as additional parameters.

댓글 수: 1

Alright I finally understood this section well! It worked perfectly! Thanks a ton!

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

추가 답변 (0개)

카테고리

질문:

2018년 8월 30일

댓글:

2018년 8월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by