0

I have the following fitness function:

function f = objfun(x,t)
f =  x.*(t-x);
end

When i try to use this code as a fitness function using MATLAB's Optimization Tool and the Genetic Algorithm (ga) solver, i get the following error:

Error running optimization. Not enough input arguments.

I know the function has only 2 variables and I'm passing it those few variables so I have no idea why I am getting this error.

Can someone please help me fix this?

brodoll
  • 1,851
  • 5
  • 22
  • 25
user3526197
  • 96
  • 1
  • 11

1 Answers1

0

I never worked in Matlab because I heard that is slow (see for instance this thread: Performance Tradeoff - When is MATLAB better/slower than C/C++).

for genetic algorithms you need the highest speed possible because for complex problems you need very large populations...

I suggest to use C/C++. Here is a very light C implementation of a Genetic Algorithm that I've made for solving the function optimization problem: http://create-technology.blogspot.ro/2015/03/a-genetic-algorithm-for-solving.html

Community
  • 1
  • 1
Mihai Oltean
  • 159
  • 1
  • 9