How to represent a job-sequencing?, with binary code

81 Views Asked by At

Suposse a job sequence of 6 jobs, as 3-5-4-2-6-1, that point the job 3 is attended in 1st place, and then the job 5,....

How could I represent this sequencies with binary code to use in metaheuristic Genetic Algorithms?

-- edited after ciuak solution --

The representation must have similar binary code to similar representations.

So 612345, must be similar to 612354.

1

There are 1 best solutions below

6
On

Easy. There are $6!$ combinations, so each number will represent a sequence.
The number will be in the form of $$ 5*4*3*2*a + 4*3*2*b + 3*2*c + 2*d + e $$ in binary.
And understanding the "jobs code" (in this example a=2,b=1,c=2,d=0,e=1):

  • We start with no numbers in our final sequence and we can pick from ${1,2,3,4,5,6}$.
  • a=2, so we pick the third element (first = 0). Our numbers to pick are now ${1,2,4,5,6}$ and our combination of jobs ${3}$ for now.
  • b=1, so we pick the second element. Our numbers to pick are now ${1,4,5,6}$ and our jobs combination is now ${3,2}$.
  • c=2, pick: {1,4,6} and jobs: {3,2,5}.
  • d=0, pick: {4,6} and jobs: {3,2,5,1}.
  • e=1, pick: {4} and jobs: {3,2,5,1,6}.
  • We are left with pick: {4} so we add that into the sequence: {3,2,5,1,6,4}.

This is the most efficient way (10 bits).
Our example numbers are 2,1,2,0,1 so the number we want to calculate is: $$ 120*a + 24*b + 6*c + 2*d + e = 240 + 24 + 12 + 0 + 1 = 277 = 100010101_2 $$ So your "jobs code" for 3,2,5,1,6,4 is $100010101$ in binary!