🌐
Cvxpy
cvxpy.org › api_reference › cvxpy.constraints.html
Constraints -
Checks whether the constraint violation is less than a tolerance. ... The absolute tolerance to impose on the violation. ... True if the violation is less than tolerance, False otherwise. ... ValueError – If the constrained expression does not have a value associated with it. class cvxpy.cons...
🌐
Google Groups
groups.google.com › g › cvxpy › c › c0CmNleJwTs
Linear formulation of an absolute value constraint used to limit portfolio turnover
November 30, 2016 - constraints = [sum_entries(w) == 1, w >= 0, w.T * beta == 0, sum_entries(abs(w)) <= some threshold, etc.....]
🌐
Cvxpy
cvxpy.org › tutorial › constraints › index.html
Advanced Constraints -
The top-level expressions in the problem objective must be real valued, but subexpressions may be complex. Arithmetic and all linear atoms are defined for complex expressions. The nonlinear atoms abs and all norms except norm(X, p) for p < 1 are also defined for complex expressions. All atoms whose domain is symmetric matrices are defined for Hermitian matrices. Similarly, the atoms quad_form(x, P) and matrix_frac(x, P) are defined for complex x and Hermitian P. All constraints are defined for complex expressions.
🌐
Cvxopt
cvxopt.org › userguide › modeling.html
Modeling — CVXOPT User's Guide
Using this modeling tool, one can specify an optimization problem by first defining the optimization variables (see the section Variables), and then specifying the objective and constraint functions using linear operations (vector addition and subtraction, matrix-vector multiplication, indexing and slicing) and nested evaluations of max, min, abs and sum (see the section Functions). A more general Python convex modeling package is CVXPY. Optimization variables are represented by variable objects. ... A vector variable. The first argument is the dimension of the vector (a positive integer with default value 1).
🌐
Cvxpy
cvxpy.org › version › 1.1 › api_reference › cvxpy.constraints.html
Constraints — CVXPY 1.1.24 documentation
Additionally, most users need not know anything more about constraints other than how to create them. The constraint APIs do nonetheless provide methods that advanced users may find useful; for example, some of the APIs allow you to inspect dual variable values and residuals. class cvxpy.const...
🌐
Stack Overflow
stackoverflow.com › questions › 67350713 › absolute-value-function-not-recognized-as-disciplined-convex-program-cvxpy
python 3.x - Absolute value function not recognized as Disciplined Convex Program (CVXPY) - Stack Overflow
import cvxpy as cp import numpy as np weights_vec = cp.Variable(10) er_vec = cp.Parameter(10, value=np.random.randn(10)) prev_h_vec = cp.Parameter(10, value=np.ones(10)) tcost_vec = cp.Parameter(10, value=[0.03]*10) objective = cp.Maximize(weights_vec @ er_vec - tcost_vec @ cp.abs(weights_vec - prev_h_vec)) prob = cp.Problem(objective) prob.solve() ... cvxpy.error.DCPError: Problem does not follow DCP rules. Specifically: The objective is not DCP. Its following subexpressions are not: param516 @ abs(var513 + -param515) The absolute function is convex.
🌐
Cvxpy
cvxpy.org › version › 1.3 › api_reference › cvxpy.constraints.html
Constraints — CVXPY 1.3 documentation
Checks whether the constraint violation is less than a tolerance. Parameters: tolerance (float) – The absolute tolerance to impose on the violation. Returns: True if the violation is less than tolerance, False otherwise. Return type: bool · Raises: ValueError – If the constrained expression ...
🌐
Cvxpy
cvxpy.org › _modules › cvxpy › atoms › elementwise › abs.html
cvxpy.atoms.elementwise.abs -
[docs] class abs(Elementwise): """ Elementwise absolute value """ _allow_complex = True def __init__(self, x) -> None: super(abs, self).__init__(x) # Returns the elementwise absolute value of x. @Elementwise.numpy_numeric def numeric(self, values): return np.absolute(values[0]) def sign_from_args(self) -> Tuple[bool, bool]: """Returns sign (is positive, is negative) of the expression.
🌐
Cvxpy
cvxpy.org › tutorial › advanced › index.html
Advanced Features -
The fact that the dual variable is non-zero also tells us that if we tighten x - y >= 1, (i.e., increase the right-hand side), the optimal value of the problem will increase. Transforms provide additional ways of manipulating CVXPY objects beyond the atomic functions. For example, the indicator transform converts a list of constraints into an expression representing the convex function that takes value 0 when the constraints hold and \(\infty\) when they are violated.
🌐
Cvxpy
cvxpy.org › _modules › cvxpy › constraints › constraint.html
cvxpy.constraints.constraint -
[docs] def value(self, tolerance: float = 1e-8): """Checks whether the constraint violation is less than a tolerance. Parameters ---------- tolerance : float The absolute tolerance to impose on the violation. Returns ------- bool True if the violation is less than ``tolerance``, False otherwise.
Find elsewhere
🌐
Readthedocs
cvxpy.readthedocs.io › en › refactoring-advanced-features › tutorial › constraints › index.html
Advanced Constraints -
March 11, 2015 - # Creates a 10-vector constrained to have boolean valued entries. x = cp.Variable(10, boolean=True) # expr1 must be boolean valued. constr1 = (expr1 == x) # Creates a 5 by 7 matrix constrained to have integer valued entries. Z = cp.Variable((5, 7), integer=True) # expr2 must be integer valued. constr2 = (expr2 == Z) CVXPY provides interfaces to many mixed-integer solvers, including open source and commercial solvers.
🌐
Cvxr
ask.cvxr.com › t › absolute-value-function-used-in-the-objective-of-disciplined-convex-program-cvxpy › 8699
Absolute value function used in the objective of Disciplined Convex Program (CVXPY) - CVX Forum: a community-driven support forum
May 1, 2021 - I am trying to run the following optimization using CVXPY: weights_vec = cp.Variable(10) er_vec = cp.Parameter(10, value=np.random.randn(10)) prev_h_vec = cp.Parameter(10, value=np.ones(10)) tcost_vec = cp.Parameter(10, value=[0.03]*10) objective = cp.Maximize(weights_vec @ er_vec - tcost_vec @ cp.abs(weights_vec - prev_h_vec)) prob = cp.Problem(objective) prob.solve() However, I get the following error: cvxpy.error.DCPError: Problem does not follow DCP rules.
🌐
Cvxpy
cvxpy.org › version › 1.2 › api_reference › cvxpy.constraints.html
Constraints — CVXPY 1.2 documentation
Additionally, most users need not know anything more about constraints other than how to create them. The constraint APIs do nonetheless provide methods that advanced users may find useful; for example, some of the APIs allow you to inspect dual variable values and residuals. class cvxpy.const...
🌐
Cvxr
ask.cvxr.com › nonconvex
How to Define the Absolute function in the Constraint of SDP - Nonconvex - CVX Forum: a community-driven support forum
November 15, 2022 - Hi folks, As you can see the fourth constraint has an absolute value. When I use abs(.) function, CVX makes an error: Error using cvxprob/newcnstr Disciplined convex programming error: Invalid constraint: {real affine}
🌐
Cvxpy
cvxpy.org › version › 1.4 › api_reference › cvxpy.constraints.html
Constraints — CVXPY 1.4 documentation
Checks whether the constraint violation is less than a tolerance. Parameters: tolerance (float) – The absolute tolerance to impose on the violation. Returns: True if the violation is less than tolerance, False otherwise. Return type: bool · Raises: ValueError – If the constrained expression ...
🌐
Cvxpy
cvxpy.org › version › 1.1 › api_reference › cvxpy.atoms.elementwise.html
cvxpy.atoms.elementwise package — CVXPY 1.1.24 documentation
class cvxpy.atoms.elementwise.abs.abs(x)[source]¶ · Bases: Elementwise · Elementwise absolute value · class cvxpy.atoms.elementwise.entr.entr(x)[source]¶ · Bases: Elementwise · Elementwise \(-x\log x\). class cvxpy.atoms.elementwise.exp.exp(x)[source]¶ ·
🌐
Cvxpy
cvxpy.org › api_reference › cvxpy.atoms.elementwise.html
cvxpy.atoms.elementwise package -
class cvxpy.abs(x)[source]¶ · Bases: Elementwise · Elementwise absolute value · class cvxpy.entr(x)[source]¶ · Bases: Elementwise · Elementwise \(-x\log x\). class cvxpy.exp(x)[source]¶ · Bases: Elementwise · Elementwise \(e^{x}\). class cvxpy.huber(x, M: int = 1)[source]¶ ·