Exemplo n.º 1
0
        @Override
        public void actionPerformed(ActionEvent event) {
          // todo something need to be done here...
          worker =
              new eva2.gui.SwingWorker() {
                @Override
                public Object construct() {
                  return doWork();
                }

                @Override
                public void finished() {
                  runButton.setEnabled(true);
                  continueButton.setEnabled(true);
                  stopButton.setEnabled(false);
                  backupPopulation =
                      (Population) optimizationParameters.getOptimizer().getPopulation().clone();
                  continueFlag = false;
                }
              };
          // also mal ganz anders ich gehe davon aus, dass der Benutzer das Ding parametrisiert hat
          // setze einfach die Backup population ein...
          continueFlag = true;
          multiRuns = 1; // multiruns machen bei continue einfach keinen Sinn...
          worker.start();
          runButton.setEnabled(false);
          continueButton.setEnabled(false);
          stopButton.setEnabled(true);
        }
Exemplo n.º 2
0
  /** This method starts the actual optimization procedure */
  @Override
  public void startExperiment() {
    if (this.mainFrame != null) {}
    this.stillWorking = true;
    this.state.optimizer.setProblem(this.state.currentProblem);
    if (this.debug) {
      System.out.println("" + this.state.optimizer.getStringRepresentation());
    }
    this.state.currentProblem.evaluate(this.state.optimizer.getPopulation());
    this.state.optimizer.getPopulation().setFunctionCalls(0);
    if (this.state.optimizer.getPopulation().size() == 0) {
      this.state.optimizer.initialize();
    }
    this.state.optimizer.addPopulationChangedEventListener(this);
    worker =
        new eva2.gui.SwingWorker() {
          @Override
          public Object construct() {
            return doWork();
          }

          @Override
          public void finished() {
            Population[] pop = null;
            if (state.optimizer instanceof IslandModelEA) {
              InterfaceOptimizer[] opt = ((IslandModelEA) state.optimizer).getOptimizers();
              pop = new Population[opt.length];
              for (int i = 0; i < opt.length; i++) {
                pop[i] = opt[i].getPopulation();
              }
            }
            state.restore();
            if (pop == null) {
              state.addPopulation2History(state.optimizer.getPopulation());
            } else {
              for (int i = 0; i < pop.length; i++) {
                state.currentProblem.evaluate(pop[i]);
                state.addPopulation2History(pop[i]);
              }
            }
            if (view != null) {
              view.problemChanged(true);
            }
            stillWorking = false;
          }
        };
    worker.start();
  }
Exemplo n.º 3
0
        @Override
        public void actionPerformed(ActionEvent event) {
          worker =
              new eva2.gui.SwingWorker() {
                @Override
                public Object construct() {
                  return doWork();
                }

                @Override
                public void finished() {
                  runButton.setEnabled(true);
                  continueButton.setEnabled(true);
                  stopButton.setEnabled(false);
                  backupPopulation =
                      (Population) optimizationParameters.getOptimizer().getPopulation().clone();
                }
              };
          worker.start();
          runButton.setEnabled(false);
          continueButton.setEnabled(false);
          stopButton.setEnabled(true);
        }