[SciPy-Dev] Proposal - optimize callback given a state keyword

Jaime Fernández del Río jaime.frio at gmail.com
Fri Feb 9 03:56:27 EST 2018


Thanks, will certainly take a look!


On Fri, Feb 9, 2018 at 9:53 AM Andrew Nelson <andyfaff at gmail.com> wrote:

> Jaime,
> I'm just messing around at the moment,
> https://github.com/andyfaff/scipy/tree/OPTIMIZE. It won't work, but
> you'll get another outline idea of what I'm thinking about.
>
> On 9 February 2018 at 19:48, Jaime Fernández del Río <jaime.frio at gmail.com
> > wrote:
>
>> On Fri, Feb 9, 2018 at 2:35 AM Andrew Nelson <andyfaff at gmail.com> wrote:
>>
>>> The `differential_evolution` function is backed by the (as yet) **non
>>> public** DifferentialEvolution solver object.
>>>
>>> This has different modes of operation (by virtue of implementing
>>> __next__ and __iter__):
>>>
>>> ```
>>> def ackley(x):
>>>     arg1 = -0.2 * np.sqrt(0.5 * (x[0] ** 2 + x[1] ** 2))
>>>     arg2 = 0.5 * (np.cos(2. * np.pi * x[0]) + np.cos(2. * np.pi * x[1]))
>>>     return -20. * np.exp(arg1) - np.exp(arg2) + 20. + np.e
>>>
>>> bounds = [(-5, 5), (-5, 5)]
>>>
>>> solver = DifferentialEvolutionSolver(ackley, bounds)
>>>
>>> # run's through to completion
>>> res = solver.solve()
>>>
>>> # control how many iterations you want
>>> for idx in range(10):
>>>     x, fun = next(solver)
>>>     # amend internal state of solver if you know what you're doing
>>>
>>> # keep on going until you decide to stop
>>> for x, fun in solver:
>>>     print(x, fun)
>>>     intol = (np.std(solver.population_energies) <=
>>>              solver.atol +
>>>              solver.tol * np.abs(np.mean(solver.population_energies)))
>>>     if intol:
>>>         break
>>> ```
>>>
>>> It seems like this could be a useful design pattern going forwards, as I
>>> think it meets Jaime's points. However, this is obviously a large package
>>> of work.
>>>
>>
>> It looks very nice indeed. I will try to find some time to look into the
>> approach in differential evolution and see if I can find inspiration there
>> to turn my thoughts into a more articulate proposal. It certainly looks
>> like it would be a lot of work, but I think there is a chance I could
>> convince my manager to work on some of this on his dime.
>>
>> Jaime
>>
>> --
>> (\__/)
>> ( O.o)
>> ( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes
>> de dominación mundial.
>>
>> _______________________________________________
>> SciPy-Dev mailing list
>> SciPy-Dev at python.org
>> https://mail.python.org/mailman/listinfo/scipy-dev
>>
>>
>
>
> --
> _____________________________________
> Dr. Andrew Nelson
>
>
> _____________________________________
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev at python.org
> https://mail.python.org/mailman/listinfo/scipy-dev
>


-- 
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes
de dominación mundial.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20180209/722e2137/attachment.html>


More information about the SciPy-Dev mailing list