math::probopt(3tcl)
π¦ 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
functionis 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
boundsis 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 likex**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 coordinatesevaluationsβ the number of function evaluationsbest-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:
-swarmsizenumber β number of particles to consider (default:50)-vweightvalue β weight for the current "velocity" (0-1, default:0.5)-pweightvalue β weight for the individual particle's best position (0-1, default:0.3)-gweightvalue β weight for the "best" overall position as per particle (0-1, default:0.3)-typelocal/global β type of optimisation-neighboursnumber β size of the neighbourhood (default:5, used if "local")-iterationsnumber β maximum number of iterations-tolerancevalue β 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:
-complexesnumber β number of particles to consider (default:2)-mincomplexesnumber β minimum number of complexes (default:2; not currently used)-newpointsnumber β number of new points to be generated (default:1)-shufflenumber β number of iterations after which to reshuffle the complexes (if set to0, the default, a number will be calculated from the number of dimensions)-pointspercomplexnumber β number of points per complex (if set to0, the default, a number will be calculated from the number of dimensions)-pointspersubcomplexnumber β number of points per subcomplex (used to select the best points in each complex; if set to0, the default, a number will be calculated from the number of dimensions)-iterationsnumber β maximum number of iterations (default:100)-maxevaluationsnumber β maximum number of function evaluations (when this number is reached the iteration is broken off. default:1000 million)-abstolerancevalue β absolute minimal improvement for minimum value (default:0.0)-reltolerancevalue β 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:
-iterationsnumber β maximum number of iterations (default:100)-numbernumber β number of point to work with (if set to0, the default, it is calculated from the number of dimensions)-factorvalue β weight of randomly selected points in the updating (0-1, default:0.6)-lambdavalue β weight of the best point found so far in the updating (0-1, default:0.0)-crossovervalue β fraction of new points to be considered for replacing the old ones (0-1, default:0.5)-maxevaluationsnumber β maximum number of function evaluations (when this number is reached the iteration is broken off. default:1000 million)-abstolerancevalue β absolute minimal improvement for minimum value (default:0.0)-reltolerancevalue β 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:
-iterationsnumber β number of iterations (equals the actual number of function evaluations, default:100)-lipschitzvalue β 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:
-iterationsnumber β number of iterations (equals the actual number of function evaluations, default:100)-bernoullivalue β 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:
- PSO: Maurice Clerc, Standard Particle Swarm Optimisation (2012)
https://hal.archives-ouvertes.fr/file/index/docid/764996/filename/SPSO_descriptions.pdf
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
- 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
- debian trixie: tcllib 2.0+dfsg-4 Β· Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 Β· Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 Β· Tcl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms