Example #1
0
        private KeyValuePair <string, double> GetRefRow(KeyValuePair <string, double> refCol, ref SimplexTable tabla)
        {
            double valorCompareIteracion = new double();
            string restriccionS          = string.Empty;
            double pivoteValor           = double.NaN;

            valorCompareIteracion = double.MaxValue;

            foreach (VectorEquation eq in tabla.StandardConstraint)
            {
                double iteracionN = eq.VectorBody.Where(v => v.Key == refCol.Key).FirstOrDefault().Value;
                string iteracionS = !string.IsNullOrEmpty(eq.Name) ? eq.Name : string.Empty;
                if (iteracionN > 0 && (tabla.GetConstants().Where(v => v.Key == eq.Name).FirstOrDefault().Value / iteracionN) < valorCompareIteracion)
                {
                    pivoteValor           = iteracionN;
                    restriccionS          = iteracionS;
                    valorCompareIteracion = (tabla.GetConstants().Where(v => v.Key == eq.Name).FirstOrDefault().Value / iteracionN);
                }

                if (tabla.IsSolution)
                {
                    tabla.IsSolution = (iteracionN > 0);
                }
            }

            return(new KeyValuePair <string, double>(restriccionS, pivoteValor));
        }