⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myclientfeedback.java

📁 一个开源的用java开发的遗传算法的封装好的工程
💻 JAVA
字号:
/*
 * This file is part of JGAP.
 *
 * JGAP offers a dual license model containing the LGPL as well as the MPL.
 *
 * For licencing information please see the file license.txt included with JGAP
 * or have a look at the top of class org.jgap.Chromosome which representatively
 * includes the JGAP license policy applicable for any file delivered with JGAP.
 */
package examples.grid.mathProblemDistributed;

import org.jgap.*;
import org.jgap.gp.*;
import org.jgap.gp.impl.*;
import org.jgap.distr.grid.gp.*;
import org.jgap.distr.grid.*;
import org.apache.log4j.*;

/**
 * Listener for feedback sent to the GP client. This is a simple sample
 * implementation.
 *
 * @author Klaus Meffert
 * @since 3.2
 */
public class MyClientFeedback
    implements IClientFeedbackGP {
  /** String containing the CVS revision. Read out via reflection!*/
  private final static String CVS_REVISION = "$Revision: 1.5 $";

  private static Logger log = Logger.getLogger(MyClientFeedback.class);

  public MyClientFeedback() {
  }

  public void error(String msg, Exception ex) {
    log.error("Error catched on client side: " + msg, ex);
  }

  public void sendingFragmentRequest(JGAPRequestGP req) {
    log.info("Sending work request " + req.getRID());
  }

  public void receivedFragmentResult(JGAPRequestGP req, JGAPResultGP res,
                                     int idx) {
    // This is just a quick and dirty solution.
    // Can you do it better?
    // ----------------------------------------
    GPPopulation pop = res.getPopulation();
    if (pop == null || pop.isFirstEmpty()) {
      IGPProgram best = res.getFittest();
      log.warn("Receiving work (index " + idx + "). Best solution: " +
               best.getFitnessValue());
      return;
    }
    if (pop == null) {
      log.error("Received empty result/population!");
    }
    else {
      log.warn("Receiving work (index " + idx + "). First solution: " +
               pop.getGPProgram(0));
    }
  }

  public void beginWork() {
    log.warn("Client starts sending work requests");
  }

  public void endWork() {
    log.warn("Your request was processed completely");
  }

  public void info(String a_msg) {
    log.warn(a_msg);
  }

  public void setProgressMaximum(int max) {
  }

  public void setProgressMinimum(int min) {
  }

  public void setProgressValue(int val) {
  }

  public void setRenderingTime(JGAPRequest req, long dt) {
  }

  public void completeFrame(int idx) {
    log.warn("Client notified that unit " + idx + " is finished.");
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -