Function 'subsindex' is not defined for values of class 'cvx'


(Tajiki) #1

I faced a problem in line “failurProb(Z(f))<=MT;” with the following error:
Function ‘subsindex’ is not defined for values of class ‘cvx’.

The code is as follwoing

failurProb= ones(1,10);
MT=5;
cvx_begin
cvx_solver MOSEK
variable Z(numberOfFlows);
for f=1:4
failurProb(Z(f))<=MT;
end
cvx_end


(Mark L. Stone) #2

You can’t have a CVX variable in an index.

What constraint(s) are you trying to achieve with failurProb(Z(f))<=MT ? failurProb was set to ones(1,10) and is not a CVX variable. So even if it were allowed, the constraint doesn’t make sense to me.


(Tajiki) #3

Thanks for the kind and fast response. I just simplified the problem to make it understandable (failureProb is not equal to ones(1,10))

Is there any substitute solution for using a CVX variable as an index?


(Mark L. Stone) #4

You have not yet made a (successful) edit. Your problem statement has not changed.

As to whether there is a substitute solution for using a CVX variable as an index, it depends on what you are trying to do. Perhaps there is a reformulation which complies with CVX’s rules. One possibility to handle certain non-convex constraints is use of binary or integer variables to achieve what you want, making use of CVX’s MIDCP capability. Given that you are using MOSEK, the MIDCP capability is available to you.