LinearProblem

class LinearProblem(*args)

Linear optimization problem.

This defines a linear problem as:

\min_{\vect{x} \in B} f(\vect{x}) = \vect{c}^T \vect{x} \\
\vect{lc_l} \leq \mat{A} \vect{x} \leq \vect{lc_u}

where B are the problem bounds, \vect{c} is the cost vector, \mat{A} is the constraint matrix term, and \vect{cb_l}, \vect{cb_u} are the constraints bounds terms.

Parameters:
costFunction

The cost vector \vect{c}.

boundsInterval

Bound constraints B

AMatrix

Linear inequality constraints matrix \mat{A}

cbInterval

Linear inequality constraints bounds terms \vect{cb_l}, \vect{cb_u}

Methods

Linearize(problem, location)

Transform a general optimization problem to a linear problem.

getBounds()

Accessor to bounds.

getClassName()

Accessor to the object's name.

getDimension()

Accessor to input dimension.

getEqualityConstraint()

Accessor to equality constraints.

getInequalityConstraint()

Accessor to inequality constraints.

getLevelFunction()

Accessor to level function.

getLevelValue()

Accessor to level value.

getLinearConstraintBounds()

Accessor to the linear constraint bounds.

getLinearConstraintCoefficients()

Accessor to the linear constraint term.

getLinearCost()

Accessor to the linear cost.

getName()

Accessor to the object's name.

getObjective()

Accessor to objective function.

getResidualFunction()

Accessor to level 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.

hasName()

Test if the object is named.

hasResidualFunction()

Test whether a least-square problem is defined.

isContinuous()

Check if the problem is continuous.

isLinear()

Check if the problem is linear.

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.

setLinearConstraint(constraintCoefficients, LU)

Accessor to the linear constraint term.

setLinearCost(cost)

Accessor to the linear cost.

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 level function.

setVariablesType(variableType)

Accessor to the variables type.

Examples

Define a mixed integer linear optimization problem with objective:

f = 1.1 x_0 + x_1, x_0 \in \Zset, x_1 \in \Rset

with inequality constraints:

\begin{eqnarray*}
    & x_1 & \leq 7\\
    5 & \leq x_0 + 2x_1 & \leq 15\\
    6 & \leq 3x_0 + 2x_1 & \\
\end{eqnarray*}

and bound constraints:

\begin{eqnarray*}
    0 & \leq x_0 & \leq 4\\
    1 & \leq x_1 &
\end{eqnarray*}

>>> import openturns as ot
>>> import openturns.experimental as otexp
>>> cost = [1.1, 1.0]
>>> bounds = ot.Interval([0.0, 1.0], [4.0, 1e30])
>>> A = ot.Matrix([[0.0, 1.0], [1.0, 2.0], [3.0, 2.0]])
>>> lcb = ot.Interval([-1e9, 5.0, 6.0], [7.0, 15.0, 1e9])
>>> problem = otexp.LinearProblem(cost, bounds, A, lcb)
>>> problem.setVariablesType([ot.OptimizationProblemImplementation.INTEGER, ot.OptimizationProblemImplementation.CONTINUOUS])
__init__(*args)
static Linearize(problem, location)

Transform a general optimization problem to a linear problem.

Objective and inequality constraints coefficients are computed from their gradients at the specified location.

Parameters:
problemOptimizationProblem

The problem to linearize

locationsequence of float

The linearization location

Returns:
linearProblemLinearProblem

The linear problem

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.

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.

getLinearConstraintBounds()

Accessor to the linear constraint bounds.

Only relevant for the linear problem type.

Returns:
LUInterval

Linear inequality constraint bounds.

getLinearConstraintCoefficients()

Accessor to the linear constraint term.

Only relevant for the linear problem type.

Returns:
AMatrix

Linear inequality constraint term.

getLinearCost()

Accessor to the linear cost.

Only relevant for the linear problem type.

Returns:
costPoint

Linear cost term.

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 level function.

Returns:
levelFunction

Level 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.

hasName()

Test if the object is named.

Returns:
hasNamebool

True if the name is not empty.

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.

isLinear()

Check if the problem is linear.

Returns:
isLinearbool

Returns True if the problem is of linear type.

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.

setLinearConstraint(constraintCoefficients, LU)

Accessor to the linear constraint term.

Returns:
AMatrix

Linear inequality constraint term.

cbInterval

Linear inequality constraint bounds.

setLinearCost(cost)

Accessor to the linear cost.

Parameters:
costPoint

Linear cost term.

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 level function.

Parameters:
levelFunctionFunction

Level 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

Optimization using HiGHS solver

Optimization using HiGHS solver