Ejemplo n.º 1
0
        private static RunDefinitionBuffer PrepareRunDefinitionBuffer(SaveRunDefintionsCallback saveFunction, int bufferBeforeSave, StatusCallback statusFunction, int bufferBeforeStatus, List <AlgorithmParameter> allParameters)
        {
            //calculate the number of permutations for status updates
            var totalNumberOfIterations = Common.CalculateApproachCount(allParameters);

            //Create the buffer for saving the iterations
            return(new RunDefinitionBuffer(saveFunction, bufferBeforeSave,
                                           statusFunction, bufferBeforeStatus,
                                           totalNumberOfIterations));
        }
Ejemplo n.º 2
0
        public static async Task <int> GenerateAsync(ApproachDefinition approachDefinition, SaveRunDefintionsCallback saveFunction, int bufferBeforeSave = 100, StatusCallback statusFunction = null, int bufferBeforeStatus = 100)
        {
            var totalPermutations = 0;

            //the iteration of all the parameters changes the definition,
            //so we deep clone to ensure the original definition is not modified
            ApproachDefinition approach = approachDefinition.DeepClone <ApproachDefinition>();

            //Get all the parameters on all algorithms of the approach and initialize them
            List <AlgorithmParameter> allParameters = PrepareParameters(approach);

            //Get a total number of iterations expected for status updates
            RunDefinitionBuffer buffer = PrepareRunDefinitionBuffer(saveFunction, bufferBeforeSave, statusFunction, bufferBeforeStatus, allParameters);

            //Iterate all the possible combinations of the parameters, and invoke the save and status callbacks stored in the buffer
            //IterateAllParameters(approach, allParameters, buffer);
            await IterateAllParametersNoRecursion(approach, allParameters, buffer);

            //Make sure all items are saved and status updated
            buffer.FlushBuffer();

            totalPermutations = buffer.PermutationCount;

            return(totalPermutations);
        }