jMetal / jMetalPy

A framework for single/multi-objective optimization with metaheuristics
https://jmetal.github.io/jMetalPy/index.html
MIT License
497 stars 150 forks source link

Is it possible to use moead with 3 objectives in version 1.6.0? #167

Closed MassimoValle closed 5 months ago

MassimoValle commented 5 months ago

This is my implementation of MOEAD that I wrote following the documentation:

algorithm = MOEAD(
                problem=problem,
                population_size=100,
                crossover=DifferentialEvolutionCrossover(CR=1.0, F=0.5, K=0.5),
                mutation=PolynomialMutation(probability=1.0 / problem.number_of_variables(), distribution_index=20),
                aggregative_function=Tschebycheff(dimension=problem.number_of_objectives()),
                neighbor_size=12,
                neighbourhood_selection_probability=0.7,
                max_number_of_replaced_solutions=2,
                weight_files_path='resources/MOEAD_weights',
                termination_criterion=StoppingByEvaluations(max_evaluations=10000)
            )

When I try to run MOEAD using a 3-objective problem I get the following error:

FileNotFoundError: Failed to initialize weights: resources/MOEAD_weights/W3D_100.dat not found

But, looking in the library installed on my computer via pip, there is no 'resources' folder.

Is there a solution for this problem? Thank you in advance for your responses

ajnebro commented 5 months ago

Hi. You can find the resources folder in the project repository (https://github.com/jMetal/jMetalPy).

Regards,

Antonio

MassimoValle commented 5 months ago

Hi. You can find the resources folder in the project repository (https://github.com/jMetal/jMetalPy).

Regards,

Antonio

Hi, thank you for your answer. Where should I put the resources folder? Because I tried putting it in the root of the jmetalpy library at the same level as the algorithm, core, lab and so on folders but it doesn't work. I also tried putting it one level above (so in the python3.11 site-packages folder) but it is not found there either when running MOEAD

ajnebro commented 5 months ago

Hi. You can find the resources folder in the project repository (https://github.com/jMetal/jMetalPy).

Regards,

Antonio

ajnebro commented 5 months ago

How are you running the algorithm?. The point is to set the working directory to the root of the jMetalPy project.

In my case, I use PyCharm as IDE and I have modified the run configuration to set it:

imagen
MassimoValle commented 5 months ago

I followed your advice and was able to solve the problem. I mistakenly thought i should put the resources folder inside the library folder but instead i should put it in the root of my project. Thank you very much for your help :D

Just one more question. I saw that there are various files in the resources folder but there is no one related to a weight of 24. Do you know how I can calculate it? I saw that in the class neighborhood.py inside the utils folder of jmetalpy there is this note:

"""Precomputed weights from

        * Zhang, Multiobjective Optimization Problems With Complicated Pareto Sets, MOEA/D and NSGA-II

        Downloaded from.

        * http://dces.essex.ac.uk/staff/qzhang/MOEAcompetition/CEC09final/code/ZhangMOEADcode/moead030510.rar
        """

The problem is that the link doesn't work and I was hoping there would be a reference on how to calculate the weights

ajnebro commented 5 months ago

MOEA/D relies heavily on weight vectors to produce high quality diversity fronts. These vectors depends of the number of objectives and the population size. Just compare the results of optimizing the DTLZ1 problem with a population of 91 and a population of 100. One method to produce such weight vectors is the Das Dennis algorithm (https://github.com/jMetal/DasDennis).

You can take a look to the resources folder of the jMetal project (https://github.com/jMetal/jMetal/tree/main/resources/weightVectorFiles/moead) to find files containing weight vectors.