Пример #1
0
        public MatrixBasedDependencyAnalysis(IEnumerable <WorkflowComponent> models)
        {
            ModelsList = models?.ToList() ?? throw new NullReferenceException();

            List <Data> data = models.GetAllData();

            //Model-Based Incidence Matrix
            IM = LibishMatrixCalculators.GetIncidenceMatrix(models.ToList(), data);
            // Model-Based DSM for model forward tracing
            DSM = CreateDSM(IM);
            // Model-Based transposed DSM for model backward tracing
            DSMT = DSM.Transpose();

            Models       = models.ToArray();
            ModelIndices = Models.Select((m, i) => new { m.Id, Index = i }).ToDictionary(m => m.Id, m => m.Index);

            // Variable-Based Incidence Matrix
            Matrix <double> VBIM = IM.Transpose();

            // Variable-Based DSM for data forward tracing
            VBDSM = CreateDSM(VBIM);
            // Variable-Based transposed DSM for data backward tracing
            VBDSMT = VBDSM.Transpose();

            DataIndices = LibishMatrixCalculators.GetDataIndices(data);
            var allData = data.ToDictionary(d => d.Id);

            Data = new Data[DataIndices.Count];
            foreach (KeyValuePair <string, int> kvp in DataIndices)
            {
                Data[kvp.Value] = allData[kvp.Key];
            }
        }
Пример #2
0
        /// <summary>
        /// Given the Model Objects, data objects and the vector(vIndep) in which '1' represent an independent variables , this function creates
        /// a subprocess after performing the computational proces modelling
        /// </summary>
        /// <param name="name"></param>
        /// <param name="components"></param>
        /// <param name="dataObjects"></param>
        /// <param name="independent"></param>
        /// <returns></returns>
        public static Workflow ScheduleWorkflow(string name, string description, List <Data> inputs, List <Data> outputs, List <WorkflowComponent> components)
        {
            explorationWatch.Restart();
            List <Data> data = components.GetAllData(inputs, out int[] independent);

            // Incidence matrices for the workfow
            IncidenceMatrix IMf = LibishMatrixCalculators.GetIncidenceMatrix(components, data);
            IncidenceMatrix IMi = VariableFlowModelling(IMf, independent);
            // Model-based DSM
            DesignStructureMatrix DSM = IMMtoDSM(IMi);
            // Locates SCCs
            List <Cluster> clusters = Decompose(DSM);
            // SCC-based incidence matrix
            IncidenceMatrix IMU = CreateUpMatrix(IMi, clusters);
            // SCC-based DSM
            DesignStructureMatrix DSMU = IMMtoDSM(IMU);
            // Orders the models, so there is only feed-forward
            List <int> order = SequenceDsm(DSMU);

            // Creates the workflows for the reversed models
            WorkflowComponent[] processedComponents = CreateReversedModels(IMi, IMf, components, data, clusters, name);
            // Creates the workflows for the SCCs (default order)
            List <WorkflowComponent> clusteredComponents = CreateSCCs(processedComponents, clusters, data, name);
            // Applies the order (vDsmArr) to the models
            List <WorkflowComponent> scheduledComponents = Schedule(clusteredComponents, order);
            // Enables dependency analysis
            var dependencyAnalysis = new MatrixBasedDependencyAnalysis(processedComponents);

            return(new Workflow(name, description, inputs, outputs, components, scheduledComponents)
            {
                DependencyAnalysis = dependencyAnalysis
            });
        }