简体   繁体   中英

memory permutation random linq of very large list orderby

I am doing a permutation of a specific series of sequences that is 104 characters long. I was using plinq to generate the sequence but without a random order the results are never complex enough to be selected.

The problem is orderby with rnd.next and guid.newguid fills up memory and returns no results.

is there any solution to randomly selecting from a linq pattern in C#?

var query = 
             from sp1 in polar
                    ...
             from vp15 in polar                           
             where GetCompressionRatio(sp1+...+vp15)>1.5
             orderby rnd.Next(0, 100000000) * rnd.Next(0, 100000000)
             select sp1+...+vp15;


foreach (var element in query)
{
    //output
}

You are trying to solve two very different problems with the same query. Even if there is a clever way to do it, I would suggest you take it one step at a time.

First, generate a non random permutation. Than, apply some random permutation algorithm on the previous result. You can try the very simple Knuth Shuffle .

Your intention will be much more clear and the decomposition can give you significant advantages in testing and debugging.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM