|
Alert!
CVXMOD is discontinued! Unfortunately CVXMOD has not been developed since 2008. It is incomplete, somewhat buggy and not supported. Please instead try the replacement package CVXPY. Or, try CVXOPT if you are prepared to work at a lower level, CVX if you are ok with Matlab, or CVXGEN if you want small (but super high speed) QP solvers. Expressions are made when parameters and variables are combined with arithmetic or used in functions. Variables, parameters, matrices and scalars may also be treated as expressions for the purpose of expression operations. Expressions can combine parameters, variables, ints, floats and matrices. ArithmeticSimple arithmetic can be used to create new expressions. Checking of sizes (including symbolic checking) ensures that expressions are valid. Example: Arithmetic
>>> A = param('A', 5, 3) >>> b = param('b', 5) >>> x = optvar('x', 3, 1) >>> 3*x <3x1 expression 3*x; optvars: x> >>> -x <3x1 expression -x; optvars: x> >>> A*x <5x1 expression A*x; optvars: x> >>> A*x - b <5x1 expression A*x - b; optvars: x> >>> A - b --------------------------------------------------------------------------- # some text cut. <class 'cvxmod.errors.DimError'>: expressions have incompatible dimensions Utility functionsCVXMOD provides some convenient functions for use with expressions.
The functions concathoriz and concatvert currently only work with ints, floats and matrices. They will eventually be able to take general expressions as their arguments. Example: Transposition
>>> x = optvar('x', 5) >>> tp(x) <1x5 expression tp(x); optvars: x> >>> A = param('A', 10, 5) >>> tp(A*x) <1x10 expression tp(A*x); optvars: x> |