/// <summary> /// Solves the increments array (<code>this.da</code>) using alpha and beta. /// Then updates the <code>this.incrementedParameters</code> array. /// NOTE: Inverts alpha. Call at least <code>updateAlpha()</code> before calling this. /// </summary> protected void SolveIncrements() { try { //use the GeneralMatrix package to invert alpha //one could also use //double[] da = DoubleMatrix.solve(alpha, beta); GeneralMatrix m = alpha.Inverse(); //set alpha with inverted matrix alpha.SetMatrix(0, alpha.RowDimension - 1, 0, alpha.ColumnDimension - 1, m); } catch (Exception e) { Trace.WriteLine(e.StackTrace); } for (int i = 0; i < alpha.RowDimension; i++) { da[i] = 0; for (int j = 0; j < alpha.ColumnDimension; j++) { da[i] += alpha.GetElement(i, j) * beta[j]; } } for (int i = 0; i < parameters.Length; i++) { //if (!Double.isNaN(da[i]) && !Double.isInfinite(da[i])) incrementedParameters[i] = parameters[i] + da[i]; } }
/// <summary> /// /// </summary> /// <param name="matrix"></param> /// <param name="criterionId"></param> public void AddCriterionRatedChoices(int criterionId, GeneralMatrix matrix) { if (criterionId > _nCriteria) { throw new ArgumentException("Passed criterion Id greater than numberof criteria"); } int col0 = criterionId * _mChoices; int colMax = col0 + _mChoices - 1; GeneralMatrix newMatrix = (GeneralMatrix)ExpandUtility(matrix).Clone(); _choiceMatrix.SetMatrix(0, _mChoices - 1, col0, colMax, newMatrix); }
/// <summary> /// /// </summary> private void CalculateChoices() { GeneralMatrix tempMatrix = null; int i, col0, colMax; PrioritiesSelector selector = new PrioritiesSelector(); for (i = 0; i < this._nCriteria; i++) { col0 = i * _mChoices; colMax = col0 + _mChoices - 1; tempMatrix = _choiceMatrix.GetMatrix(0, _mChoices - 1, col0, colMax); selector.ComputePriorities(tempMatrix); //first element of the matrix is consistency ratio //for the criteria _lambdas.SetElement(i + 1, 0, selector.ConsistencyRatio); _modelResult.SetMatrix(0, _mChoices - 1, i, i, selector.CalculatedMatrix); } }
public void Negative_BadSetMatrix1() { B.SetMatrix(ib, ie + B.RowDimension + 1, jb, je, M); }