Conversation
Modify "global initial_flag" to ensure that when running different function or running the same function with different dimensions of x, the program will reload the optima matrix. If not, there will be an error about dimension mismatch between the optima matrix and the individual to be evaluated.
|
Can you please elaborate on the suggested fix? it would be great to provide a code snippet that exhibits the problem. |
|
Let's take the code of Composition Function 3 as an example, which has F13, F14, F16, F18 with different dimensions. This is the original code: We just want to only load optima.mat for the first time and directly use the persistent variables func_num, func, o, sigma ,lambda, bias, M in the next calls. This works fine during running F13 (2D). But when changing to F14 (3D), the dimension of input x changed. So there will be a mismatch of the dimension of the persistent variable o . To address this issue, I add two persistent variables initial_flag and dim and delete the global variable initial_flag. In this way, at every call we not only judge if the initial_flag==0, but also judge if the dimension of the input x has changed. Therefore, when F13 (2D) changes to F14 (3D), we will reload optima.mat and generate the new compositional function. |

Modify "global initial_flag" to ensure that when running different functions or running the same function with different dimensions of x, the program will reload the optima matrix. If not, when running next function with different dimensions of x, there will be an error about dimension mismatch between the optima matrix and the individual to be evaluated.