private static bool SubAssemsAreInOptNodesOrRestNodes(TreeCandidate option)
 {
     foreach (var seq in FrozenSequence)
     {
         if (seq.All(option.MovNodes.Contains) || seq.All(option.RefNodes.Contains))
         {
             return(true);
         }
         if (!seq.Any(option.MovNodes.Contains) && !seq.Any(option.RefNodes.Contains))
         {
             return(true);
         }
     }
     return(false);
 }
        protected static List <TreeCandidate> GetCandidates(HashSet <Component> A, double G = 0)
        {
            var gOptions   = new Dictionary <option, HashSet <int> >();
            var candidates = new List <TreeCandidate>();

            if (FrozenSequence.Count > 0)
            {
                // each of these frozen sequences must be considered as a subassembly
                //HashSet<Component> subAssem;
                if (MemoCandidates.ContainsKey(A))
                {
                    // If the memoOption has the key, then the options will be chosen which the components
                    //    of the frozen subassemblies are either all in the option.nodes or non of them are
                    //    in the option.nodes (meaning that it's in the rest)
                    candidates.AddRange(MemoCandidates[A].Where(SubAssemsAreInOptNodesOrRestNodes));
                    return(candidates);
                }
            }
            GenerateOptions(A, gOptions);
            //MemoOptions.Add(A, gOptions);

            foreach (var opt in gOptions.Keys)
            {
                var TC = new TreeCandidate();
                if (AssemblyEvaluator.EvaluateSub(Graph, A, opt.Nodes.Cast <Component>().ToList(), gOptions[opt], out TC.sa) > 0)
                {
                    TC.RefNodes = new HashSet <Component>(TC.sa.Install.Reference.PartNames.Select(n => (Component)Graph[n]));
                    TC.MovNodes = new HashSet <Component>(TC.sa.Install.Moving.PartNames.Select(n => (Component)Graph[n]));
                    //if (Math.Min (TC.RefNodes.Count, TC.MovNodes.Count) > 21)	//example constraint
                    //	continue;

                    var HR = H(TC.RefNodes);
                    var HM = H(TC.MovNodes);
                    TC.G = G;
                    TC.H = TC.sa.Install.Time + Math.Max(HR, HM);
                    candidates.Add(TC);
                }
            }
            MemoCandidates.Add(A, candidates);
            return(candidates);
        }