placo::problem#
- class placo.Expression#
- A: ndarray#
Expression A matrix, in Ax + b.
- b: ndarray#
Expression b vector, in Ax + b.
- cols() int#
Number of cols in A.
- static from_double(self, value: float) Expression#
Builds an expression from a double (A will be zero, the expression is only one row)
- Parameters:
value (float) – value
- static from_vector(self, v: ndarray) Expression#
Builds an expression from a vector (A will be zeros)
- Parameters:
v (numpy.ndarray) – vector
- is_constant() bool#
checks if the expression is constant (doesn’t depend on decision variables)
- is_scalar() bool#
checks if the expression is a scalar
- left_multiply(M: ndarray) Expression#
Multiply an expression on the left by a given matrix M.
- Parameters:
M (numpy.ndarray) – matrix
- mean() Expression#
Reduces a multi-rows expression to the mean of its items.
- piecewise_add(f: float) Expression#
Adds the expression element by element to another expression.
- rows() int#
Number of rows in A.
- slice(start: int, rows: int = -1) Expression#
Slice rows from a given expression.
- Parameters:
start (int) – start row
rows (int) – number of rows (default: -1, all rows)
- sum() Expression#
Reduces a multi-rows expression to the sum of its items.
- value(x: ndarray) ndarray#
Retrieve the expression value, given a decision variable. This can be used after a problem is solved to retrieve a specific expression value.
- class placo.Integrator#
Integrator can be used to efficiently build expressions and values over a decision variable that is integrated over time with a given linear system.
- A: ndarray#
The discrete system matrix such that $X_{k+1} = A X_k + B u_k$.
- B: ndarray#
The discrete system matrix such that $X_{k+1} = A X_k + B u_k$.
- M: ndarray#
The continuous system matrix.
- expr(step: int, diff: int = -1) Expression#
Builds an expression for the given step and differentiation.
- Parameters:
step (int) – the step, (if -1 the last step will be used)
diff (int) – differentiation (if -1, the expression will be a vector of size order with all orders)
- expr_t(t: float, diff: int = -1) Expression#
Builds an expression for the given time and differentiation.
- Parameters:
t (float) – the time
diff (int) – differentiation (if -1, the expression will be a vector of size order with all orders)
- final_transition_matrix: ndarray#
Caching the discrete matrix for the last step.
- get_trajectory() IntegratorTrajectory#
Retrieve a trajectory after a solve.
- t_start: float#
Time offset for the trajectory.
- static upper_shift_matrix(self, order: int) ndarray#
Builds a matrix M so that the system differential equation is dX = M X.
- value(t: float, diff: int) float#
Computes.
- class placo.IntegratorTrajectory#
- duration() float#
Trajectory duration.
- value(t: float, diff: int) float#
Gets the value of the trajectory at a given time and differentiation.
- Parameters:
t (float) – time
diff (int) – differentiation
- class placo.PolygonConstraint#
- static in_polygon(self, expression_x: Expression, expression_y: Expression, polygon: list[ndarray], margin: float = 0.0) ProblemConstraint#
- static in_polygon_xy(self, expression_xy: Expression, polygon: list[ndarray], margin: float = 0.0) ProblemConstraint#
Given a polygon, produces inequalities so that the given point lies inside the polygon. WARNING: Polygon must be clockwise (meaning that the exterior of the shape is on the trigonometric normal of the vertices)
- class placo.Problem#
- add_constraint(constraint: ProblemConstraint) ProblemConstraint#
Adds a given constraint to the problem.
- add_limit(expression: Expression, target: ndarray) ProblemConstraint#
Adds a limit, “absolute” inequality constraint (abs(Ax + b) <= t)
- add_variable(size: int = 1) Variable#
Adds a n-dimensional variable to a problem.
- Parameters:
size (int) – dimension of the variable
- clear_constraints() None#
Clear all the constraints.
- clear_variables() None#
Clear all the variables.
- determined_variables: int#
Number of determined variables.
- dump_status() None#
- free_variables: int#
Number of free variables to solve.
- n_equalities: int#
Number of equalities.
- n_inequalities: int#
Number of inequality constraints.
- n_variables: int#
Number of problem variables that need to be solved.
- regularization: float#
Default internal regularization.
- rewrite_equalities: bool#
If set to true, a QR factorization will be performed on the equality constraints, and the QP will be called with free variables only.
- slack_variables: int#
Number of slack variables in the solver.
- slacks: ndarray#
Computed slack variables.
- solve() None#
Solves the problem, raises QPError in case of failure.
- use_sparsity: bool#
If set to true, some sparsity optimizations will be performed when building the problem Hessian. This optimization is generally not useful for small problems.
- x: ndarray#
Computed result.
- class placo.ProblemConstraint#
Represents a constraint to be enforced by a Problem.
- configure(type: str, weight: float = 1.0) None#
Configures the constraint.
- Parameters:
weight (float) – weight
- expression: Expression#
The constraint expression (Ax + b)
- is_active: bool#
This flag will be set by the solver if the constraint is active in the optimal solution.
- priority: any#
Constraint priority.
- weight: float#
Constraint weight (for soft constraints)
- class placo.ProblemPolynom(variable: Variable)#
- expr(x: float, derivative: int = 0) Expression#
Builds a problem expression for the value of the polynom.
- Parameters:
x (float) – abscissa
derivative (int) – differentiation order (0: p, 1: p’, 2: p’’ etc.)
- class placo.Sparsity#
- add_interval(start: int, end: int) None#
Adds an interval to the sparsity, this will compute the union of intervals.
- Parameters:
start (int) – interval start
end (int) – interval end
- static detect_columns_sparsity(self, M: ndarray) Sparsity#
Helper to detect columns sparsity.
- Parameters:
M (numpy.ndarray) – given matrix
- intervals: list[SparsityInterval]#
Intervals of non-sparse columns.
- print_intervals() None#
Print intervals.
- class placo.Variable#
Represents a variable in a Problem.
- expr(start: int = -1, rows: int = -1) Expression#
Builds an expression from a variable.
- Parameters:
start (int) – start row (default: 0)
rows (int) – number of rows (default: -1, all rows)
- k_end: int#
End offset in the Problem.
- k_start: int#
Start offset in the Problem.
- value: ndarray#
Variable value, populated by Problem after a solve.