예제 #1
0
  private void CalcularActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_CalcularActionPerformed

    String datosResultado[] = null;
    String resultadoModelo[] = null;
    Modelo modelo = new Modelo(numeroCajas, volumenesCajas, pesosCajas, volumenMorral, pesoMorral);
    double valorFO = 0;
    int tamanoArregloResultado = 0;

    double inicioTiempo = System.currentTimeMillis();
    try {
      resultadoModelo = modelo.modelar();

    } catch (LpSolveException ex) {
      Logger.getLogger(Morral.class.getName()).log(Level.SEVERE, null, ex);
    }
    double tiempoTotal = System.currentTimeMillis() - inicioTiempo;
    resultiempoejecucion.setText(Double.toString(tiempoTotal / 1000));

    if (resultadoModelo != null) {
      // Agregar a tabla resultados los morrales con sus cajas
      tamanoArregloResultado = Integer.parseInt(resultadoModelo[0]);
      valorFO = Double.parseDouble(resultadoModelo[1]);
      this.morrales = new int[tamanoArregloResultado];
      this.cajasEnMorrales = new String[tamanoArregloResultado];
      datosResultado = new String[2];

      int nummorral = 0;
      for (int j = 2; j < tamanoArregloResultado; j++) {
        this.morrales[nummorral] = nummorral + 1;
        datosResultado[0] = Integer.toString(this.morrales[nummorral]);
        this.cajasEnMorrales[j] = resultadoModelo[j];
        if (!"".equals(cajasEnMorrales[j])) {
          datosResultado[1] = this.cajasEnMorrales[j];
          modelResultado.addRow(datosResultado);
        }

        nummorral++;
      }

      // Mostrar resultado de f.o
      resultado.setText(resultadoModelo[1]);
    }
  } // GEN-LAST:event_CalcularActionPerformed
  public void run(String[] param) {

    formulario.clear();

    SelecionarPalavras run = new SelecionarPalavras();
    int t = param.length;
    String[] listaPalavras = param;

    String[] novaListaPalavras = new String[t];
    ArrayList<String> newArray = new ArrayList();
    ArrayList<Integer> newArrayId = new ArrayList();

    Integer[] quantidadeItemPalvra = new Integer[t];

    newArray = run.runN(param);
    Collections.sort(newArray);
    int size = newArray.size();

    for (int j = 0; j < size; j++) {

      int cont = 0;

      for (int x = 0; x < param.length; x++) {

        if (newArray.get(j).equals(param[x])) {
          cont++;
          newArrayId.add(j, cont);
        }
      }
    }

    for (int i = 0; i < newArray.size(); i++) {
      formulario.setPalavra(newArray.get(i));
      formulario.setQuantidade(newArrayId.get(i));
    }
  }