Пример #1
0
        /// <summary>
        /// Run Algorithm
        /// </summary>
        /// <param name="NotVisited"></param>
        public void goAlgorithm(List <Scene> notVisited)
        {
            comp++;
            if (notVisited.Count == 0)
            {
                // Poda
                comp++;
                if (evaluation.isFactible(visited))
                {
                    memory += evaluation.memory;

                    evaluation.seeCombination(visited);

                    Console.WriteLine("Costo: " + evaluation.getCostCalendar(visited));

                    comp++;
                    if (evaluation.getCostCalendar(visited) <= bestCalendar.bestCost)   //Change best calendar
                    {
                        changeBestCalendar(visited);
                    }
                    memory += evaluation.memory;
                    asig   += evaluation.asig; comp += evaluation.comp;
                }
                else
                {
                    memory += evaluation.memory;
                }
                asig += evaluation.asig; comp += evaluation.comp;
            }
            else
            {
                asig++;
                memory += new Scene(0).valueMemory;
                foreach (Scene scene in notVisited)
                {
                    asig++;
                    // Combination
                    this.visited.Remove(scene); this.visited.Add(scene); asig += 2;

                    List <Scene> auxScene = evaluation.shallowClone(notVisited); asig++;
                    memory += auxScene.Count * new Scene(0).valueMemory;
                    auxScene.Remove(scene); asig++;


                    cantNodes++;
                    goAlgorithm(auxScene);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="stage"></param>
        public BranchAndBound(Stage stage)
        {
            evaluation = new Evaluating(stage);

            notVisited = evaluation.shallowClone(stage.scenes);
            //visited = evaluation.shallowClone(stage.scenes);
            runBB();
        }
        /********************************************* Generar la población inicial***********************************/
        /// <summary>
        /// Generate a start population. Create a father with the original list an
        /// the mother with the list reverse
        /// </summary>
        private void generateStartPopulation()
        {
            father = stage.scenes; asig++;
            List <Scene> aux = evaluating.shallowClone(stage.scenes); asig++; //pasar evaluating

            aux.Reverse(); asig++;
            mother = aux; asig++;

            memoryCycle += (father.Count * father[0].valueMemory) * 4;
            memoryOrder += (father.Count * father[0].valueMemory) * 4;
        }