예제 #1
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);
        }
예제 #2
0
        public bool GetFuzzyDataSimplex(string path, string NombreHoja, out FuzzyTableau tableau)
        {
            bool isCorrect = false;

            tableau = 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);
                FuzzyPrimalSimplexService fpsService = new FuzzyPrimalSimplexService();

                if (helperExcel.SiProcesoCorrecto && helperExcel.ComprobarSiExisteHoja(NombreHoja, out int indiceHoja) &&
                    helperExcel.ObtenerDimensionesHoja(indiceHoja, out int countFila, out int countCol))
                {
                    string[,] data = helperExcel.ObtenerDatosHoja(NombreHoja);
                    if (GetEquations(path, data, countFila - 1, countCol - 1, out List <string> header, out List <FuzzyConstraint> fuzzyEquations, out FuzzyObjectiveFunction fuzzyObjectiveFunction, out List <Constraint> equations, out ObjectiveFunction objectiveFunction) && fuzzyEquations.Count > 0)
                    {
                        List <FuzzyVectorEquation> constraints = fpsService.StandardizeConstraints(fuzzyEquations).ToList();
                        if (fpsService.StandardizeObjectiveFunction(fuzzyEquations, ref fuzzyObjectiveFunction))
                        {
                            tableau = new FuzzyTableau(constraints, fuzzyObjectiveFunction); isCorrect = true;
                        }
                    }
                }

                helperExcel.CerrarLibroExcel();
            }

            return(isCorrect);
        }
예제 #3
0
        public bool GetFuzzyParameter(string path, string sheetName, out List <FuzzyParameter> fuzzyParameters)
        {
            bool isCorrect = false;

            fuzzyParameters = new List <FuzzyParameter>();

            if (!string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(sheetName))
            {
                UsoExcel helperExcel = new UsoExcel(path);

                if (helperExcel.SiProcesoCorrecto && helperExcel.ComprobarSiExisteHoja(sheetName, out int index) &&
                    helperExcel.ObtenerDimensionesHoja(index, out int countRow, out int countCol))
                {
                    string[,] data = helperExcel.ObtenerDatosHoja(sheetName);

                    for (int i = 0; i < countRow - 1; i++)
                    {
                        TRFN   numT       = null;
                        string parName    = string.Empty;
                        bool   isNamePass = false;
                        for (int j = 0; j < countCol - 1; j++)
                        {
                            if (!GetFuzzyNumber(data[i, j], out numT) && !isNamePass)
                            {
                                parName    = data[i, j];
                                isNamePass = true;
                            }
                        }

                        if (!string.IsNullOrEmpty(parName) && numT != null)
                        {
                            fuzzyParameters.Add(new FuzzyParameter(parName, numT));
                        }
                    }
                }

                helperExcel.CerrarLibroExcel();
            }

            return(isCorrect);
        }