Asynchronous 如何在MOEA框架中获得实时统计数据?
我知道有Asynchronous 如何在MOEA框架中获得实时统计数据?,asynchronous,real-time,evolutionary-algorithm,moea-framework,Asynchronous,Real Time,Evolutionary Algorithm,Moea Framework,我知道有Instrumenter类,但是该方法在运行结束后输出数据。我希望获得(接近)实时数据,就像演示中的符号回归一样。 看看它的代码,似乎我需要使用step方法,并尝试模仿Executor中的runSingleSeed。有更好的办法吗?其他一些类,如Instrumenter,但异步。我在网上找不到类似的东西 只需围绕循环构建一个包装器(与下一个类似),并使其成为观察者模式中的主题 import java.util.Properties; 导入java.util.array; 导入java.
Instrumenter
类,但是该方法在运行结束后输出数据。我希望获得(接近)实时数据,就像演示中的符号回归一样。
看看它的代码,似乎我需要使用
step
方法,并尝试模仿Executor
中的runSingleSeed
。有更好的办法吗?其他一些类,如Instrumenter
,但异步。我在网上找不到类似的东西 只需围绕循环构建一个包装器(与下一个类似),并使其成为观察者模式中的主题
import java.util.Properties;
导入java.util.array;
导入java.text.DecimalFormat;
导入org.moeaframework.core.Algorithm;
导入org.moeaframework.core.Solution;
导入org.moeaframework.core.Problem;
导入org.moeaframework.core.Population;
导入org.moeaframework.core.NondominatedPopulation;
导入org.moeaframework.core.variable.EncodingUtils;
导入org.moeaframework.core.spi.AlgorithmFactory;
导入org.moeaframework.problem.misc.Kursawe;
公共班机{
公共静态void main(字符串[]args){
字符串算法名称=“NSGAII”;
属性=新属性();
properties.setProperty(“populationSize”,“100”);//更改属性
问题=新的Kursawe();
algorithmalgorithmfactory.getInstance()
.getAlgorithm(算法名称、属性、问题);
int=100;
整数代=0;
while(世代
只需围绕循环构建一个包装器(与下一个类似),并使其成为观察者模式中的主题
import java.util.Properties;
导入java.util.array;
导入java.text.DecimalFormat;
导入org.moeaframework.core.Algorithm;
导入org.moeaframework.core.Solution;
导入org.moeaframework.core.Problem;
导入org.moeaframework.core.Population;
导入org.moeaframework.core.NondominatedPopulation;
导入org.moeaframework.core.variable.EncodingUtils;
导入org.moeaframework.core.spi.AlgorithmFactory;
导入org.moeaframework.problem.misc.Kursawe;
公共班机{
公共静态void main(字符串[]args){
字符串算法名称=“NSGAII”;
属性=新属性();
properties.setProperty(“populationSize”,“100”);//更改属性
问题=新的Kursawe();
algorithmalgorithmfactory.getInstance()
.getAlgorithm(算法名称、属性、问题);
int=100;
整数代=0;
while(世代public class MyAlgorithmFactory extends AlgorithmFactory {
private static Algorithm algorithm;
public Algorithm getGeneratedAlgorithm() {
return this.algorithm;
}
@Override
public Algorithm getAlgorithm(String name, Properties properties, Problem problem){
this.algorithm = super.getAlgorithm(name, properties, problem);
return algorithm;
}
}
MyAlgorithmFactory af = new MyAlgorithmFactory();
Executor executor = new Executor()
.usingAlgorithmFactory(af)
.withAlgorithm("NSGAII") //
.withProblem(yourProblemHere) //
.withMaxEvaluations(10000);