semivar

semivar defines a semi-continuous variable

Syntax

x = semivar(n)
x = semivar(n,m)
x = semivar(n,m,'type')
x = semivar(n,m,'type','field')

Examples

YALMIP defines a semi-continuous variable as a variable taking either the value 0, or any value between an upper and lower bound. In contrast to the definitions used in most mixed-integer solver, YALMIP allows negative variables, and will reformulate the model accordingly if required.

The following code defines a least squares problem with a constraint that all variables are either 0, or between 0.1 and 0.3.

A = randn(20,10);
b = randn(20,1);
x = semivar(10,1);

e = b-A*x;
F = [0.1 <= x <= 0.3];
optimize(F,norm(e,1));

Note that we have defined constraints which cuts away 0 from the feasible set. However, when the variable is defined with semivar, YALMIP understands that the simple bounds relate to the semi-continuous nature of the variable.

Comment

semivar requires that the solver used supports semi-continuous variables.

Leave a Comment