OptimizationProblem

class OptimizationProblem(*args)

Base class to define an optimization problem.

This represents a general optimization problem:

\min_{x\in B} f(x) \\
g(x) = 0 \\
h(x) \ge 0

where B is problem’s bounds, f is the objective function, g are equality constraints, and h are inequality constraints.

Available constructors:

OptimizationProblem(objective)

OptimizationProblem(objective, equality, inequality, bounds)

Parameters:
objectiveFunction

Objective function. Additional constraints and bounds must always be consistent with the objective input dimension.

equalityFunction

Equality constraints.

inequalityFunction

Inequality constraints.

boundsInterval

Bounds.

Examples

Define an optimization problem to find the minimum of the Rosenbrock function:

>>> import openturns as ot
>>> rosenbrock = ot.SymbolicFunction(['x1', 'x2'], ['(1-x1)^2+100*(x2-x1^2)^2'])
>>> problem = ot.OptimizationProblem(rosenbrock)

Methods

getBounds()

Accessor to bounds.

getClassName()

Accessor to the object's name.

getDimension()

Accessor to input dimension.

getEqualityConstraint()

Accessor to equality constraints.

getId()

Accessor to the object's id.

getImplementation()

Accessor to the underlying implementation.

getInequalityConstraint()

Accessor to inequality constraints.

getLevelFunction()

Accessor to level function.

getLevelValue()

Accessor to level value.

getName()

Accessor to the object's name.

getObjective()

Accessor to objective function.

getResidualFunction()

Accessor to the residual function.

getVariablesType()

Accessor to the variables type.

hasBounds()

Test whether bounds had been specified.

hasEqualityConstraint()

Test whether equality constraints had been specified.

hasInequalityConstraint()

Test whether inequality constraints had been specified.

hasLevelFunction()

Test whether level function had been specified.

hasMultipleObjective()

Test whether objective function is a scalar or vector function.

hasResidualFunction()

Test whether a least-square problem is defined.

isContinuous()

Check if the problem is continuous.

isMinimization([marginalIndex])

Test whether this is a minimization or maximization problem.

setBounds(bounds)

Accessor to bounds.

setEqualityConstraint(equalityConstraint)

Accessor to equality constraints.

setInequalityConstraint(inequalityConstraint)

Accessor to inequality constraints.

setLevelFunction(levelFunction)

Accessor to level function.

setLevelValue(levelValue)

Accessor to level value.

setMinimization(minimization[, marginalIndex])

Tell whether this is a minimization or maximization problem.

setName(name)

Accessor to the object's name.

setObjective(objective)

Accessor to objective function.

setResidualFunction(residualFunction)

Accessor to the residual function.

setVariablesType(variableType)

Accessor to the variables type.

__init__(*args)
getBounds()

Accessor to bounds.

Returns:
boundsInterval

Problem bounds.

getClassName()

Accessor to the object’s name.

Returns:
class_namestr

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

getDimension()

Accessor to input dimension.

Returns:
dimensionint

Input dimension of objective function.

getEqualityConstraint()

Accessor to equality constraints.

Returns:
equalityFunction

Describe equality constraints.

getId()

Accessor to the object’s id.

Returns:
idint

Internal unique identifier.

getImplementation()

Accessor to the underlying implementation.

Returns:
implImplementation

A copy of the underlying implementation object.

getInequalityConstraint()

Accessor to inequality constraints.

Returns:
inequalityFunction

Describe inequality constraints.

getLevelFunction()

Accessor to level function.

Returns:
levelFunction

Level function.

getLevelValue()

Accessor to level value.

Returns:
valuefloat

Level value.

getName()

Accessor to the object’s name.

Returns:
namestr

The name of the object.

getObjective()

Accessor to objective function.

Returns:
objectiveFunction

Objective function.

getResidualFunction()

Accessor to the residual function.

Returns:
residualFunctionFunction

Residual function.

getVariablesType()

Accessor to the variables type.

Returns:
variablesTypeIndices

Types of the variables.

Notes

Possible values for each variable are ot.OptimizationProblemImplementation.CONTINUOUS, ot.OptimizationProblemImplementation.INTEGER and ot.OptimizationProblemImplementation.`BINARY`.

hasBounds()

Test whether bounds had been specified.

Returns:
valuebool

True if bounds had been set for this problem, False otherwise.

hasEqualityConstraint()

Test whether equality constraints had been specified.

Returns:
valuebool

True if equality constraints had been set for this problem, False otherwise.

hasInequalityConstraint()

Test whether inequality constraints had been specified.

Returns:
valuebool

True if inequality constraints had been set for this problem, False otherwise.

hasLevelFunction()

Test whether level function had been specified.

Returns:
valuebool

True if level function had been set for this problem, False otherwise.

hasMultipleObjective()

Test whether objective function is a scalar or vector function.

Returns:
valuebool

False if objective function is scalar, True otherwise.

hasResidualFunction()

Test whether a least-square problem is defined.

Returns:
valuebool

True if this is a least-squares problem, False otherwise.

isContinuous()

Check if the problem is continuous.

Returns:
isContinuousbool

Returns True if all variables are continuous.

isMinimization(marginalIndex=0)

Test whether this is a minimization or maximization problem.

Parameters:
marginal_indexint, default=0

Index of the output marginal (for multi-objective only)

Returns:
valuebool

True if this is a minimization problem (default), False otherwise.

setBounds(bounds)

Accessor to bounds.

Parameters:
boundsInterval

Problem bounds.

setEqualityConstraint(equalityConstraint)

Accessor to equality constraints.

Parameters:
equalityConstraintFunction

Equality constraints.

setInequalityConstraint(inequalityConstraint)

Accessor to inequality constraints.

Parameters:
inequalityConstraintFunction

Inequality constraints.

setLevelFunction(levelFunction)

Accessor to level function.

Parameters:
levelFunctionFunction

Level function.

setLevelValue(levelValue)

Accessor to level value.

Parameters:
levelValuefloat

Level value.

setMinimization(minimization, marginalIndex=0)

Tell whether this is a minimization or maximization problem.

Parameters:
minimizationbool

True if this is a minimization problem, False otherwise.

marginal_indexint, default=0

Index of the output marginal (for multi-objective only)

setName(name)

Accessor to the object’s name.

Parameters:
namestr

The name of the object.

setObjective(objective)

Accessor to objective function.

Parameters:
objectiveFunctionFunction

Objective function.

Notes

Constraints and bounds are cleared if the objective has a different input dimension in order to keep the problem valid at all time.

setResidualFunction(residualFunction)

Accessor to the residual function.

Parameters:
residualFunctionFunction

Residual function.

setVariablesType(variableType)

Accessor to the variables type.

Parameters:
variablesTypeIndices

Types of the variables.

Notes

Possible values for each variable are ot.OptimizationProblemImplementation.CONTINUOUS, ot.OptimizationProblemImplementation.INTEGER and ot.OptimizationProblemImplementation.BINARY.

Examples using the class

Kriging: configure the optimization solver

Kriging: configure the optimization solver

Linear Regression with interval-censored observations

Linear Regression with interval-censored observations

Optimization with constraints

Optimization with constraints

Optimization using NLopt

Optimization using NLopt

Mix/max search using optimization

Mix/max search using optimization

Optimization using bonmin

Optimization using bonmin

Multi-objective optimization using Pagmo

Multi-objective optimization using Pagmo

Quick start guide to optimization

Quick start guide to optimization

Optimization of the Rastrigin test function

Optimization of the Rastrigin test function

Optimization using dlib

Optimization using dlib

EfficientGlobalOptimization examples

EfficientGlobalOptimization examples