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

 采纳的回答

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.

更多回答(0 个)

类别

Community Treasure Hunt

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

Start Hunting!

Translated by