Invalid constraint: {real affine} == {convex}

Dear all,

When I add a equality constraint about “T_F” to "subject to " in cvx I got this error
错误使用 cvxprob/newcnstr (line 192)
Disciplined convex programming error:
Invalid constraint: {real affine} == {convex}
My code show as follow

cvx_begin
        variable qo(2,J) nonnegative;
        variable z(K,J) nonnegative;
        variable T_F(1,J+1) nonnegative;
        variable T_H(1,J) nonnegative;
        variable o(1,J) nonnegative;
        
        t_u = a .* D_n .* pow_p(z,-1);
        t_c = c .* D_n ./ f_kmj;
        expression e;
        e = sum(o) + T_F(J+1) ;
        minimize(e)
        subject to
            T_F(1,end) == norm(qo(:,1)-QS(:,n)) / V_Mean; 
            for j=1:J
                if j ~= J
                    T_F(1,j) == norm(qo(:,j+1)-qo(:,j)) / V_Mean;
                else
                    T_F(1,j) == norm(QE(:,n)-qo(:,j)) / V_Mean;
                end
            end
            o >= max(t_c +  t_u );
            T_H(1,:) >= max(t_u );
            
            for j=1:J
                o(j) >= T_H(1,j) + T_F(1,j);
            end

Next I tranform the euqality constrains to a assignment before “subject to”, where the code show as follow:

    cvx_begin
        variable qo(2,J) nonnegative;
        variable z(K,J) nonnegative;
        variable T_F(1,J+1) nonnegative;
        variable T_H(1,J) nonnegative;
        variable o(1,J) nonnegative;
        
        t_u = a .* D_n .* pow_p(z,-1);
        t_c = c .* D_n ./ f_kmj;
        expression e;
        e = sum(o) + T_F(J+1) ;
        minimize(e)
        T_F(1,end) = norm(qo(:,1)-QS(:,n)) / V_Mean; 
        for j=1:J
            if j ~= J
                T_F(1,j) = norm(qo(:,j+1)-qo(:,j)) / V_Mean;
            else
                T_F(1,j) = norm(QE(:,n)-qo(:,j)) / V_Mean;
            end
        end
        
        subject to
            T_F(1,end) = norm(qo(:,1)-QS(:,n)) / V_Mean; 
            for j=1:J
                if j ~= J
                    T_F(1,j) = norm(qo(:,j+1)-qo(:,j)) / V_Mean;
                else
                    T_F(1,j) = norm(QE(:,n)-qo(:,j)) / V_Mean;
                end
            end
            
            0<=qo<=M;
            
            o >= max(t_c +  t_u );
            T_H(1,:) >= max(t_u );
            
            for j=1:J
                o(j) >= T_H(1,j) + T_F(1,j);
            end

I got this error "
错误使用 cvx_end (line 70)
The following cvx variable(s) have been cleared or overwritten:
T_F
This is often an indication that an equality constraint was
written with one equals ‘=’ instead of two ‘==’. The model
must be rewritten before cvx can proceed."

How can I correct the error?

Nonlinear equality constraints are non-convex.

Thank you, I will change my model.

Hello, How do I turn my nonlinear constraint into a linear constraint, could you gice me some advises and I would appreciate it very much.

My advice is don’t. Either relax it to a convex inequality,. which may or may not suit your needs, or use a non-convex solver, for instance under YALMIP.