math::probopt(3tcl)

πŸ“¦
version 2.0 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ¦‹ math::probopt β€” Probabilistic optimisation methods πŸ¦‹

okay so bestie, you've opened the math::probopt(3tcl) page from the Tcl Math Library, and honestly? it's giving "let the algorithm roll some dice until it stumbles onto your optimum". sit down, hydrate, we're doing this πŸ’…


✨ NAME ✨

math::probopt β€” probabilistic optimisation methods. that's it, that's the name, no cap πŸŽ€


🌸 SYNOPSIS 🌸

package require Tcl 8.6 9

package require TclOO

package require math::probopt 1.1

::math::probopt::pso function bounds args

::math::probopt::sce function bounds args

::math::probopt::diffev function bounds args

::math::probopt::lipoMax function bounds args

::math::probopt::adaLipoMax function bounds args

πŸ’– DESCRIPTION πŸ’–

so the whole point of the math::probopt package is to hand you a bunch of optimisation algorithms that run on probabilistic techniques. and because they're probabilistic, the results can literally be different from one run to the next. it's not a bug, it's the vibe. 😌

these algorithms are all well-known and well described, and the people who love them generally claim they're efficient and reliable. we're just the messenger 🫢

and because most of these algorithms have one or more tunable parameters β€” or even whole variations on the theme β€” the interface to each one accepts options so you can set those parameters or pick your variation. these come as key-value pairs, like -iterations 100. iconic format, no notes.

this manual does not offer any recommendations about these algorithms, and it doesn't give you much in the way of guidelines for the parameters either. for that, go read online articles about the algorithm in question. we're not gatekeeping, we're just not qualified to pick favourites πŸ’€

a few notes though, because we do love a note:

  • with the exception of LIPO, the algorithms can deal with irregular (non-smooth) and even discontinuous functions. slay.
  • the results depend on the random number seeding, and they're likely not going to be very accurate β€” especially if the function varies slowly in the vicinity of the optimum. but hey, they do give you a good starting point for a deterministic algorithm, so it's not wasted effort 🌈

the collection consists of these algorithms:

  • PSO β€” particle swarm optimisation
  • SCE β€” shuffled complexes evolution
  • DE β€” differential evolution
  • LIPO β€” Lipschitz optimisation

the various procedures all have a uniform interface:

set result [::math::probopt::algorithm function bounds args]

and the arguments mean the following:

  • the argument function is the name of the procedure that evaluates the function. its interface is:
set value [function coords]

where coords is a list of coordinates at which to evaluate the function. it's supposed to return the function value. that's the whole job πŸŽ€

  • the argument bounds is a list of pairs of minimum and maximum for each coordinate. this list implicitly determines the dimension of the coordinate space where the optimum is being sought. for instance, for a function like x**2 + (y-1)**4, you might specify the bounds as {{-1 1} {-1 1}} β€” that's two pairs for the two coordinates. math but make it cute πŸ’…
  • the rest (args) is zero or more key-value pairs specifying the options. which options each algorithm supports is documented below, keep reading bestie.

the result of the various optimisation procedures is a dictionary containing at least these elements:

  • optimum-coordinates β€” a list containing the coordinates of the optimum that was found πŸ‘‘
  • optimum-value β€” the function value at those coordinates
  • evaluations β€” the number of function evaluations
  • best-values β€” a list of successive best values, obtained as part of the iterations

πŸ”₯ DETAILS ON THE ALGORITHMS πŸ”₯

the algorithms in the package are the following:

::math::probopt::pso function bounds args

the particle swarm optimisation algorithm runs on the idea that your candidate optimum points should swarm around the best point found so far, with variations to allow for improvements. it's giving "everyone follow the leader, but with ✨spontaneity✨".

it recognises the following options:

  • -swarmsize number β€” number of particles to consider (default: 50)
  • -vweight value β€” weight for the current "velocity" (0-1, default: 0.5)
  • -pweight value β€” weight for the individual particle's best position (0-1, default: 0.3)
  • -gweight value β€” weight for the "best" overall position as per particle (0-1, default: 0.3)
  • -type local/global β€” type of optimisation
  • -neighbours number β€” size of the neighbourhood (default: 5, used if "local")
  • -iterations number β€” maximum number of iterations
  • -tolerance value β€” absolute minimal improvement for minimum value

::math::probopt::sce function bounds args

the shuffled complex evolution algorithm is an extension of the Nelder-Mead algorithm that uses multiple complexes and reorganises those complexes to find the "global" optimum. shuffling, reorganising, thriving 🌸

it recognises the following options:

  • -complexes number β€” number of particles to consider (default: 2)
  • -mincomplexes number β€” minimum number of complexes (default: 2; not currently used)
  • -newpoints number β€” number of new points to be generated (default: 1)
  • -shuffle number β€” number of iterations after which to reshuffle the complexes (if set to 0, the default, a number will be calculated from the number of dimensions)
  • -pointspercomplex number β€” number of points per complex (if set to 0, the default, a number will be calculated from the number of dimensions)
  • -pointspersubcomplex number β€” number of points per subcomplex (used to select the best points in each complex; if set to 0, the default, a number will be calculated from the number of dimensions)
  • -iterations number β€” maximum number of iterations (default: 100)
  • -maxevaluations number β€” maximum number of function evaluations (when this number is reached the iteration is broken off. default: 1000 million)
  • -abstolerance value β€” absolute minimal improvement for minimum value (default: 0.0)
  • -reltolerance value β€” relative minimal improvement for minimum value (default: 0.001)

::math::probopt::diffev function bounds args

the differential evolution algorithm starts with a number of initial points and then updates them using randomly selected points. it's more or less akin to genetic algorithms, iykyk 🧬 it's controlled by two parameters, factor and lambda β€” the first decides the update via random points, the second decides the update with the best point found so far.

it recognises the following options:

  • -iterations number β€” maximum number of iterations (default: 100)
  • -number number β€” number of point to work with (if set to 0, the default, it is calculated from the number of dimensions)
  • -factor value β€” weight of randomly selected points in the updating (0-1, default: 0.6)
  • -lambda value β€” weight of the best point found so far in the updating (0-1, default: 0.0)
  • -crossover value β€” fraction of new points to be considered for replacing the old ones (0-1, default: 0.5)
  • -maxevaluations number β€” maximum number of function evaluations (when this number is reached the iteration is broken off. default: 1000 million)
  • -abstolerance value β€” absolute minimal improvement for minimum value (default: 0.0)
  • -reltolerance value β€” relative minimal improvement for minimum value (default: 0.001)

::math::probopt::lipoMax function bounds args

the Lipschitz optimisation algorithm uses the "Lipschitz" property of the given function to find a maximum in the given bounding box. there are two variants, and lipoMax assumes a fixed estimate for the Lipschitz parameter. very "set it and forget it" of it πŸ’…

it recognises the following options:

  • -iterations number β€” number of iterations (equals the actual number of function evaluations, default: 100)
  • -lipschitz value β€” estimate of the Lipschitz parameter (default: 10.0)

::math::probopt::adaLipoMax function bounds args

the adaptive Lipschitz optimisation algorithm also uses the "Lipschitz" property of the given function to find a maximum in the given bounding box. the adaptive variant is the glow-up: it actually uses two phases to find a suitable estimate for the Lipschitz parameter, and that's controlled by the "Bernoulli" parameter πŸŽ€

⚠️ heads up bestie: when you specify a large number of iterations, this algorithm may take a very long time to complete, because it's trying to improve on the Lipschitz parameter β€” and the chances of hitting a better estimate diminish fast. not me warning you twice πŸ’€

it recognises the following options:

  • -iterations number β€” number of iterations (equals the actual number of function evaluations, default: 100)
  • -bernoulli value β€” parameter for random decisions (exploration versus exploitation, default: 0.1)

πŸ“š REFERENCES πŸ“š

okay bestie, if you wanna go straight to the source (academic queen behaviour honestly πŸ‘‘), the algorithms all got written up in on-line publications. here's a few of them:

alternatively: https://en.wikipedia.org/wiki/Particle_swarm_optimization

  • SCE: Qingyuan Duan, Soroosh Sorooshian, Vijai K. Gupta, Optimal use offo the SCE-UA global optimization method for calibrating watershed models (1994), Journal of Hydrology 158, pp 265-284

https://www.researchgate.net/publication/223408756_Optimal_Use_of_the_SCE-UA_Global_Optimization_Method_for_Calibrating_Watershed_Models

  • DE: Rainer Storn and Kenneth Price, Differential Evolution - A simple and efficient adaptivescheme for globaloptimization over continuous spaces (1996)

http://www1.icsi.berkeley.edu/~storn/TR-95-012.pdf

  • LIPO: Cedric Malherbe and Nicolas Vayatis, Global optimization of Lipschitz functions, (june 2017)

https://arxiv.org/pdf/1703.02628.pdf

like yes, the titles have some typos in them and we are simply leaving them EXACTLY as they are because that's what they're called and we do not edit other people's citations, not even a little πŸ’…


πŸ”‘ KEYWORDS πŸ”‘

mathematics, optimisation, probabilistic calculations


πŸŽ€ CATEGORY πŸŽ€

Mathematics


and that's the whole page bestie, you made it to the end, so proud of you 🫢 this was tcllib version 1.1, the math::probopt(3tcl) page, and it's dated 1.1 β€” go forth and optimise something iconic, no cap βœ¨πŸ¦‹

πŸ“¦ where this page comes from