public ResultsComposition RechercheCompositions(string json, string inputs, string outputs, int nmax, int tmax)
        {
            results = new ResultsComposition();

            corpus  = Corpus.charger(json);
            requete = Requete.charger(inputs, outputs);

            if (ValidationInputs() != "true")
            {
                results.error   = true;
                results.message = ValidationInputs();

                return(results);
            }

            initEspaceRecherche(tmax);


            time = DateTime.Now;
            //CompositionLargeur(tmax, nmax);
            CompositionProfondeur(tmax, nmax);
            results.timeTotal = (DateTime.Now - time).TotalSeconds;


            if (results.compositions.Count == 0)
            {
                results.error   = true;
                results.message = "Error : No Results.";
            }
            else
            {
                results.countCompositions = results.compositions.Count;
            }



            return(results);
        }
        public ResultsComposition RechercheCompositions(string json, string inputs, string outputs, int nmax, int tmax)
        {
            results = new ResultsComposition();

            corpus  = Corpus.charger(json);
            requete = Requete.charger(inputs, outputs);

            if (ValidationInputs() != "true")
            {
                results.error   = true;
                results.message = ValidationInputs();

                return(results);
            }


            time = DateTime.Now;

            initEspaceRecherche(tmax);

            results.countCompositions = 0;

            List <Composition> levelCurrent = new List <Composition>();
            List <Composition> levelNext    = new List <Composition>();

            levelCurrent.Add(new Composition(corpus, requete));
            solutions = new List <List <string> >();

            int numberCompositionsTested = 0;
            int distance = 0;

            while (levelCurrent.Count > 0 && tmax > distance++ && nmax > 0)
            {
                levelNext = new List <Composition>();

                //espaceRecherche = corpus.services;

                espaceRecherche = new List <Service>();
                foreach (string s in servicesPertinants[distance - 1])
                {
                    espaceRecherche.Add(corpus.hs[s]);
                }

                Composition bestNode = GetBestNode(levelCurrent);


                for (int i = 0; i < levelCurrent.Count && nmax > 0; i++)
                {
                    List <Composition> cpp = ConstructionComposition(levelCurrent[i]);

                    numberCompositionsTested += cpp.Count();

                    foreach (Composition newComposition in cpp)
                    {
                        if (newComposition.Complete())
                        {
                            solutions.Add(newComposition.services);
                            results.compositions.Add(newComposition);

                            if (--nmax <= 0)
                            {
                                break;
                            }
                        }
                        else if (levelNext.Contains(newComposition) == false)
                        {
                            levelNext.Add(newComposition);
                        }
                    }
                }

                levelCurrent.Clear();
                levelCurrent.AddRange(levelNext);
            }

            foreach (Composition c in results.compositions)
            {
                c.AddEnd();
            }

            if (results.compositions.Count == 0)
            {
                results.error   = true;
                results.message = "Error : No Results in " + numberCompositionsTested + " compositions.";
            }
            else
            {
                results.countCompositions = results.compositions.Count;
            }


            results.timeTotal = (DateTime.Now - time).TotalSeconds;

            return(results);
        }