# Objective function of a Genetic Algorithm

This is my first effort about AI/ML.

I have the following problem given by my teacher,

Design a simple genetic algorithm in MATLAB, with binary-coded chromosomes, in order to solve pattern finding problem in 16-bit strings.

The objective function is given by the following formula:

F(x) = NoS("010") + 2NoS("0110") + 3NoS("01110") + 4NoS("011110") + 5NoS("0111110") + 6NoS("01111110") + 7NoS("011111110") + 6NoS("0111111110") + 5NoS("01111111110") + 4NoS("011111111110") + 3NoS("0111111111110") + 2NoS("01111111111110") + NoS("011111111111110")

I couldn't understand the formula.

What does it mean by Nos?

What operations are they performing on those binary strings?

What is F(x)?

• NoS means "numbers of" (that is, count the occurrences of the substring in the individual's chromosome). F(x) is the fitness you are computing (a scalar number), I don't understand your question. Dec 2 '16 at 1:41
• @lacerbi, What operations are they performing on those binary strings? Dec 2 '16 at 1:43
• I'll try again. mNoS("110") means that you need to count how many 110 patterns there are in your individual's chromosome (string), multiply by m, and that's one of the contributions to the fitness of the individual. Sum over all contributions and that's F(x). Dec 2 '16 at 1:51

## 1 Answer

NoS means "numbers of" (that is, count the occurrences of the substring in the individual's chromosome). F(x) is the fitness you are computing (a scalar number).

In particular, mNoS("110") where m is a scalar, means m $\cdot$ NoS("110"), that is:

• count how many 110 patterns there are in your individual's chromosome (string x);
• multiply by m;

and this is one of the contributions to the fitness of the individual. Sum over all contributions and that is your F(x).