Giter VIP home page Giter VIP logo

Comments (7)

PaulJonasJost avatar PaulJonasJost commented on July 27, 2024 1

So if you have defined x_guessesin the problem, use pypesto.optimize.ScipyDifferentialEvolutionOptimizer and call pypesto.optimize.minimze, the following will happen:

I think that is the argument line here. I hope this helps in clarifying it :)

from pypesto.

PaulJonasJost avatar PaulJonasJost commented on July 27, 2024 1

So if you have defined x_guessesin the problem, use pypesto.optimize.ScipyDifferentialEvolutionOptimizer and call pypesto.optimize.minimze, the following will happen:

I think that is the argument line here. I hope this helps in clarifying it :)

Though I might have to correct myself, I think it is not passed on, as it is lost in the minimise function. Thanks a lot for the question, will fix that and also clarify in the documentation.

from pypesto.

PaulJonasJost avatar PaulJonasJost commented on July 27, 2024 1

will also have a look at the PySwarms optimizer 👍🏼

from pypesto.

PaulJonasJost avatar PaulJonasJost commented on July 27, 2024 1

Many thanks 🙏🏼 A fix for the ScipyDifferentialEvolutionOptimizer as well as at least a warning for the pyswarms optimizer will be released within this week :)

from pypesto.

PaulJonasJost avatar PaulJonasJost commented on July 27, 2024 1

merged at least warning for optimizers in #1027.

from pypesto.

Mjvolk3 avatar Mjvolk3 commented on July 27, 2024

This does help, but I have been doing the same thing, walking through code to figure out how potentially conflicting options are handled. For instance, I thought that it would send the x_guesses in the PyswarmsOptimizer to act as init_pos for the particles in the swarm. But instead first x0 is set by startpoint.

for startpoint, id in zip(startpoints, ids):
task = OptimizerTask(
optimizer=optimizer,
problem=problem,
x0=startpoint,
id=id,
history_options=history_options,
optimize_options=options,
)

Then x0 is used only to define dimension, not init_pos.

optimizer = pyswarms.single.global_best.GlobalBestPSO(
n_particles=self.par_popsize,
dimensions=len(x0),
options=self.options,
bounds=(lb, ub),
)

I think some documentation describing options could be useful, but if it's too much work we can always figure things out by looking at src.

from pypesto.

Mjvolk3 avatar Mjvolk3 commented on July 27, 2024

@PaulJonasJost I've taken some notes on my exploration. They might be useful to you. Excuse them for their brevity. I think the last example showing generate_swarm will be informative.

  • Say we set pypesto.problem.x_guesses ($n \times d$ array). Then the following loop will occur $n$ times, with random starts when using the PySwarms optimizer. This works well as we will have particles starting in new locations.
for startpoint, id in zip(startpoints, ids):
        task = OptimizerTask(
            optimizer=optimizer,
            problem=problem,
            x0=startpoint,
            id=id,
            history_options=history_options,
            optimize_options=options,
        )
        tasks.append(task)
  • If the PySwarms option init_pos=x_guesses then there will still be $n$ loops but then the number of particles par_popsize will be ignored, and be len(x_guesses), and the initialization will be the same for each new set of particles. This would not be desireable for properly running the optimizer. Because of this is probably best to advise against using init_pos.

  • side note: x0 is evaluated for both init_pos=x_guesses and the default init_pos=None.

  • I've tested how particles are generated to show this. If we specify the init_pos, n_particles is overwritten and we only get an initialization of the size of init_pos.

>>> from pyswarms.backend.generators import generate_swarm
>>> init_pos = np.ones((2,3))
>>> generate_swarm(n_particles=4, dimensions=init_pos.shape[1],init_pos=init_pos)
array([[1., 1., 1.],
       [1., 1., 1.]])

The dimension arg needs to be specified, but is overwritten by kwarg init_pos.

>>> generate_swarm(n_particles=4, dimensions=5,init_pos=init_pos)
array([[1., 1., 1.],
       [1., 1., 1.]])

init_pos=None is normal default behavior, with random initialization of particles. Doing this we actually get 4 particles.

>>> generate_swarm(n_particles=4, dimensions=init_pos.shape[1],init_pos=None)
array([[0.17696656, 0.03424968, 0.55395097],
       [0.85859682, 0.5250245 , 0.41581642],
       [0.64526319, 0.04922589, 0.31136249],
       [0.53644966, 0.48004648, 0.32024561]])

from pypesto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.