Beispiel #1
0
        public bool EjecutarBasicSimplex(string nombreHojaProblema)
        {
            bool             siCorrecto = false;
            ConectorDatosApp conector   = new ConectorDatosApp();
            SimplexTService  service    = new SimplexTService();
            KeyValuePair <string, double> variableMinima = new KeyValuePair <string, double>();
            KeyValuePair <string, double> pivote         = new KeyValuePair <string, double>();

            if (conector.ExtraerDatosSimplex(Path, nombreHojaProblema, out Tableau tabla))
            {
                service.PivotarTSimplex(ref tabla, out variableMinima, out pivote);
                service.ReducirColumnas(ref tabla, pivote, variableMinima.Key);

                while (!service.ComprobarSiFinalizaSimplex(tabla.FuncionObjetivo))
                {
                    service.PivotarTSimplex(ref tabla, out variableMinima, out pivote);
                    service.ReducirColumnas(ref tabla, pivote, variableMinima.Key);
                }

                Trace.TrazaTextoConFecha(Constantes.TextoSiSolucion);
                Trace.TrazaTexto(Constantes.TextoValor);
                Trace.TrazaEcuacionVectorialVertical(tabla.FuncionObjetivo);
            }

            return(siCorrecto);
        }
Beispiel #2
0
        public bool ExtraerDatosSimplex(string path, string NombreHoja, out Tableau tabla)
        {
            bool siCorrecto = false;

            tabla = null;
            List <string> cabeceraFila    = new List <string>();
            List <string> cabeceraColumna = new List <string>();

            if (!string.IsNullOrWhiteSpace(path) && !string.IsNullOrWhiteSpace(NombreHoja))
            {
                UsoExcel        helperExcel = new UsoExcel(path);
                SimplexTService stService   = new SimplexTService();

                if (helperExcel.SiProcesoCorrecto && helperExcel.ComprobarSiExisteHoja(NombreHoja, out int indiceHoja) &&
                    helperExcel.ObtenerDimensionesHoja(indiceHoja, out int countFila, out int countCol))
                {
                    string[,] datosH = helperExcel.ObtenerDatosHoja(NombreHoja);
                    List <Constraint>         restricciones       = ObtenerEcuaciones(datosH, countFila - 1, countCol - 1, out List <string> cabecera, out ObjectiveFunction funcionObjetivo);
                    List <StandardConstraint> restriccionesEstand = stService.EstandarizarRestricciones(restricciones).ToList();
                    restriccionesEstand = stService.EstandarizarVector(restriccionesEstand).ToList();
                    if (stService.EstandarizarFuncionObjetivo(restriccionesEstand, ref funcionObjetivo))
                    {
                        tabla = new Tableau(funcionObjetivo, restriccionesEstand); siCorrecto = true;
                    }
                }

                helperExcel.CerrarLibroExcel();
            }

            return(siCorrecto);
        }
Beispiel #3
0
        public void EstandarizarRestricciones()
        {
            SimplexTService stService = new SimplexTService();

            IEnumerable <StandardConstraint> result = stService.EstandarizarRestricciones(restricciones);

            result = stService.EstandarizarVector(result);

            if (stService.EstandarizarFuncionObjetivo(result, ref FO))
            {
                Tableau ts = new Tableau(FO, result);

                stService.PivotarTSimplex(ref ts, out KeyValuePair <string, double> variableMinima, out KeyValuePair <string, double> pivote);
                stService.ReducirColumnas(ref ts, pivote, variableMinima.Key);
            }
        }