示例#1
0
        protected override bool CheckCommodity()
        {
            linEquationContext.TCPELinProgMatrix = new LinEquationsMatrix();
            ILinEqsAlgorithmProvider linEqsAlgorithmProvider = configuration.Get <ILinEqsAlgorithmProvider>();

            LinEqsSetBuilder tcpeLinProgBuilder =
                linEqsAlgorithmProvider.GetLinEquationsSetBuilder(
                    meapContext,
                    tapeSegContext,
                    linEquationContext);

            tcpeLinProgBuilder.CreateTCPEPLinProgEqsSet();
            AddCommodityCheckEquation();

            SparseMatrix         A = linEquationContext.TCPELinProgMatrix.GetLinEqSetSparseMatrix();
            LinEqSetSolverSparse linEqSetSolver = new(A);

            return(linEqSetSolver.IfSolutionExists());
        }
        /// <summary>
        /// Just to compare linear equation set solvers
        /// </summary>
        protected override bool CheckCommodity()
        {
            linEquationContext.TCPELinProgMatrix = new LinEquationsMatrix();
            ILinEqsAlgorithmProvider linEqsAlgorithmProvider = configuration.Get <ILinEqsAlgorithmProvider>();

            LinEqsSetBuilder tcpeLinProgBuilder =
                linEqsAlgorithmProvider.GetLinEquationsSetBuilder(
                    meapContext,
                    tapeSegContext,
                    linEquationContext);

            tcpeLinProgBuilder.CreateTCPEPLinProgEqsSet();
            AddCommodityCheckEquation();

            String linEqSetQuery = linEquationContext.TCPELinProgMatrix.GetLinEqSetQuery();

            tapeSegContext.MathQueryString = linEqSetQuery + "LinearSolve[A,b]";

            MathKernelConnector mathKernelConnector = configuration.Get <MathKernelConnector>();
            String linEqSetOutput = mathKernelConnector.MathKernel.EvaluateToOutputForm(tapeSegContext.MathQueryString, 0);

            return(!linEqSetOutput.Contains(linEqSetStr));
        }