# Multiple dual variables at one constraint

Hi there,

I’m trying to use dual variables, but it appears not to work when there are 2 variables in one constraint.
Is there an option to make this work?

I’m trying to solve the following and want a dual variable for both x and y. If I try only one dual variable for the s variable, it does work.

``````variable x(m,1) nonnegative;
variable y(m,3) nonnegative;
variable s(n,3) nonnegative;
dual variables D1{3} D2{3};

minimize (sum(c'*x) + sum(-q.*(pb(1)*(y(:,1)) + ...
pb(2)*(y(:,2)) + pb(3)*(y(:,3)))) );
subject to
for z = 1:3
y(:,z) <= x : D1{z} D2{z};
s(:,z) <= s_max';
for i = 1:n
I(i,:)*y(:,z) == ksi(i,z) - p(i) + s(i,z);
end
end
``````

If someone can help me that would be great!

Dual variables pertain to (are associated with) constraints, not to (primal) variables.

The variables actually has to be nonnegative so they have a constraint and hence there is a dual variable.

variable x(m,1) nonnegative;

``````y(:,z) <= x : D{z};
``````

I get the error message:

``````Undefined operator ':' for input arguments of type 'cvx'.
``````

However, if I add it to a different constraint, it does work.

`s(:,z) <= s_max' : D{z};`

Do you have any idea where the problem can be?