BioSystemsUM / MEWpy

Metabolic Engineering Workbench
https://mewpy.readthedocs.io
GNU General Public License v3.0
37 stars 12 forks source link

problem in optimization #40

Closed Laminsecin closed 7 months ago

Laminsecin commented 1 year ago

Hi, I encountered this error while trying to define a new reaction over/under expression problem instance.

TypeError Traceback (most recent call last)

Cell In [162], line 2 1 # run the optimization ----> 2 ea = EA(problem, max_generations= 100, visualizer=True) 3 final_pop = ea.run()

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\mewpy\optimization__init__.py:154, in EA(problem, initial_population, max_generations, mp, visualizer, algorithm, kwargs) 151 else: 152 engine = engines[engs[0]] --> 154 return engine(problem, initial_population=initial_population, max_generations=max_generations, mp=mp, 155 visualizer=visualizer, algorithm=algorithm, kwargs)

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\mewpy\optimization\jmetal\ea.py:71, in EA.init(self, problem, initial_population, max_generations, mp, visualizer, algorithm, **kwargs) 69 self.ea_problem = JMetalKOProblem(self.problem, self.initial_population) 70 else: ---> 71 self.ea_problem = JMetalOUProblem(self.problem, self.initial_population) 72 self.crossover, self.mutation = self.ea_problem.build_operators() 73 self.population_size = kwargs.get('population_size', get_population_size())

TypeError: Can't instantiate abstract class JMetalOUProblem with abstract methods name, number_of_constraints, number_of_objectives, number_of_variables

vmspereira commented 1 year ago

Hi @Laminsecin ,

Thank you for pointing out this issue.

To address it, you may downgrade jmetalpy to its previous version:

pip install jmetalpy==1.5.5

or use the Inpyred optimization engine by adding the two lines below:

from mewpy.optimization import set_default_engine
set_default_engine('inspyred')

ea = EA(problem, max_generations= 100, visualizer=True)

Thank you.

Laminsecin commented 1 year ago

@vmspereira Thank you so much for your help. I did what you said, but unfortunately I get the following error: module 'collections' has no attribute 'Sequence' I was able to solve this error by changing a line in ec.py file import collections.abc as collections. but know the program does not give me any solutions? where is the problem? image

vmspereira commented 1 year ago

Hi @Laminsecin. It is difficult to provide suggestions without knowing what the problem you are trying to solve is. There are distinct reasons why you might not have solutions. Supposing that you are trying to find solutions for metabolite production, did you run an FVA to verify the feasibility of it? The problem may be difficult or impossible. Some things you might try are: 1) increase the number of allowed modifications, 2) seed the EA with solutions from the literature for related metabolites/organisms, 3) start by improving the production of a precursor... But again, it greatly depends on what you are trying to achieve.