Пример #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
            });
        }
Пример #3
0
        /// <summary>
        /// This function identifies the SCC (from vClus) in the vResultMod, then groups it and therafter combines it with other models in the vResultMod and return it as a cWfmCollection
        /// </summary>
        /// <param name="components"></param>
        /// <param name="clusters"></param>
        /// <param name="data"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        private static List <WorkflowComponent> CreateSCCs(WorkflowComponent[] components, List <Cluster> clusters, List <Data> data, string name)
        {
            var vResultSub = new List <WorkflowComponent>();

            for (int c = 0; c < clusters.Count; c++)
            {
                Cluster cluster = clusters[c];
                if (cluster.Count == 1)
                {
                    vResultSub.Add(components[cluster[0]]);
                }
                else
                {
                    var sccComponents = new List <WorkflowComponent>();
                    foreach (int r in cluster)
                    {
                        sccComponents.Add(components[r]);
                    }
                    (List <Data> inputs, List <Data> outputs) = LibishMatrixCalculators.GetInputOutputs(sccComponents, data);

                    // Set inputs and outputs of this scc to
                    var solvers = new List <ISolver>()
                    {
                        new FixedPointSolver()
                    };
                    string sccName = Workflow.GetSCCWorkflowName(name, components, sccComponents);
                    var    scc2    = new WorkflowSCC(sccName, "", inputs, outputs, sccComponents, sccComponents, solvers);

                    vResultSub.Add(scc2);
                }
            }
            return(vResultSub);
        }
Пример #4
0
 public static bool IsModelReversed(this IncidenceMatrix IM, int model, IncidenceMatrix IMf) => !LibishMatrixCalculators.CompareAssigned(IMf, IM, model);
Пример #5
0
 private static bool CompareTwoModelsIfModified(Vector <double> rowf, Vector <double> rowi) => !LibishMatrixCalculators.CompareAssigned(rowf, rowi);
Пример #6
0
 /// <summary>
 /// Given a single incidence matrix this function convertes it to a dsm and returns it.
 /// </summary>
 /// <param name="IMM"></param>
 /// <returns></returns>
 private static DesignStructureMatrix IMMtoDSM(IncidenceMatrix IMM) => LibishMatrixCalculators.IncidenceMatrixToDesignStructureMatrix(IMM);