2

I'm using the ga() function of Matlab for parameter optimization in the following way:

options = gaoptimset('CrossoverFraction',0.8,'FitnessScalingFcn',@fitscalingrank,'TolFun',1e-6,...
                'Generations',50,'PopulationSize',20,'EliteCount',2);
minfn = @(z)myLossFunction(z);
[x,fval,~,output] = ga(minfn,8,[],[],[],[],LB,UB,[],1,options);

LB and UB are just matrices with the lower and upper bound for the variables.

The above code works very well. Now, I have made a local copy of the ga() function and named it ga2() because I want to make some modification to it. Now I'm calling it in the following way:

[x,fval,~,output] = ga2(minfn,8,[],[],[],[],LB,UB,[],1,options);

I did not do any modifications yet, I just renamed it to ga2().

Now I'm getting the following error at line 295 of the call gaminlpvalidateoptions(options); of ga2():

Undefined function 'gaminlpvalidateoptions' for input arguments of type 'struct'.

If I comment it out, I'm getting a new error on line 328 saying:

Undefined function 'gacommon' for input arguments of type 'function_handle'.

Why is this and how can I get rid off? I have just copied and renamed the ga() function.

machinery
  • 5,972
  • 12
  • 67
  • 118

0 Answers0