TNC

class TNC(*args)

Truncated Newton Constrained solver.

Available constructors:

TNC(problem)

TNC(problem, scale, offset, maxCGit, eta, stepmx, accuracy, fmin, rescale)

Parameters:

problem : OptimizationProblem

Optimization problem to solve.

specificParameters : TNCSpecificParameters

Parameters for this solver.

scale : sequence of float

Scaling factors to apply to each variables

offset : sequence of float

Constant to substract to each variable

maxCGit : int

Maximum number of hessian*vector evaluation per main iteration

eta : float

Severity of the line search.

stepmx : float

Maximum step for the line search. may be increased during call

accuracy : float

Relative precision for finite difference calculations

fmin : float

Minimum function value estimate.

rescale : float

f scaling factor (in log10) used to trigger f value rescaling

Notes

Non-linear optimizer supporting bound constraints. This solver does not implement the progress callback.

Examples

>>> import openturns as ot
>>> model = ot.SymbolicFunction(['E', 'F', 'L', 'I'], ['-F*L^3/(3*E*I)'])
>>> bounds = ot.Interval([1.0]*4, [2.0]*4)
>>> problem = ot.OptimizationProblem(model, ot.Function(), ot.Function(), bounds)
>>> algo = ot.TNC(problem)
>>> algo.setStartingPoint([0.0] * 4)
>>> algo.run()
>>> result = algo.getResult()

Methods

computeLagrangeMultipliers(x) Compute the Lagrange multipliers of a problem at a given point.
getAccuracy() Accessor to accuracy parameter.
getClassName() Accessor to the object’s name.
getEta() Accessor to eta parameter.
getFmin() Accessor to fmin parameter.
getId() Accessor to the object’s id.
getMaxCGit() Accessor to maxCGit parameter.
getMaximumAbsoluteError() Accessor to maximum allowed absolute error.
getMaximumConstraintError() Accessor to maximum allowed constraint error.
getMaximumEvaluationNumber() Accessor to maximum allowed number of evaluations.
getMaximumIterationNumber() Accessor to maximum allowed number of iterations.
getMaximumRelativeError() Accessor to maximum allowed relative error.
getMaximumResidualError() Accessor to maximum allowed residual error.
getName() Accessor to the object’s name.
getOffset() Accessor to offset parameter.
getProblem() Accessor to optimization problem.
getRescale() Accessor to rescale parameter.
getResult() Accessor to optimization result.
getScale() Accessor to scale parameter.
getShadowedId() Accessor to the object’s shadowed id.
getStartingPoint() Accessor to starting point.
getStepmx() Accessor to stepmx parameter.
getVerbose() Accessor to the verbosity flag.
getVisibility() Accessor to the object’s visibility state.
hasName() Test if the object is named.
hasVisibleName() Test if the object has a distinguishable name.
run() Launch the optimization.
setAccuracy(accuracy) Accessor to accuracy parameter.
setEta(eta) Accessor to eta parameter.
setFmin(fmin) Accessor to fmin parameter.
setMaxCGit(maxCGit) Accessor to maxCGit parameter.
setMaximumAbsoluteError(maximumAbsoluteError) Accessor to maximum allowed absolute error.
setMaximumConstraintError(maximumConstraintError) Accessor to maximum allowed constraint error.
setMaximumEvaluationNumber(…) Accessor to maximum allowed number of evaluations.
setMaximumIterationNumber(maximumIterationNumber) Accessor to maximum allowed number of iterations.
setMaximumRelativeError(maximumRelativeError) Accessor to maximum allowed relative error.
setMaximumResidualError(maximumResidualError) Accessor to maximum allowed residual error.
setName(name) Accessor to the object’s name.
setOffset(offset) Accessor to offset parameter.
setProblem(problem) Accessor to optimization problem.
setProgressCallback(*args) Set up a progress callback.
setRescale(rescale) Accessor to rescale parameter.
setResult(result) Accessor to optimization result.
setScale(scale) Accessor to scale parameter.
setShadowedId(id) Accessor to the object’s shadowed id.
setStartingPoint(startingPoint) Accessor to starting point.
setStepmx(stepmx) Accessor to stepmx parameter.
setStopCallback(*args) Set up a stop callback.
setVerbose(verbose) Accessor to the verbosity flag.
setVisibility(visible) Accessor to the object’s visibility state.
__init__(*args)

x.__init__(…) initializes x; see help(type(x)) for signature

computeLagrangeMultipliers(x)

Compute the Lagrange multipliers of a problem at a given point.

Parameters:

x : sequence of float

Point at which the Lagrange multipliers are computed.

Returns:

lagrangeMultiplier : sequence of float

Lagrange multipliers of the problem at the given point.

Notes

The Lagrange multipliers \vect{\lambda} are associated with the following Lagrangian formulation of the optimization problem:

\cL(\vect{x}, \vect{\lambda}_{eq}, \vect{\lambda}_{\ell}, \vect{\lambda}_{u}, \vect{\lambda}_{ineq}) = J(\vect{x}) + \Tr{\vect{\lambda}}_{eq} g(\vect{x}) + \Tr{\vect{\lambda}}_{\ell} (\vect{x}-\vect{\ell})^{+} + \Tr{\vect{\lambda}}_{u} (\vect{u}-\vect{x})^{+} + \Tr{\vect{\lambda}}_{ineq}  h^{+}(\vect{x})

where \vect{\alpha}^{+}=(\max(0,\alpha_1),\hdots,\max(0,\alpha_n)).

The Lagrange multipliers are stored as (\vect{\lambda}_{eq}, \vect{\lambda}_{\ell}, \vect{\lambda}_{u}, \vect{\lambda}_{ineq}), where:
  • \vect{\lambda}_{eq} is of dimension 0 if there is no equality constraint, else of dimension the dimension of g(\vect{x}) ie the number of scalar equality constraints
  • \vect{\lambda}_{\ell} and \vect{\lambda}_{u} are of dimension 0 if there is no bound constraint, else of dimension of \vect{x}
  • \vect{\lambda}_{eq} is of dimension 0 if there is no inequality constraint, else of dimension the dimension of h(\vect{x}) ie the number of scalar inequality constraints

The vector \vect{\lambda} is solution of the following linear system:

\Tr{\vect{\lambda}}_{eq}\left[\dfrac{\partial g}{\partial\vect{x}}(\vect{x})\right]+
\Tr{\vect{\lambda}}_{\ell}\left[\dfrac{\partial (\vect{x}-\vect{\ell})^{+}}{\partial\vect{x}}(\vect{x})\right]+
\Tr{\vect{\lambda}}_{u}\left[\dfrac{\partial (\vect{u}-\vect{x})^{+}}{\partial\vect{x}}(\vect{x})\right]+
\Tr{\vect{\lambda}}_{ineq}\left[\dfrac{\partial h}{\partial\vect{x}}(\vect{x})\right]=-\dfrac{\partial J}{\partial\vect{x}}(\vect{x})

If there is no constraint of any kind, \vect{\lambda} is of dimension 0, as well as if no constraint is active.

getAccuracy()

Accessor to accuracy parameter.

Returns:

accuracy : float

Relative precision for finite difference calculations

if <= machine_precision, set to sqrt(machine_precision).

getClassName()

Accessor to the object’s name.

Returns:

class_name : str

The object class name (object.__class__.__name__).

getEta()

Accessor to eta parameter.

Returns:

eta : float

Severity of the line search.

if < 0 or > 1, set to 0.25.

getFmin()

Accessor to fmin parameter.

Returns:

fmin : float

Minimum function value estimate.

getId()

Accessor to the object’s id.

Returns:

id : int

Internal unique identifier.

getMaxCGit()

Accessor to maxCGit parameter.

Returns:

maxCGit : int

Maximum number of hessian*vector evaluation per main iteration

if maxCGit = 0, the direction chosen is -gradient

if maxCGit < 0, maxCGit is set to max(1,min(50,n/2)).

getMaximumAbsoluteError()

Accessor to maximum allowed absolute error.

Returns:

maximumAbsoluteError : float

Maximum allowed absolute error.

getMaximumConstraintError()

Accessor to maximum allowed constraint error.

Returns:

maximumConstraintError : float

Maximum allowed constraint error.

getMaximumEvaluationNumber()

Accessor to maximum allowed number of evaluations.

Returns:

N : int

Maximum allowed number of evaluations.

getMaximumIterationNumber()

Accessor to maximum allowed number of iterations.

Returns:

N : int

Maximum allowed number of iterations.

getMaximumRelativeError()

Accessor to maximum allowed relative error.

Returns:

maximumRelativeError : float

Maximum allowed relative error.

getMaximumResidualError()

Accessor to maximum allowed residual error.

Returns:

maximumResidualError : float

Maximum allowed residual error.

getName()

Accessor to the object’s name.

Returns:

name : str

The name of the object.

getOffset()

Accessor to offset parameter.

Returns:

offset : Point

Constant to substract to each variable

if empty, the constant are (min-max)/2 for interval bounded

variables and x for the others.

getProblem()

Accessor to optimization problem.

Returns:

problem : OptimizationProblem

Optimization problem.

getRescale()

Accessor to rescale parameter.

Returns:

rescale : float

f scaling factor (in log10) used to trigger f value rescaling

if 0, rescale at each iteration

if a big value, never rescale

if < 0, rescale is set to 1.3.

getResult()

Accessor to optimization result.

Returns:

result : OptimizationResult

Result class.

getScale()

Accessor to scale parameter.

Returns:

scale : Point

Scaling factors to apply to each variable

if empty, the factors are min-max for interval bounded variables

and 1+|x] for the others.

getShadowedId()

Accessor to the object’s shadowed id.

Returns:

id : int

Internal unique identifier.

getStartingPoint()

Accessor to starting point.

Returns:

startingPoint : Point

Starting point.

getStepmx()

Accessor to stepmx parameter.

Returns:

stepmx : float

Maximum step for the line search. may be increased during call

if too small, will be set to 10.0.

getVerbose()

Accessor to the verbosity flag.

Returns:

verbose : bool

Verbosity flag state.

getVisibility()

Accessor to the object’s visibility state.

Returns:

visible : bool

Visibility flag.

hasName()

Test if the object is named.

Returns:

hasName : bool

True if the name is not empty.

hasVisibleName()

Test if the object has a distinguishable name.

Returns:

hasVisibleName : bool

True if the name is not empty and not the default one.

run()

Launch the optimization.

setAccuracy(accuracy)

Accessor to accuracy parameter.

Parameters:

accuracy : float

Relative precision for finite difference calculations

if <= machine_precision, set to sqrt(machine_precision).

setEta(eta)

Accessor to eta parameter.

Parameters:

eta : float

Severity of the line search.

if < 0 or > 1, set to 0.25.

setFmin(fmin)

Accessor to fmin parameter.

Parameters:

fmin : float

Minimum function value estimate.

setMaxCGit(maxCGit)

Accessor to maxCGit parameter.

Parameters:

maxCGit : int

Maximum number of hessian*vector evaluation per main iteration

if maxCGit = 0, the direction chosen is -gradient

if maxCGit < 0, maxCGit is set to max(1,min(50,n/2)).

setMaximumAbsoluteError(maximumAbsoluteError)

Accessor to maximum allowed absolute error.

Parameters:

maximumAbsoluteError : float

Maximum allowed absolute error.

setMaximumConstraintError(maximumConstraintError)

Accessor to maximum allowed constraint error.

Parameters:

maximumConstraintError : float

Maximum allowed constraint error.

setMaximumEvaluationNumber(maximumEvaluationNumber)

Accessor to maximum allowed number of evaluations.

Parameters:

N : int

Maximum allowed number of evaluations.

setMaximumIterationNumber(maximumIterationNumber)

Accessor to maximum allowed number of iterations.

Parameters:

N : int

Maximum allowed number of iterations.

setMaximumRelativeError(maximumRelativeError)

Accessor to maximum allowed relative error.

Parameters:

maximumRelativeError : float

Maximum allowed relative error.

setMaximumResidualError(maximumResidualError)

Accessor to maximum allowed residual error.

Parameters:

maximumResidualError : float

Maximum allowed residual error.

setName(name)

Accessor to the object’s name.

Parameters:

name : str

The name of the object.

setOffset(offset)

Accessor to offset parameter.

Parameters:

offset : sequence of float

Constant to substract to each variable

if empty, the constant are (min-max)/2 for interval bounded

variables and x for the others.

setProblem(problem)

Accessor to optimization problem.

Parameters:

problem : OptimizationProblem

Optimization problem.

setProgressCallback(*args)

Set up a progress callback.

Parameters:

callback : callable

Takes a float as argument as percentage of progress.

Notes

May not be implemented by all solvers, refer to the solver documentation.

setRescale(rescale)

Accessor to rescale parameter.

Parameters:

rescale : float

f scaling factor (in log10) used to trigger f value rescaling

if 0, rescale at each iteration

if a big value, never rescale

if < 0, rescale is set to 1.3.

setResult(result)

Accessor to optimization result.

Parameters:

result : OptimizationResult

Result class.

setScale(scale)

Accessor to scale parameter.

Parameters:

scale : sequence of float

Scaling factors to apply to each variable

if empty, the factors are min-max for interval bounded variables

and 1+|x] for the others.

setShadowedId(id)

Accessor to the object’s shadowed id.

Parameters:

id : int

Internal unique identifier.

setStartingPoint(startingPoint)

Accessor to starting point.

Parameters:

startingPoint : Point

Starting point.

setStepmx(stepmx)

Accessor to stepmx parameter.

Parameters:

stepmx : float

Maximum step for the line search. may be increased during call

if too small, will be set to 10.0.

setStopCallback(*args)

Set up a stop callback.

Parameters:

callback : callable

Returns an int deciding whether to stop or continue.

Notes

May not be implemented by all solvers, refer to the solver documentation.

setVerbose(verbose)

Accessor to the verbosity flag.

Parameters:

verbose : bool

Verbosity flag state.

setVisibility(visible)

Accessor to the object’s visibility state.

Parameters:

visible : bool

Visibility flag.