Exemplo n.º 1
0
        public int Solve_Optimized(out bool complete)
        {
            Vector negativeKnown = new Vector(knownForce);

            negativeKnown.Scale(-1);
            Matrix matrix = new Matrix(unknowns.Select(edgeTuple => edgeTuple.Item2).ToList(), negativeKnown);
            int    rank   = matrix.ReduceToRREF();

            complete = true;
            int numSolved = 0;

            for (int i = 0; i < rank; ++i)
            {
                int pos = FetchSolvedPosition(matrix, i);
                if (pos > -1)
                {
                    var solvedInternalForce = matrix[i, matrix.N - 1];

                    if (!OTruss.ForceIsValid(solvedInternalForce))
                    {
                        return(-1);
                    }

                    internalForces[unknowns[pos].Item1] = solvedInternalForce;
                    ++numSolved;
                }
            }

            complete = numSolved == unknowns.Count;
            return(numSolved);
        }
 public OCommandProcessor()
 {
     truss = new OTruss();
 }