esa / esa/pygmo2

Changing population when using decorator meta-problem

Open
#144 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
536
Forks
74
PR merge metrics
No merged PRs in 30d

Description

(This should be under the feature-request/help labels, I'm just not sure how to add them)

I have written code that changes a problem using a decorator, but I'd also like to change the problem in an instantiated population. Is there currently a way to do this? For example, given some population with an associated problem at initialisation, is there a way to update the problem to the new decorated one without creating a new population? I know this is potentially very un-pygmonic (against the way PyGMO is designed), but I think it could be useful for some upcoming projects.

E.g.
```
import pygmo as pg

# Define a dummy decorated problem
def f_decor(orig_fitness_function):
def new_fitness_function(self, dv):
import time
start = time.monotonic()
fitness = orig_fitness_function(self, dv)
print("Elapsed time: {} seconds".format(time.monotonic() - start))
return fitness
return new_fitness_function

# The original problem
prob = pg.problem(pg.rosenbrock(dim = 10))

# The initial population
pop = pg.population(prob, size = 20)

# The algorithm
algo = pg.algorithm(pg.sade(gen = 1000))

# Evolve the population
pop = algo.evolve(pop)

new_prob = pg.problem(pg.decorator_problem(rb, fitness_decorator=f_decor))

#
pop = pop.change_problem(new_prob)
```

Any help is much appreciated!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the pg.population and pg.problem entry points shown in the example, and trace how a population retains its associated problem through algo.evolve(). Check the existing public API for any supported problem-replacement operation. Done would require a clear decision and documented behavior for changing the problem without recreating the population.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.