0

I am a Python beginner. Trying to follow a getting started tutorial of a multi-objective optimization algoritm https://pymoo.org/getting_started/part_2.html

I have installed pymoo according to the installation instructions:

pip install -U pymoo

Everything works fine up to the paragraph Define a Termination Criterion

I imput the code:

from pymoo import get_termination

ERROR

ImportError                               Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_10384/2370239780.py in <module>
      1 #Define a Termination Criterion
      2 
----> 3 from pymoo import get_termination
      4 

ImportError: cannot import name 'get_termination' from 'pymoo' (C:\Users\musae\anaconda3\lib\site-packages\pymoo\__init__.py)

The same things happens when I imput

from pymoo.problems import get_problem

from that example of NSGA2 algorithm https://pymoo.org/algorithms/moo/nsga2.html#nb-nsga2

ERROR

ImportError                               Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_24508/113033208.py in <module>
      1 from pymoo.algorithms.moo.nsga2 import NSGA2
----> 2 from pymoo.problems import get_problem
      3 from pymoo.optimize import minimize
      4 from pymoo.visualization.scatter import Scatter
      5 

ImportError: cannot import name 'get_problem' from 'pymoo.problems' (C:\Users\musae\anaconda3\lib\site-packages\pymoo\problems\__init__.py)

Have I installed it wrong? Why do I get those errors?

Thank you!

Alex
  • 1

2 Answers2

0

Instead of from pymoo.problems import get_problem use from pymoo.problems.multi import * .

And for get_problem use problem instead. As an example:

get_problem("zdt1").pareto_front()

Should be converted to:

ZDT1().pareto_front()

Reza Akraminejad
  • 1,412
  • 3
  • 24
  • 38
0

I also came across the first error of unable to inport get_termination, using from pymoo.factory import get_termination works for me.

ALEE
  • 1
  • 3