Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Counting # of times a sequence occurs

Subject: Counting # of times a sequence occurs

From: Diego Zegarra

Date: 12 Feb, 2009 19:07:02

Message: 1 of 1

I am having trouble on thinking what the most efficient way to do this would be, since I dont want to do too many calculations that just makes the code slow. This is the data I want to work with,

S_Seq = cell(4,1)
S_Seq{1,1} {1,1} = [3,19,10,18,17,12,9,13,6,7]
S_Seq{1,1} {2,1} = [1,20,16,14,5,15,4,8,2,11]
S_Seq{2,1} {1,1} = [17,18,12,19,10,13,3,9,7,6]
S_Seq{2,1} {2,1} = [1,20,16,14,5,15,4,8,2,11]
S_Seq{3,1} {1,1} = [3,12,9,17,18,10,13,6,1,7]
S_Seq{3,1} {2,1} = [19,5,15,11,16,14,20,4,8,2]
S_Seq{4,1} {1,1} = [3,12,9,17,18,10,13,6,2,8]
S_Seq{4,1} {2,1} = [19,5,1,20,15,11,16,14,7,4]

I have 20 jobs to be scheduled in two machines, so I get the schedule of machine 1 being Seq_...{1,1} and machine 2 being Seq_...{1,1}. I have 4 different schedules shown here.

I want to check how many times is each job sequence occurs in this four schedules. So for example I want to check how many times is job 11 scheduled after job 2. The first and second schedule do have this sequence but neither the third or fourth have it. So then only 2 out of the 4 schedules have it, I want to calculate this for every possible sequence as I need to create a matrix of numJobs x numJobs (20x20) where every possible sequence is accounted for. I have problems that have up to 120 jobs so the matrix gets really big, 14,400 entries.

I know I can check for every single one of this possible sequences, however I am trying to see if anyone knows a better and more efficient way to do that.

Any help will be greatly appreciated, thanks a lot!

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us