Hi everyone, I am simulating a cascade multi-level inverter and using C-script to calculate the switching angle by applying the Grey Wolf Optimization algorithm (GWO). In 'codegen' mode, the simulation seems correct, but when I convert to 'PIL' mode, the model can't connect to the device target. Then, I tested the c-script without code with the simple PIL model, it work, when I add the allocation memory function like the code below, I get the error like the image, and I can't simulate my model in the PIL mode. Is there any problem here with my allocation function with PIL? Thanks for your help.

#define SEARCHAGENTS 30
#define NUMBER_GENES 5
float **currentGeneration, **nextGeneration;
void AllocateMemory(void);
void AllocateMemory(void){
int organism;
currentGeneration =
(float**)malloc(sizeof(float*) * SEARCHAGENTS);
nextGeneration =
(float**)malloc(sizeof(float*) * SEARCHAGENTS);
for(organism=0; organism < SEARCHAGENTS; ++organism){
currentGeneration[organism] =
(float*)malloc(sizeof(float) * NUMBER_GENES);
nextGeneration[organism] =
(float*)malloc(sizeof(float) * NUMBER_GENES);
}
}