public ResultsDecouverte RechercheServices(string json, string inputs, string outputs)
        {
            results = new ResultsDecouverte();

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

            if (ValidationInputs() != "true")
            {
                results.error   = true;
                results.message = "Error : Corpus Null";

                return(results);
            }

            foreach (Service s in corpus.services)
            {
                bool conditionInputs  = true;
                bool conditionOutputs = true;

                foreach (string i in s.input)
                {
                    //if (Matching.Include(corpus, requete.input, i) == false)
                    if (requete.input.Contains(i) == false)
                    {
                        conditionInputs = false;
                    }
                }

                foreach (string o in requete.output)
                {
                    //if (Matching.Include(corpus, s.output, o) == false)
                    if (s.output.Contains(o) == false)
                    {
                        conditionOutputs = false;
                    }
                }

                if (conditionInputs && conditionOutputs)
                {
                    results.services.Add(s);
                }
            }

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

            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);
            }

            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);
        }