/// <summary> /// retruns the inputs and output data objects for the given modelobjects collection /// </summary> /// <param name="modelobjects"></param> /// <param name="dataobjects"></param> /// <returns></returns> public static object[] GetInputOutputs(List <WorkflowComponent> modelobjects, List <Data> dataobjects) { Matrix <double> iMatrix = WorkflowComponent.GetIncidenceMatrix(modelobjects, dataobjects); object[] vInOut = new object[2]; var vInputs = new List <Data>(); var vOutputs = new List <Data>(); for (int ncount = 0; ncount < iMatrix?.ColumnCount; ncount++) { if ((MatrixCalculators.FindValueInVector(iMatrix.Column(ncount), 2) > 0) & (MatrixCalculators.FindValueInVector(iMatrix.Column(ncount), 3) > 0)) { vOutputs.Add(dataobjects[ncount]); } else if (MatrixCalculators.FindValueInVector(iMatrix.Column(ncount), 3) > 0) { vOutputs.Add(dataobjects[ncount]); } else if (MatrixCalculators.FindValueInVector(iMatrix.Column(ncount), 2) > 0) { vInputs.Add(dataobjects[ncount]); } } vInOut[0] = vInputs; vInOut[1] = vOutputs; return(vInOut); }
/// <summary> /// Converts an incidence matrix to design structure matrix. /// </summary> /// <param name="iMatrix"></param> /// <returns></returns> public static Matrix <double> ImmtoDsm(Matrix <double> iMatrix) { // converts imm to dsm var vDsm = new DenseMatrix(iMatrix.RowCount, iMatrix.RowCount); MatrixCalculators.Eye(vDsm); double[,] vSpRowCol = MatrixCalculators.FindValue(iMatrix, 3); for (int nsprow = 0; nsprow < vSpRowCol.GetLength(0); nsprow++) { Vector <double> vSpInp = MatrixCalculators.FindLocValueInVector(iMatrix.Column((int)vSpRowCol[nsprow, 1]), 2); if (vSpInp != null) { for (int nvSpInp = 0; nvSpInp < vSpInp.Count; nvSpInp++) { vDsm[(int)vSpRowCol[nsprow, 0], (int)vSpInp[nvSpInp]] = 1; } } } return(vDsm); }