示例#1
0
        /// <summary>
        /// Performs the varaible flow modelling given the foundation IM and the vector representing the independent variable.
        /// </summary>
        /// <param name="IMf"></param>
        /// <param name="independent"></param>
        /// <returns></returns>
        private static IncidenceMatrix VariableFlowModelling(IncidenceMatrix IMf, int[] independent)
        {
            IncidenceMatrix[] IMSet = AllWorkflows(IMf, independent);
            int LeastModified       = LibishScheduler.LeastModified(IMSet, IMf);

            return(IMSet[LeastModified]);
            // code for genetic algorithm
        }
示例#2
0
        public static Workflow ScheduleWorkflow(string name, string description, List <Data> inputs, List <Data> outputs, List <WorkflowComponent> components, ReversalMode mode)
        {
            // Redirect to right scheduler method
            if (mode == ReversalMode.Global)
            {
                return(ScheduleWorkflowGlobal(name, description, inputs, outputs, components, GlobalReversalMode.Global));
            }
            else if (mode == ReversalMode.Legacy)
            {
                return(LibishScheduler.ScheduleWorkflow(name, description, inputs, outputs, components));
            }

            List <WorkflowComponent> workflowComponents = components.GetAllComponents();
            var allData = inputs.Concat(outputs).ToList();

            // 0. Sanity checks, check array is not more than 1 output
            NonReversibleSanityCheck(workflowComponents);

            // 1. Find Model-Variable matching. Which variables are inputs, and wich are outputs for each model
            MatchingDictionary outputsDict = MatchModelsWithVariables(inputs, allData, workflowComponents);

            // 2. Determine which models are reversed, and create reversed Workflows (Model or Global) to cater for them
            ReverseComponents(name, outputsDict, workflowComponents, out List <WorkflowComponent> matchedComponents, out List <WorkflowComponent> reversedComponents);

            // 3. Cluster reversed components joint by non-reversible variables (e.g. arrays)
            List <WorkflowComponent> reversedClusteredComponents = ClusterReversedModel(name, allData, matchedComponents, reversedComponents, mode, components);

            // 4. Cluster Strongly Connected Components to get an acyclic graph
            List <WorkflowComponent> clusteredComponents = ClusterStronglyConnectedComponents(name, allData, reversedClusteredComponents);

            // 5. Schedule the acyclic graph to get the final order of the components
            List <WorkflowComponent> scheduledComponents = ScheduleAcyclic(allData, clusteredComponents);

            return(new Workflow(name, description, inputs, outputs, components, scheduledComponents, false, mode.ToString())
            {
                DependencyAnalysis = new GraphBasedDependencyAnalysis(matchedComponents)
            });
        }