Ask for help on optimizing a permutation problem - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Ask for help on optimizing a permutation problem

Posts: 1Member
Hi everyone,

I have one optimization problem with pressed deadline. It looks simple to understand but puzzle me for a while.

Here is the description:

We have a 5*10 Matrix. Each column out of 10 have several non-zero elements and are arranged on the top closely. The rest of the column will be all zeros.

Now we pick up one non-zero element from each column and put the 10 elements together to get a new vector.

Then it comes to the problem that how to find out all possible vectors? The original source code use a 10-level for loops to get all possible vectors, but it is really slow. And my task is find another algorithm or Matlab function to replace the 10 level for loops.

If you could help, please! Only an idea is also more than welcomed! Thank you in advance!

Here is an example matrix and vector:

1 2 4 5 3 1 2 1 7 2

3 3 8 6 5 3 3 2 9 5

7 5 9 7 0 4 5 4 0 6

0 6 0 8 0 5 7 5 0 7

0 0 0 9 0 0 0 8 0 0

a possible vector:

(1 3 4 6 3 5 2 1 9 2 )