# Variable Length Optimization Algorithms?

**URL:** <https://discourse.julialang.org/t/variable-length-optimization-algorithms/78285>\
**Category:** Optimization (Mathematical)\
**Created:** [March 22, 2022, 3:59pm UTC](https://discourse.julialang.org/t/variable-length-optimization-algorithms/78285 "2022-03-22T15:59:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ParadaCarleton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paradacarleton/32/20005_2.png) [@ParadaCarleton](https://discourse.julialang.org/u/ParadaCarleton)\
**Post date:** [March 22, 2022, 3:59pm UTC](https://discourse.julialang.org/t/variable-length-optimization-algorithms/78285/1 "2022-03-22T15:59:54Z")

</div>

Are there any implementations of algorithms for variable-length optimization, where the number of parameters can vary? Examples can be found [here](https://www.tandfonline.com/doi/pdf/10.1080/0305215X.2017.1316845?casa_token=kaT_POIZdSIAAAAA:D1VNZcFj094lCZENBt3VI48dGYUrmQ8wd_vPhevh_k5NgdUcdyVBdFoaZGr3GyCe_yZT2lpbCfN-jA) (particle swarm based), [here](https://www.sciencedirect.com/science/article/pii/S0957417416301634), [here](https://arxiv.org/abs/2006.12703), and [here](https://link.springer.com/article/10.1007/s10710-016-9282-8) (genetic algorithms).

(If not, I’d love to see a package implementing some!)

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [March 22, 2022, 7:48pm UTC](https://discourse.julialang.org/t/variable-length-optimization-algorithms/78285/2 "2022-03-22T19:48:01Z")

</div>

Is this explicitly for genetic algorithms?

---

<div class="post-metadata">

**Author:** ![ParadaCarleton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paradacarleton/32/20005_2.png) [@ParadaCarleton](https://discourse.julialang.org/u/ParadaCarleton)\
**Post date:** [March 22, 2022, 7:59pm UTC](https://discourse.julialang.org/t/variable-length-optimization-algorithms/78285/3 "2022-03-22T19:59:13Z")

</div>

Not necessarily; one of the algorithms I linked was a particle swarm. The general principle is just that I have a number of parameters that can vary and needs to be optimized alongside the parameters themselves. Any packages that work in this case would be much appreciated.

A good example of these problems would be trying to optimize both the number and placement of knots for a spline being fit to data, or modeling a distribution as a mixture of n normals (where n is unknown).

---

<div class="post-metadata">

**Author:** ![ParadaCarleton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paradacarleton/32/20005_2.png) [@ParadaCarleton](https://discourse.julialang.org/u/ParadaCarleton)\
**Post date:** [March 22, 2022, 8:02pm UTC](https://discourse.julialang.org/t/variable-length-optimization-algorithms/78285/4 "2022-03-22T20:02:49Z")

</div>

Oh, wait, I just realized I’d forgotten to link the particle swarm method. I’ve added it now, sorry about that!
