示例#1
0
        public static SimplexResult Maximize(
            Matrix <double> conditions,
            Vector <double> objectiveFunctionComponents,
            Vector <double> initialSolution,
            SortedSet <int> basisIndices)
        {
            var phase = new MutableSimplexMainPhase(conditions, objectiveFunctionComponents, initialSolution, basisIndices);

            phase.Maximize();

            return(ToResult(phase));
        }
示例#2
0
        private static SimplexResult ToResult(MutableSimplexMainPhase phase)
        {
            var x       = phase.Solution.ToImmutableArray();
            var indices = phase.B.ToImmutableSortedSet();

            var result = 0.0;

            foreach (var(a, b) in x.Zip(phase.ObjectiveFunctionComponents))
            {
                result += a * b;
            }

            return(new SimplexResult(indices, x, result));
        }