public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            var service = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;

            if (service != null && value != null)
            {
                // ReSharper disable SuspiciousTypeConversion.Global
                var gridItem = provider as GridItem;
                // ReSharper restore SuspiciousTypeConversion.Global
                var propertyName = value.GetType().Name;
                if (gridItem != null)
                {
                    propertyName = gridItem.Label;
                }
                var label   = propertyName;
                var oldJson = JsonSerializerHelper.Serialize(value);
                using (var form = new CollectionEditorForm(string.Format("Edit {0}", propertyName), label, value))
                {
                    if (service.ShowDialog(form) == DialogResult.OK)
                    {
                        if (string.Compare(oldJson,
                                           JsonSerializerHelper.Serialize(value),
                                           StringComparison.InvariantCulture) != 0)
                        {
                            value = GenericCopier <object> .DeepCopy(form.Value);
                        }
                    }
                }
            }
            // ReSharper disable AssignNullToNotNullAttribute
            return(value);
            // ReSharper restore AssignNullToNotNullAttribute
        }
        public void Run()
        {
            string srcFile = GetType().Name + "1.bts";

            if (File.Exists(srcFile))
            {
                File.Delete(srcFile);
            }

            string dstFile = GetType().Name + "2.bts";

            if (File.Exists(dstFile))
            {
                File.Delete(dstFile);
            }

            try
            {
                // Create sample file and put some data into it
                CreateSampleFile(srcFile);

                // Open sample file in a generic way without specifying the item and index types
                using (var bf = BinaryFile.Open(srcFile))
                {
                    var src = bf as IGenericInvoker2;
                    if (src == null)
                    {
                        // This could be a BinIndexedFile or some legacy file that we no longer support.
                        // Even though BinaryFile supports RunGenericMethod() with one generic argument,
                        // for the purposes of this demo we will only show using it with two that IEnumerableFeed has.
                        Console.WriteLine("File {0} does not support reading through IEnumerableFeed<,>", srcFile);
                        return;
                    }

                    // Print content of the source file
                    Console.WriteLine("Source file\n{0}", Utils.DumpFeed(src));

                    // We need a class that implements IGenericCallable2<,>
                    // As an alternative, "this" class could implement it
                    var callable = new GenericCopier();

                    // Run generic method on the callable class, passing string as a parameter to it
                    long copied = src.RunGenericMethod(callable, dstFile);

                    // Done
                    Console.WriteLine("{0} items was copied from {1} to {2}", copied, srcFile, dstFile);
                }
            }
            finally // Cleanup
            {
                if (File.Exists(srcFile))
                {
                    File.Delete(srcFile);
                }
                if (File.Exists(dstFile))
                {
                    File.Delete(dstFile);
                }
            }
        }
Esempio n. 3
0
        public static int StepWalking(int num)
        {
            if (num < 0 || num > 15)
            {
                return(-1);
            }

            var stepIncrements = new List <int>();

            stepIncrements.Add(1); //Possible step increments
            stepIncrements.Add(2);

            //List of valid step combinations
            var stepCombinations = new List <List <int> >();

            //Breadth-first search
            var queue = new List <List <int> >();

            queue.Add(new List <int> {
                1
            });                             //Arbitrary low starting values to use iterative approach
            queue.Add(new List <int> {
                1, 1
            });

            while (queue.Count != 0)
            {
                var nextQueue = new List <List <int> >();

                foreach (var stepList in queue)
                {
                    var sumOfSteps = stepList.Sum(x => Convert.ToInt32(x));

                    //Add step combination if step list adds up to number of stairs (num)
                    if (sumOfSteps == num)
                    {
                        stepCombinations.Add(stepList);
                        continue;
                    }

                    //Use both 1 and 2 step increments
                    foreach (var increment in stepIncrements)
                    {
                        if (sumOfSteps + increment <= num)
                        {
                            //If not exceeding total number of stairs, take further steps with new queue
                            var stepListCopy = GenericCopier <List <int> > .DeepCopy(stepList);

                            stepListCopy.Add(increment);
                            nextQueue.Add(stepListCopy);
                        }
                    }
                }

                queue = nextQueue;
            }

            return(stepCombinations.Count);
        }
        private void ResetProperties()
        {
            Title = OriginalTitle;


            TimesheetId = OriginalTimesheetId;


            // Unhook propertyChanged eventhandlers for ProjectTimeItems
            if (ProjectTimeItems != null)
            {
                ListUtility.AttachPropertyChangedEventHandlers(ProjectTimeItems, ProjectTimeItems_Item_PropertyChanged, attach: false);
            }
            ProjectTimeItems = OriginalProjectTimeItems == null ? null : GenericCopier <ObservableCollection <ObservableProjectTaskTimesheetItem> > .DeepCopy(OriginalProjectTimeItems);

            // Hookup propertyChanged eventhandlers for ProjectTimeItems
            if (ProjectTimeItems != null)
            {
                ListUtility.AttachPropertyChangedEventHandlers(ProjectTimeItems, ProjectTimeItems_Item_PropertyChanged, attach: true);
            }


            // Unhook propertyChanged eventhandlers for NonProjectActivityItems
            if (NonProjectActivityItems != null)
            {
                ListUtility.AttachPropertyChangedEventHandlers(NonProjectActivityItems, NonProjectActivityItems_Item_PropertyChanged, attach: false);
            }
            NonProjectActivityItems = OriginalNonProjectActivityItems == null ? null : GenericCopier <ObservableCollection <ObservableProjectTaskTimesheetItem> > .DeepCopy(OriginalNonProjectActivityItems);

            // Hookup propertyChanged eventhandlers for NonProjectActivityItems
            if (NonProjectActivityItems != null)
            {
                ListUtility.AttachPropertyChangedEventHandlers(NonProjectActivityItems, NonProjectActivityItems_Item_PropertyChanged, attach: true);
            }


            RequiredHours = OriginalRequiredHours == null ? null : GenericCopier <ObservableCollection <TimeSpan> > .DeepCopy(OriginalRequiredHours);


            TotalRequiredHours = OriginalTotalRequiredHours;


            // Unhook propertyChanged eventhandlers for DummyTimeEntry
            if (DummyTimeEntry != null)
            {
                DummyTimeEntry.PropertyChanged -= DummyTimeEntry_PropertyChanged;
            }
            DummyTimeEntry = OriginalDummyTimeEntry == null ? null : GenericCopier <ObservableTimeEntry> .DeepCopy(OriginalDummyTimeEntry);

            // Hookup propertyChanged eventhandlers for DummyTimeEntry
            if (DummyTimeEntry != null)
            {
                DummyTimeEntry.PropertyChanged += DummyTimeEntry_PropertyChanged;
            }


            DummyValueTypeCollection = OriginalDummyValueTypeCollection == null ? null : GenericCopier <ObservableCollection <int> > .DeepCopy(OriginalDummyValueTypeCollection);
        }
Esempio n. 5
0
        private GenericCopier CreateGenericCopier()
        {
            var cp = new GenericCopier();

            cp.SetCopyCmd(CopyType.GsUtilCp, "echo");
            cp.SetCopyCmd(CopyType.Cp, "echo");
            cp.SetCopyCmd(CopyType.Http, "echo");

            return(cp);
        }
        private void ResetProperties()
        {
            Title = OriginalTitle;


            TimesheetId = OriginalTimesheetId;


            // Unhook propertyChanged eventhandlers for ProjectTimeItems
            if (ProjectTimeItems != null)
            {
                ListUtility.AttachPropertyChangedEventHandlers(ProjectTimeItems, ProjectTimeItems_Item_PropertyChanged, attach: false);
            }
            ProjectTimeItems = OriginalProjectTimeItems == null ? null : GenericCopier <ObservableCollection <ObservableProjectTaskTimesheetItem> > .DeepCopy(OriginalProjectTimeItems);

            // Hookup propertyChanged eventhandlers for ProjectTimeItems
            if (ProjectTimeItems != null)
            {
                ListUtility.AttachPropertyChangedEventHandlers(ProjectTimeItems, ProjectTimeItems_Item_PropertyChanged, attach: true);
            }


            // Unhook propertyChanged eventhandlers for NonProjectActivityItems
            if (NonProjectActivityItems != null)
            {
                ListUtility.AttachPropertyChangedEventHandlers(NonProjectActivityItems, NonProjectActivityItems_Item_PropertyChanged, attach: false);
            }
            NonProjectActivityItems = OriginalNonProjectActivityItems == null ? null : GenericCopier <ObservableCollection <ObservableProjectTaskTimesheetItem> > .DeepCopy(OriginalNonProjectActivityItems);

            // Hookup propertyChanged eventhandlers for NonProjectActivityItems
            if (NonProjectActivityItems != null)
            {
                ListUtility.AttachPropertyChangedEventHandlers(NonProjectActivityItems, NonProjectActivityItems_Item_PropertyChanged, attach: true);
            }


            RequiredHours = OriginalRequiredHours == null ? null : GenericCopier <ObservableCollection <TimeSpan> > .DeepCopy(OriginalRequiredHours);


            TotalRequiredHours = OriginalTotalRequiredHours;


            // Unhook propertyChanged eventhandlers for Totals
            if (Totals != null)
            {
                ListUtility.AttachPropertyChangedEventHandlers(Totals, Totals_Item_PropertyChanged, attach: false);
            }
            Totals = OriginalTotals == null ? null : GenericCopier <ObservableCollection <ObservableHoursSummary> > .DeepCopy(OriginalTotals);

            // Hookup propertyChanged eventhandlers for Totals
            if (Totals != null)
            {
                ListUtility.AttachPropertyChangedEventHandlers(Totals, Totals_Item_PropertyChanged, attach: true);
            }
        }
Esempio n. 7
0
        internal void AddVehicles(List <Vehicle> vehicles, Problem problem)
        {
            //Copiar los vehículos y añadir depósitos al inicio y al final
            foreach (var vehicle in vehicles)
            {
                var depot = problem.Requests.Find(t => t.ID_Unique == 0);
                vehicle.Requests.Insert(0, GenericCopier <Request> .DeepCopy(depot));
                depot.Origin = false;
                vehicle.Requests.Add(GenericCopier <Request> .DeepCopy(depot));
            }

            Vehicles = vehicles.ToList();
        }
        public void AcceptChanges()
        {
            _projectCode.AcceptChanges();
            OriginalProjectCode = GenericCopier <ObservablePickListItem> .DeepCopy(_projectCode);


            _taskCode.AcceptChanges();
            OriginalTaskCode = GenericCopier <ObservablePickListItem> .DeepCopy(_taskCode);


            foreach (var item in _timeEntries)
            {
                item.AcceptChanges();
            }
            OriginalTimeEntries = GenericCopier <ObservableCollection <ObservableTimeEntry> > .DeepCopy(_timeEntries);


            ResetChangeTracking();
        }
        private void ResetProperties()
        {
            // Unhook propertyChanged eventhandlers for ProjectCode
            if (ProjectCode != null)
            {
                ProjectCode.PropertyChanged -= ProjectCode_PropertyChanged;
            }
            ProjectCode = OriginalProjectCode == null ? null : GenericCopier <ObservablePickListItem> .DeepCopy(OriginalProjectCode);

            // Hookup propertyChanged eventhandlers for ProjectCode
            if (ProjectCode != null)
            {
                ProjectCode.PropertyChanged += ProjectCode_PropertyChanged;
            }


            // Unhook propertyChanged eventhandlers for TaskCode
            if (TaskCode != null)
            {
                TaskCode.PropertyChanged -= TaskCode_PropertyChanged;
            }
            TaskCode = OriginalTaskCode == null ? null : GenericCopier <ObservablePickListItem> .DeepCopy(OriginalTaskCode);

            // Hookup propertyChanged eventhandlers for TaskCode
            if (TaskCode != null)
            {
                TaskCode.PropertyChanged += TaskCode_PropertyChanged;
            }


            // Unhook propertyChanged eventhandlers for TimeEntries
            if (TimeEntries != null)
            {
                ListUtility.AttachPropertyChangedEventHandlers(TimeEntries, TimeEntries_Item_PropertyChanged, attach: false);
            }
            TimeEntries = OriginalTimeEntries == null ? null : GenericCopier <ObservableCollection <ObservableTimeEntry> > .DeepCopy(OriginalTimeEntries);

            // Hookup propertyChanged eventhandlers for TimeEntries
            if (TimeEntries != null)
            {
                ListUtility.AttachPropertyChangedEventHandlers(TimeEntries, TimeEntries_Item_PropertyChanged, attach: true);
            }
        }
Esempio n. 10
0
        static bool BruteForce(int x, int y, int trialValue)
        {
            RemoveNeighbours(x, y, spaces[x, y][trialValue]);

            Solving();

            if (Check())
            {
                spaces = GenericCopier <List <int> [, ]> .DeepCopy(spacesSave);

                grid = GenericCopier <char[, ]> .DeepCopy(gridSave);

                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 11
0
        public static List <Solution> Optimization(RunMetaheuristicInput input)
        {
            var problems = input.Problems;

            //Set randomized value.
            _random = input.Random;
            List <Solution> Solutions = new List <Solution>();

            var default_Metaheuristic = Constants.TypeMetaheuristics.ILS;

            IMetaheuristic metaheuristic = MetaheuristicFactory.CreateMetaheuristic(default_Metaheuristic, input.HeuristicSettings, input.Problems.First(), input.Random);



            //Ejecutar cada problema.
            foreach (var problem in problems)
            {
                //Primer paso. Preprocesar los problemas (ajustar ventanas de tiempo cuando sea posible).
                SplashGlobalData.SetSplashData(Constants.SPLASH_NAME_PROBLEM, problem.ID_Problem);
                SplashGlobalData.SetSplashData(Constants.SPLASH_PROGRESS, 0.0);
                //Create Solution
                for (int number_Repetition = 0; number_Repetition < input.HeuristicSettings.MaxRepetitions; number_Repetition++)
                {
                    var      watch    = System.Diagnostics.Stopwatch.StartNew();
                    Solution solution = new Solution(problem.ID_Problem);
                    DARPAlgorithms.BuildInitialSolution(ref solution, problem, ref _random);
                    solution.InitialSolution = GenericCopier <Solution> .DeepCopy(solution);

                    //Update Splash.
                    SplashGlobalData.SetSplashData(Constants.SPLASH_NUMBER_REPETITION, number_Repetition + 1);
                    SplashGlobalData.SetSplashData(Constants.SPLASH_PROGRESS, Convert.ToDouble(SplashGlobalData.GetSplashData <double>(Constants.SPLASH_PROGRESS)) + 1);

                    //Execute Heuristic
                    metaheuristic.ExecuteMetaheuristic(ref solution);
                    watch.Stop();
                    solution.ExecutionTime = watch.ElapsedMilliseconds;
                    Solutions.Add(solution);
                    //Validation.Validator.ValidateSolution(ref solution, problem);
                }
            }

            return(Solutions);
        }
        public void AcceptChanges()
        {
            OriginalTitle = _title;


            OriginalTimesheetId = _timesheetId;


            foreach (var item in _projectTimeItems)
            {
                item.AcceptChanges();
            }
            OriginalProjectTimeItems = GenericCopier <ObservableCollection <ObservableProjectTaskTimesheetItem> > .DeepCopy(_projectTimeItems);


            foreach (var item in _nonProjectActivityItems)
            {
                item.AcceptChanges();
            }
            OriginalNonProjectActivityItems = GenericCopier <ObservableCollection <ObservableProjectTaskTimesheetItem> > .DeepCopy(_nonProjectActivityItems);


            OriginalRequiredHours = GenericCopier <ObservableCollection <TimeSpan> > .DeepCopy(_requiredHours);


            OriginalTotalRequiredHours = _totalRequiredHours;


            foreach (var item in _totals)
            {
                item.AcceptChanges();
            }
            OriginalTotals = GenericCopier <ObservableCollection <ObservableHoursSummary> > .DeepCopy(_totals);


            ResetChangeTracking();
        }
        public void AcceptChanges()
        {
            OriginalTitle = _title;


            OriginalTimesheetId = _timesheetId;


            foreach (var item in _projectTimeItems)
            {
                item.AcceptChanges();
            }
            OriginalProjectTimeItems = GenericCopier <ObservableCollection <ObservableProjectTaskTimesheetItem> > .DeepCopy(_projectTimeItems);


            foreach (var item in _nonProjectActivityItems)
            {
                item.AcceptChanges();
            }
            OriginalNonProjectActivityItems = GenericCopier <ObservableCollection <ObservableProjectTaskTimesheetItem> > .DeepCopy(_nonProjectActivityItems);


            OriginalRequiredHours = GenericCopier <ObservableCollection <TimeSpan> > .DeepCopy(_requiredHours);


            OriginalTotalRequiredHours = _totalRequiredHours;


            _dummyTimeEntry.AcceptChanges();
            OriginalDummyTimeEntry = GenericCopier <ObservableTimeEntry> .DeepCopy(_dummyTimeEntry);


            OriginalDummyValueTypeCollection = GenericCopier <ObservableCollection <int> > .DeepCopy(_dummyValueTypeCollection);


            ResetChangeTracking();
        }
Esempio n. 14
0
        private void SolveClick(object sender, RoutedEventArgs e)
        {
            #region Parsing
            Reset();

            ReadData();
            #endregion

            #region Pencil
            for (int x = 0; x < 9; x++)
            {
                for (int y = 0; y < 9; y++)
                {
                    #region Setup
                    int box = ((x / 3) * 3) + (y / 3);

                    if (grid[x, y] != ' ')
                    {
                        spaces[x, y].Add(int.Parse(grid[x, y].ToString()));
                        continue;
                    }
                    for (int i = 1; i <= 9; i++)
                    {
                        spaces[x, y].Add(i);
                    }
                    #endregion

                    #region Pencil by Box
                    for (int a = (box / 3) * 3; a < ((box / 3) * 3) + 3; a++)
                    {
                        for (int b = (box % 3) * 3; b < ((box % 3) * 3) + 3; b++)
                        {
                            if (grid[a, b] != ' ')
                            {
                                spaces[x, y].Remove(int.Parse(grid[a, b].ToString()));
                            }
                        }
                    }
                    #endregion

                    #region Pencil by Row
                    for (int i = 0; i < 9; i++)
                    {
                        if (grid[x, i] != ' ')
                        {
                            spaces[x, y].Remove(int.Parse(grid[x, i].ToString()));
                        }
                    }
                    #endregion

                    #region Pencil by Column
                    for (int i = 0; i < 9; i++)
                    {
                        if (grid[i, y] != ' ')
                        {
                            spaces[x, y].Remove(int.Parse(grid[i, y].ToString()));
                        }
                    }
                    #endregion
                }
            }
            #endregion

            #region Solving
            Solving();

            if (Check())
            {
                #region Brute Forceing
                spacesSave = GenericCopier <List <int> [, ]> .DeepCopy(spaces);

                gridSave = GenericCopier <char[, ]> .DeepCopy(grid);

                for (int x = 0; x < 9; x++)
                {
                    for (int y = 0; y < 9; y++)
                    {
                        if (spaces[x, y].Count > 1)
                        {
                            for (int i = 0; i < spaces[x, y].Count; i++)
                            {
                                if (BruteForce(x, y, i))
                                {
                                    goto Exit;
                                }
                            }
                        }
                    }
                }
                #endregion
            }
Exit:
            #endregion

            #region Display
            Display();
            Sudoku.IsEnabled  = false;
            Choices.IsEnabled = false;

            if (Check())
            {
                MessageBox.Show("Sorry, this is the best I could do.");
            }
            else
            {
                MessageBox.Show("Solution Found!");
            }
            #endregion
        }
Esempio n. 15
0
        public void ExecuteMetaheuristic(ref Solution bestSolution)
        {
            int      bestIteration   = 0;
            Solution partialSolution = GenericCopier <Solution> .DeepCopy(bestSolution);

            int            control_Diversify = 0;
            SummaryDetails summary           = new SummaryDetails();

            Splash.SplashGlobalData.SetSplashData(Constants.SPLASH_BEST_SOLUTION, bestSolution.Fitness);
            double pertCost = 0, vnsCost = 0;

            int iterations = 0;

            //Guardar coste inicial.
            summary.ILSSummary.InitCost = bestSolution.Parc_Cost;
            for (int i = 0; iterations < _ilsSettings.MaxILSIterations && i < _ilsSettings.MaxILSNoImprovement; i++)
            {
                //Control de intensificación-diversificación.
                if (i % _DIVERSIFY_MAX == 0)
                {
                    _diversify--;
                }
                _diversify = _diversify < 3 ? 3 : _diversify;
                if (i % 100 == 0)
                {
                    _diversify = _DIVERSIFY_MAX;
                }
                //Guardar valores estadísticos.
                var initCost    = partialSolution.Parc_Cost;
                var initFitness = partialSolution.Fitness;

                Splash.SplashGlobalData.SetSplashData(Constants.SPLASH_ILS_TOTAL_ITERATIONS, iterations + 1);
                //Apply VNS local search.
                _vns.ExecuteMetaheuristic(ref partialSolution);


                //Validator.ValidateSolution(ref partialSolution, _problem);
                bool feasible = partialSolution.Feasible;
                //Guardar valores estadísticos.
                vnsCost = Costs.ParcialCostSolution(partialSolution, _problem); // partialSolution.Parc_Cost;
                var vnsFitness = partialSolution.Fitness;

                if (vnsFitness < initFitness)
                {
                    summary.ILSSummary.TotalImpPrevious++; //Incrementar el número de veces que se mejora la solución previa (perturbada).
                }
                if (bestSolution.Feasible)
                {
                    if (partialSolution.Feasible && (Math.Round(partialSolution.Fitness, 2) < Math.Round(bestSolution.Fitness, 2)))
                    {
                        bestSolution = GenericCopier <Solution> .DeepCopy(partialSolution);

                        //Actualizar la mejor solución con los nuevos parámetros.
                        control_Diversify = 0;
                        bestIteration     = i;
                        i          = 0;
                        _diversify = _DIVERSIFY_MAX;
                        summary.ILSSummary.BestIteration = iterations + 1; //Guardar mejor iteración encontrada.
                        summary.ILSSummary.TotalImpBest++;                 //Incrementar el número de veces que se mejora la mejor solución.
                        Singleton.Instance.UpdatePenaltyTerms(partialSolution);
                        Splash.SplashGlobalData.SetSplashData(Constants.SPLASH_ILS_IMPROVEMENTS, summary.ILSSummary.TotalImpBest);
                        Splash.SplashGlobalData.SetSplashData(Constants.SPLASH_BEST_SOLUTION, Math.Round(bestSolution.Fitness, 2));
                    }
                    else
                    {
                        control_Diversify++;
                    }
                }
                else
                {
                    if (partialSolution.Feasible || Math.Round(partialSolution.Fitness, 2) < Math.Round(bestSolution.Fitness, 2))
                    {
                        if (partialSolution.Feasible && summary.ILSSummary.FirstItFeasible == null)
                        {
                            summary.ILSSummary.FirstItFeasible = iterations + 1; //Guardar primera iteración factible.
                        }
                        bestSolution = GenericCopier <Solution> .DeepCopy(partialSolution);

                        control_Diversify = 0;
                        i          = 0;
                        _diversify = _DIVERSIFY_MAX;
                        summary.ILSSummary.BestIteration = iterations + 1; //Guardar mejor iteración encontrada.
                        summary.ILSSummary.TotalImpBest++;                 //Incrementar el número de veces que se mejora la mejor solución.
                        Singleton.Instance.UpdatePenaltyTerms(partialSolution);
                        //bestSolution.Fitness = Costs.EvaluationSolution(bestSolution, _problem);
                        Splash.SplashGlobalData.SetSplashData(Constants.SPLASH_ILS_IMPROVEMENTS, summary.ILSSummary.TotalImpBest);
                        Splash.SplashGlobalData.SetSplashData(Constants.SPLASH_BEST_SOLUTION, bestSolution.Fitness);
                    }
                    else
                    {
                        control_Diversify++;
                    }
                }

                if (control_Diversify > _diversify)
                {
                    partialSolution = GenericCopier <Solution> .DeepCopy(bestSolution);

                    control_Diversify = 0;
                }

                var perturbation = _perturbations.ExecutePerturbation(ref partialSolution);
                //Guardar valores estadísticos.
                pertCost = partialSolution.Parc_Cost;
                var pertFitness = partialSolution.Fitness;

                //Añadir resumen de la iteración.
                summary.VNSOperators.Add(new VNSOperators(iterations, _vns.ShiftInter, 0, _vns.WRI_IntraOP, _vns.IntraRouteInsertionOP, _vns.IntraSwap));
                summary.ILSEvolution.Add(new ILSEvolution(iterations, Math.Round(initCost, 2), Math.Round(initFitness, 2), Math.Round(vnsCost, 2), Math.Round(vnsFitness, 2), perturbation, Math.Round(pertFitness, 2), Math.Round(pertCost, 2), feasible));
                Splash.SplashGlobalData.SetSplashData(Constants.SPLASH_PROGRESS, Convert.ToDouble(Splash.SplashGlobalData.GetSplashData <double>(Constants.SPLASH_PROGRESS)) + _coef_Updater_Splash);
                //Guardar cambios de cada operador.



                iterations++;
            }

            //Recalcular con el proceso de 8 pasos y actualizar el coste.
            foreach (var vehicle in bestSolution.Vehicles)
            {
                DARPAlgorithms.EightStepsEvaluationProcedure(ref bestSolution, vehicle, _problem);
            }
            bestSolution.TotalDuration       = bestSolution.Vehicles.Sum(t => t.VehicleDuration);
            bestSolution.TimeWindowViolation = bestSolution.Vehicles.Sum(t => t.TotalTimeWindowViolation);
            bestSolution.RideTimeViolation   = bestSolution.Vehicles.Sum(r => r.TotalRideTimeViolation);
            bestSolution.DurationViolation   = bestSolution.Vehicles.Sum(d => d.TotalDurationViolation);
            bestSolution.LoadViolation       = bestSolution.Vehicles.Sum(l => l.TotalLoadViolation);
            bestSolution.TotalWaitingTime    = bestSolution.Vehicles.Sum(t => t.TotalWaitingTime);
            DARPAlgorithms.UpdateConstraintsSolution(ref bestSolution, _problem);
            bestSolution.Fitness   = Costs.EvaluationSolution(bestSolution, _problem);
            bestSolution.Parc_Cost = Costs.ParcialCostSolution(bestSolution, _problem);

            summary.ILSSummary.TotalIterations = iterations + 1;
            summary.ILSSummary.FinalCost       = bestSolution.Parc_Cost;


            bestSolution.SummaryDetails = summary;
        }
Esempio n. 16
0
        public List <ProcessData> working()
        {
            if (estimate_data.Count == 0)
            {
                List <ProcessData> ready_queue = new List <ProcessData>();
                end_job_flag = new List <bool>();

                int limit = data.Sum(item => Convert.ToInt32(item.arrived_time)) + data.Sum(item => Convert.ToInt32(item.service_time));

                init();

                for (int time = 0; time < limit;)
                {
                    for (int i = 0; i < data.Count; i++)
                    {
                        if (Convert.ToInt32(data[i].arrived_time) <= time &&
                            !end_job_flag[Convert.ToInt32(data[i].no) - 1])
                        {
                            ready_queue.Add(data[i]);
                            // 작업 수행 확인
                            end_job_flag[Convert.ToInt32(data[i].no) - 1] = true;
                        }
                    }

                    if (ready_queue.Count > 0)
                    {
                        ready_queue = calculate(time, ready_queue);

                        estimate_data.Add(new ProcessData(new string[]
                        {
                            ready_queue[0].no,
                            ready_queue[0].pid,
                            ready_queue[0].priority,
                            "" + time,
                            ready_queue[0].service_time
                        }));

                        time += Convert.ToInt32(ready_queue[0].service_time);

                        ready_queue.RemoveAt(0);
                    }
                    else
                    {
                        time++;
                    }
                }

                List <ProcessData> time_data = GenericCopier <List <ProcessData> > .DeepCopy(estimate_data);

                time_data = Common.Sort_Default(time_data);
                data      = Common.Sort_Default(data);

                for (int idx = 0; idx < time_data.Count; idx++)
                {
                    delay_data[idx]  = Convert.ToInt32(time_data[idx].arrived_time) - Convert.ToInt32(data[idx].arrived_time);
                    return_data[idx] = delay_data[idx] + Convert.ToInt32(time_data[idx].service_time);
                }
            }

            return(estimate_data);
        }