public void MontarLinhaZ(FuncaoObjetiva fObjetiva) { double[] valorQuadro = new double[Cabecario.Length]; for (int i = 0; i < Cabecario.Length; i++) { for (int j = 0; j < fObjetiva.Letras.Length; j++) { if (fObjetiva.Letras[j].Equals(Cabecario[i])) { valorQuadro[i] = fObjetiva.Valores[j]; } } } this.LinhaZ = new KeyValuePair <string, double[]>("Z", valorQuadro); }
public Quadro(FuncaoObjetiva FObjetiva, List <Restricao> restricoes, int quantA, int quantF) { int tamanho = FObjetiva.Tamanho(); tamanho = tamanho + quantA + quantF + 1; if (quantA > 0) { duasFases = true; } else { duasFases = false; } string[] novoCabecario = new string[tamanho]; int a = 1; int f = 1; int j = 0; int jAux = FObjetiva.Letras.Length; for (int i = 0; i < tamanho; i++) { if (j < jAux) { novoCabecario[i] = FObjetiva.Letras[j]; j++; } else if (f <= quantF) { novoCabecario[i] = "f" + f; f++; } else if (a <= quantA) { novoCabecario[i] = "a" + a; a++; } else { novoCabecario[i] = "b"; } } this.Cabecario = novoCabecario; f = 1; Dictionary <string, double[]> novasLinhas = new Dictionary <string, double[]>(); for (int i = 0; i < restricoes.Count(); i++) { double[] valorQuadro = new double[Cabecario.Length]; restricoes[i].Valores.CopyTo(valorQuadro, 0); valorQuadro[restricoes[i].Valores.Length] = restricoes[i].Resultado; int auxiliares = quantA + quantF; for (int p = Cabecario.Length - auxiliares - 1; p < Cabecario.Length - 1; p++) { if (valorQuadro[p] == 1) { novasLinhas.Add(Cabecario[p], valorQuadro); } } f++; } Linhas = novasLinhas; MontarLinhaZ(FObjetiva); if (duasFases) { double[] linha = new double[Cabecario.Length]; int aux = 1; List <int> indexesArtificiais = new List <int>(); for (int i = 0; i < Cabecario.Length; i++) { foreach (KeyValuePair <string, double[]> entry in this.Linhas) { //^a\d* if (Regex.IsMatch(entry.Key, @"^a\d*")) { linha[i] = linha[i] + entry.Value[i]; } } linha[i] = linha[i] * -1; if (Cabecario[i].Equals("a" + aux)) { linha[i] = 0; aux++; } } this.LinhaZ2 = new KeyValuePair <string, double[]>("Z'", linha); } }