Exemple #1
0
        static void Main(string[] args)
        {
            List <int> numeros = new List <int>();

            Data.createScenariosOfMovie();
            Data.createScenario1(5, 40, 0);  // location ,actors, posicion del escenario
            Data.createScenario2(6, 60, 1);  // location ,actors, posicion del escenario
            Data.createScenario3(7, 100, 2); // location ,actors, posicion del escenario
            Data.createScenario4(8, 80, 3);  // location ,actors, posicion del escenario
            Data.printScenarios();

            Data.createDays();
            Data.assignScenesToDay();
            Data.assignLocationsToDay();



            Data.performPmxInAllScenarios();
            Pmx.clearLists();
            Pmx.performOxInAllScenarios();



            Console.WriteLine("\n\n\n\n");
            Console.WriteLine("_____________________________________________ BRANCH AND BOUND ALGORITHM _____________________________________________\n");
            BranchAndBound BB = new BranchAndBound(movie.Scenarios, movie);

            BB.RunBB();

            Console.ReadKey();
        }
        /// <summary>
        /// Por cada escenario se hace una combinación con el fin
        /// de obtener el mejor calendario en relación al costo
        /// </summary>
        public void RunBB()
        {
            // Escenario 1
            cont             = 0; countA++;
            this.Combination = this.ShallowClone(Scenario1Scenes); countA++; countL++;
            SetActorParticipation(Movie.GetInstance().Scenarios[0].Actors, Scenario1Scenes); countL++;
            Console.WriteLine("|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°| ESCENARIO 1 |°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|\n\n"); countL++;
            MakeCombination(Scenario1Scenes, Scenario1Days, InitialCost1); countL++;
            FinalCost1 = BSSF.Min(); countA++; countL++;
            BSSF.Clear(); countL++;
            memorySize += Movie.GetInstance().Scenarios[0].MemoryCostForBB();
            BranchAndBound.ScenariosResults();
            countA = 0; countC = 0; cont = 0; countL = 0;

            // Escenario 2
            memorySize       = 0;
            cont             = 0; countA++;
            FirstTime        = true; countA++; countL++;
            this.Combination = this.ShallowClone(Scenario2Scenes); countA++; countL++;
            Console.WriteLine("|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°| ESCENARIO 2 |°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|\n\n"); countL++;
            SetActorParticipation(Movie.GetInstance().Scenarios[1].Actors, Scenario2Scenes); countL++;
            MakeCombination(Scenario2Scenes, Scenario2Days, InitialCost2); countL++;
            FinalCost2 = BSSF.Min(); countA++; countL++;
            BSSF.Clear(); countA++; countL++;
            memorySize += Movie.GetInstance().Scenarios[1].MemoryCostForBB();
            BranchAndBound.ScenariosResults();
            countA = 0; countC = 0; cont = 0; countL = 0;

            // Escenario 3
            memorySize       = 0;
            cont             = 0; countA++;
            FirstTime        = true; countA++; countL++;
            this.Combination = this.ShallowClone(Scenario3Scenes); countA++; countL++;
            SetActorParticipation(Movie.GetInstance().Scenarios[2].Actors, Scenario3Scenes); countL++;
            Console.WriteLine("|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°| ESCENARIO 3 |°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|\n\n"); countL++;
            MakeCombination(Scenario3Scenes, Scenario3Days, InitialCost3); countL++;
            FinalCost3 = BSSF.Min(); countA++; countL++;
            BSSF.Clear(); countL++;
            memorySize += Movie.GetInstance().Scenarios[2].MemoryCostForBB();
            BranchAndBound.ScenariosResults();
            countA = 0; countC = 0; cont = 0; countL = 0;

            // Escenario 4
            memorySize       = 0;
            cont             = 0; countA++;
            FirstTime        = true; countA++; countL++;
            this.Combination = this.ShallowClone(Scenario4Scenes); countA++; countL++;
            SetActorParticipation(Movie.GetInstance().Scenarios[3].Actors, Scenario4Scenes); countL++;
            Console.WriteLine("|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°| ESCENARIO 4 |°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|°|\n\n"); countL++;
            MakeCombination(Scenario4Scenes, Scenario4Days, InitialCost4); countL++;
            FinalCost4 = BSSF.Min(); countA++; countL++;
            BSSF.Clear(); countA++; countL++;
            memorySize += Movie.GetInstance().Scenarios[3].MemoryCostForBB();
            BranchAndBound.ScenariosResults();
            countA = 0; countC = 0; cont = 0; countL = 0;

            PrintCostComparison();
        }