jmetal解决超多目标问题,并且利用igd值进行评价

本文介绍了IGD值作为超多目标优化算法评价指标的原理,并详细展示了如何在JMetal框架中部署NSGA-III和MOEA/D算法,包括配置帕累托平面、计算IGD值和设定参考点。通过代码示例,阐述了NSGA-III与MOEA/D在参考点设置上的差异。
摘要由CSDN通过智能技术生成

IGD值介绍:

反世代距离评价指标(Inverted Generational Distance, IGD) 是一个综合性能评价指标。它主要通过计算每个在真实 Pareto前沿面上的点(个体)到算法获取的个体集合之间的最小距离和,来评价算法的收敛性能和分布性能。值越小,算法的综合性能包括收敛性和分布性能越好。计算公式如下,
在这里插入图片描述
与之类似的,还有GD(世代距离),该指标表示求出已知的最优帕累托面和问题理想帕累托面之间的间隔距离,该距离表示偏离真正边界的程度,值越大,偏离真正最优边界越远,收敛性越差。

JMetal部署

NSGA-III部署

JMetal中提供了很多超多目标优化算法,这里我们采用了NSGA-III与MOEA/D分别进行介绍(两者的配置过程大致相同,但是也存在差别,比如说参考点的选择上)
代码如下:

public class testnsgaiii {
   

    public static void main(String[] args) throws FileNotFoundException {
   
        double[] igds=new double[10];
        Problem<DoubleSolution> problem;
        problem = new DTLZ7(30, 15);//配置DTLZ函数,前面是自变量数,后面是目标维度数。
        String referenceParetoFront = "";// 真实PF,用于计算指标值,只在计算需要理想帕累托面指标中需要使用。
        //System.out.println("15");
        referenceParetoFront = "jmetal-problem/src/test/resources/pareto_fronts/dtlz7_tf_15objs.pf";//从这里读取理想帕累托平面值
        String s = "NSGAiii" + problem.getName() + "-"+problem.getNumberOfObjectives();
        for (int i = 0; i < 10; i++) {
   
            Algorithm<List<DoubleSolution>> algorithm;
            CrossoverOperator<DoubleSolution> crossover;
            MutationOperator<DoubleSolution> mutation;
            SelectionOperator<List<DoubleSolution>, DoubleSolution> selection;
            // 定义优化问题
//            new InvertedGenerationalDistance<PointSolution>(normalizedReferenceFront).evaluate(normalizedPopulation) + "\n";
            // 种群规模
            int popSize = 136;
            // 配置SBX交叉算子
            double crossoverProbability = 0.9;
            double crossoverDistributionIndex = 20.0;
            crossover = new SBXCrossover(crossoverProbability, crossoverDistributionIndex);
            // 配置变异算子
            double mutationProbability = 1.0 / problem.getNumberOfVariables();
            double mutationDistributionIndex = 20.0;
            mutation = new PolynomialMutation(mutationProbability, mutationDistributionIndex);
            // 配置选择算子
            selection = new BinaryTournamentSelection<DoubleSolution>(
                    new RankingAndCrowdingDistanceComparator<DoubleSolution>());
            // 将组件注册到algorithm
            algorithm = new NSGAIIIBuilder<DoubleSolution>(problem)
                    .setPopulationSize(popSize)
                    .setMaxIterations(2000)
                    .setCrossoverOperator(crossover)
                    .setMutationOperator(mutation)
                    .setSelectionOperator(selection).build();

            // 用AlgorithmRunner运行算法

            AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor((Algorithm<?>) algorithm).execute();


            // 获取结果集

            List<DoubleSolution> population = algorithm.getResult();
            // 输出结果
            printFinalSolutionSet(population, s);
            double IGD = new InvertedGenerationalDistance<DoubleSolution>(referenceParetoFront).
  • 4
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
调度车间问题是经典的组合优化问题,可以使用JMetal框架求解。下是使用JMetal求解调度车间问题的示例代码: ```java import org.uma.jmetal.algorithm.singleobjective.geneticalgorithm.GeneticAlgorithm; import org.uma.jmetal.algorithm.singleobjective.geneticalgorithm.SteadyStateGeneticAlgorithm; import org.uma.jmetal.operator.CrossoverOperator; import org.uma.jmetal.operator.MutationOperator; import org.uma.jmetal.operator.impl.crossover.PMXCrossover; import org.uma.jmetal.operator.impl.mutation.SwapMutation; import org.uma.jmetal.problem.Problem; import org.uma.jmetal.problem.singleobjective.SchedulingProblem; import org.uma.jmetal.solution.PermutationSolution; import org.uma.jmetal.util.AlgorithmRunner; import org.uma.jmetal.util.JMetalException; import org.uma.jmetal.util.evaluator.impl.SequentialSolutionListEvaluator; import org.uma.jmetal.util.factory.AlgorithmFactory; import org.uma.jmetal.util.factory.CrossoverOperatorFactory; import org.uma.jmetal.util.factory.MutationOperatorFactory; import org.uma.jmetal.util.factory.ProblemFactory; import java.util.List; public class SchedulingProblemExample { public static void main(String[] args) throws JMetalException { Problem<PermutationSolution<Integer>> problem; GeneticAlgorithm<PermutationSolution<Integer>> algorithm; CrossoverOperator<PermutationSolution<Integer>> crossover; MutationOperator<PermutationSolution<Integer>> mutation; problem = ProblemFactory.createProblem("SchedulingProblem"); crossover = CrossoverOperatorFactory .<PermutationSolution<Integer>>getOperator("PMXCrossover"); mutation = MutationOperatorFactory.<PermutationSolution<Integer>>getOperator("SwapMutation"); algorithm = new SteadyStateGeneticAlgorithm<>(problem, 100, 20, crossover, mutation, new SequentialSolutionListEvaluator<>()); AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm) .execute(); List<PermutationSolution<Integer>> population = algorithm.getResult(); long computingTime = algorithmRunner.getComputingTime(); System.out.println("Total execution time: " + computingTime + "ms"); PermutationSolution<Integer> solution = population.get(0); int[] schedule = ((SchedulingProblem) problem).getSchedule(solution); System.out.println("Optimal Schedule: "); for (int i = 0; i < schedule.length; i++) { System.out.println("Job " + i + " starts at " + schedule[i]); } } } ``` 在这个示例代码中,我们使用JMetal的`ProblemFactory`创建一个调度车间问题,然后使用`CrossoverOperatorFactory`和`MutationOperatorFactory`创建交叉和变异算子。我们使用`SteadyStateGeneticAlgorithm`作为优化算法,并使用`SequentialSolutionListEvaluator`对种群进行评估。 最后,我们使用`AlgorithmRunner`执行算法,并输出最优解对应的调度方案。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值