I am trying to optimize a coefficients of filter by minimizing sum-squared error. I want to use a genetic algorithm (GA) optimization wherein the coefficients of filter form the GA's chromosome (a vector).

How can I construct the objective function, given that I want it to use least-squares minimization?

  • $\begingroup$ I can't understand what you are asking. Please edit your question to define all notation before using it. Thank you! $\endgroup$
    – D.W.
    Commented Jan 10, 2018 at 23:35
  • $\begingroup$ What do you mean by "optimize a correlation's parameters"? What are the "parameters" of a correlation? What does it mean to optimize a correlation? What is a "correlation" to you? This question lacks details and I can't understand what you are asking. Please define all terms before using them. $\endgroup$
    – D.W.
    Commented Jan 13, 2018 at 20:14
  • $\begingroup$ If you've accidentally created two accounts, I suggest you merge them. Instructions are here: cs.stackexchange.com/help/merging-accounts $\endgroup$
    – D.W.
    Commented Jan 13, 2018 at 20:14
  • $\begingroup$ @D.W. Their question seems reasonably straightforward. They basically just want to know how to construct an objective function for a genetic algorithm, and the answer's just to RMS the chromosome's entries. A good answer'd probably comment on how genetic algorithms work, and why standard objective functions are still correct despite the different stepping approach. $\endgroup$
    – Nat
    Commented Jan 13, 2018 at 20:21
  • $\begingroup$ I'm glad to hear it makes sense to you. Do you think it will be clear to others? Do you think it should be re-opened? If yes, are you willing to edit it to define the terms and clarify what is meant by, for instance, "optimize a correlation's parameters"? I don't see that the question defines what those terms mean (and I don't see any criteria for evaluating a proposed evaluation function) -- is it just me? $\endgroup$
    – D.W.
    Commented Jan 14, 2018 at 14:20

1 Answer 1


tl;dr- Objective functions are supposed to quantify how good a set of parameters is. It doesn't matter how you got the parameters; for example, it doesn't matter that you're using genetic algorithms. You just need to create some function that says how well the parameters work.

So you're designing a filter, which requires that the filter's parameters be optimized to fit its application, and you'd like to use genetic algorithms for the optimization?

You're correct that the filter's parameters should be used to construct the chromosomes in the genetic algorithm. The genetic algorithm then does its work by:

  1. Calculates how well its chromosome (combination of parameters) performs.

  2. Discards the chromosomes that didn't perform well.

  3. Modifies (mutates) the parameter sets (chromosomes) that did perform well.

  4. Goes back to Step (1), looping until either it finds a parameter set that's good enough or it gives up (fails to converge).

However, how should the algorithm assess how "good" the parameter sets are? That's what the objective function's for. The objective function takes the chromosome as input, then produces a result that quantifies how good that chromosome is.

Since chromosomes are sets of parameters, they're often represented as a vector (array). For example, if your filter's, say,$$ f\left(x\right)=ax^2+bx+c, $$then the chromosome's the array of the parameters $\left\{a,b,c\right\}$.

The question statement doesn't specify your filter or exactly what sort of problem you're working on. However, since you want to use sum-squared error, that implies that your filter produces an output with quantifiable error.

So, presumably, your objective function would be$$ \text{error}=\sum_{{\forall}\text{data}~i}{\left(f_{\text{measured}}\left(x_i\right)-f_{\text{model}}\left(x_i\right)\right)}^2, $$or something like that. Some folks prefer to use the root-mean-square, i.e.$$ \text{error}=\sqrt{\sum_{{\forall}\text{data}~i}{\left(f_{\text{measured}}\left(x_i\right)-f_{\text{model}}\left(x_i\right)\right)}^2}, $$but that shouldn't matter here.

In general, I'd suggest seeing genetic algorithms as stepping functions. Their core duty is to produce new guesses during an optimization process. Objective functions live elsewhere in the optimization process's structure; this is, objective functions don't care how you're stepping - whether you're using genetic algorithms, Newton's method, Simplex, gradient descent, bisection, random guessing, or whatever else - it doesn't matter to the objective function. All the objective function has to do is say how good a guess is, regardless of how that guess was generated.

  • $\begingroup$ Thanks for the answer,I m using FIR filter ,and I am choosing LS method for find the coefficient ,because the coefficient is complex . $\endgroup$
    – K.n90
    Commented Jan 16, 2018 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.