minimize -is:module

Minimization without derivatives
Minimize a named metric NB. For a version which generalizes over the underlying monad, see minimize
minimize free assigns finds a set element x from free that is contained in the least number of sets in assigns. Then it returns the assigns where x is contained in the associated set. This formulation allows us not to name x and thus we do not need a second type variable for set elements and no type family from set to its element type. Unchecked preconditions: free must be a superset of all sets in the assign list. free must be non-empty. The assigns list may be empty. The output of assigns must be a subsequence of the input assigns, that is, it must be a subset of the input and it must be in the same order. This requirement was originally needed by minimize for Map, but currently it is not utilized anywhere.
Minimize this metric
Minimize window (see XMonad.Actions.Minimize)
Deprecated: use minimizeD ConjugateFR eps maxit step tol f g xi
Minimization with derivatives.
Deprecated: use minimize NMSimplex2 eps maxit sizes f xi
Minimization without derivatives (vector version)
Minimization with derivatives (vector version)
Deprecated: use minimizeD VectorBFGS2 eps maxit step tol f g xi
Minimize a window
Widget for Minimize command

Example program

The following interactive session example enforces the same scalar constraint as the nonlinear constraint example, but this time it uses the augmented Lagrangian method to enforce the constraint and the SBPLX algorithm, which does not support nonlinear constraints itself, to perform the minimization. As before, the parameters must always sum to 1, and the minimizer finds the same constrained minimum of 22.5 at (0.5, 0.5).
>>> import Numeric.LinearAlgebra ( dot, fromList, toList )

>>> let objf x = x `dot` x + 22

>>> let stop = ObjectiveRelativeTolerance 1e-9 :| []

>>> let algorithm = SBPLX objf [] Nothing

>>> let subproblem = LocalProblem 2 stop algorithm

>>> let x0 = fromList [5, 10]

>>> minimizeLocal subproblem x0
Right (Solution {solutionCost = 22.0, solutionParams = [0.0,0.0], solutionResult = FTOL_REACHED})

>>> -- define constraint function:

>>> let constraintf x = sum (toList x) - 1.0

>>> -- define constraint object to pass to the algorithm:

>>> let constraint = EqualityConstraint (Scalar constraintf) 1e-6

>>> let problem = AugLagProblem [constraint] [] (AUGLAG_EQ_LOCAL subproblem)

>>> minimizeAugLag problem x0
Right (Solution {solutionCost = 22.500000015505844, solutionParams = [0.5000880506776678,0.4999119493223323], solutionResult = FTOL_REACHED})
Solve the specified global optimization problem.

Example program

The following interactive session example uses the ISRES algorithm, a stochastic, derivative-free global optimizer, to minimize a trivial function with a minimum of 22.0 at (0, 0). The search is conducted within a box from -10 to 10 in each dimension.
>>> import Numeric.LinearAlgebra ( dot, fromList )

>>> let objf x = x `dot` x + 22                              -- define objective

>>> let stop = ObjectiveRelativeTolerance 1e-12 :| []        -- define stopping criterion

>>> let algorithm = ISRES objf [] [] (SeedValue 22) Nothing  -- specify algorithm

>>> let lowerbounds = fromList [-10, -10]                    -- specify bounds

>>> let upperbounds = fromList [10, 10]                      -- specify bounds

>>> let problem = GlobalProblem lowerbounds upperbounds stop algorithm

>>> let x0 = fromList [5, 8]                                 -- specify initial guess

>>> minimizeGlobal problem x0
Right (Solution {solutionCost = 22.000000000002807, solutionParams = [-1.660591102367038e-6,2.2407062393213684e-7], solutionResult = FTOL_REACHED})

Example program

The following interactive session example enforces the same scalar constraint as the nonlinear constraint example, but this time it uses the SLSQP solver to find the minimum.
>>> import Numeric.LinearAlgebra ( dot, fromList, toList, scale )

>>> let objf x = (x `dot` x + 22, 2 `scale` x)

>>> let stop = ObjectiveRelativeTolerance 1e-9 :| []

>>> let constraintf x = (sum (toList x) - 1.0, fromList [1, 1])

>>> let constraint = EqualityConstraint (Scalar constraintf) 1e-6

>>> let algorithm = SLSQP objf [] [] [constraint]

>>> let problem = LocalProblem 2 stop algorithm

>>> let x0 = fromList [5, 10]

>>> minimizeLocal problem x0
Right (Solution {solutionCost = 22.5, solutionParams = [0.4999999999999998,0.5000000000000002], solutionResult = FTOL_REACHED})