public int PrepareALSLinkMan(int nPls) //QALS_Search { if (ALSLst != null) { return(ALSLst.Count()); } int ALSSizeMax = GNPXApp000.ALSSizeMax; int mx = 0; //tentative ID, reset later ALSLst = new List <UALS>(); List <int> singlyMan = new List <int>(); for (int nn = 1; nn <= nPls; nn++) { for (int tf = 0; tf < 27; tf++) { List <UCell> Pcells = pBDL.IEGetCellInHouse(tf, 0x1FF).ToList(); if (Pcells.Count < 1) { continue; } int szMax = Min(Pcells.Count, 8 - nn); szMax = Min(szMax, ALSSizeMax); //ALS size maximum value for (int sz = 1; sz <= szMax; sz++) { Combination cmb = new Combination(Pcells.Count, sz); while (cmb.Successor()) { int FreeB = 0; Array.ForEach(cmb.Index, q => FreeB |= Pcells[q].FreeB); if (FreeB.BitCount() != (sz + nn)) { continue; } List <UCell> Q = new List <UCell>(); Array.ForEach(cmb.Index, q => Q.Add(Pcells[q])); //Check for existence of ALS with the same configuration UALS UA = new UALS(mx++, sz, tf, FreeB, Q); if (!UA.IsPureALS()) { continue; } int hs = UA.GetHashCode(); if (singlyMan.Any(p => p == hs)) { UA.singly = false; } else { singlyMan.Add(hs); } ALSLst.Add(UA); } } } } ALSLst.Sort(); int ID = 0; ALSLst.ForEach(P => P.ID = ID++); // ALSLst.ForEach(P=>WriteLine(P)); return(ALSLst.Count()); }