I have three sets of constraints, but cvx 'fails' to solve simultaneously

The three constraints are able to solve the problem individually, but when I combine all three it fails to give a solution. could you please help me with this

cvx_begin quiet
variables T(K+1,n1) Tw(K+1,n1) Qdotc(K,n1) p2(K,n1) e(K+1,n2) ph(K,n2) pw(K,n2) pd(K,n2)
expressions p1(K,n1) % intermediate variables (these are just placeholders for text expressions)
p1 = Qdotc./eta1 + (1-1./eta1).pos(Qdotc - eta1.pMax1); % thermal → electric power map (note assignment (=) vs. equality (==) operator)
minimize( pid
max(P + sum(p1,2)+ sum(p2,2) + sum(ph - atHome.pd,2))… % home neighborhood peak
+ pid
max(0,max(pWorkBase + sum(pw - atWork.pd,2)) - max(pWorkBase))… % work neighborhood peak
+ pie
sum(P + sum(p1,2) + sum(p2,2) + sum(ph + pw,2))… % energy
+ pic
(sum(sum(abs(T-Tset))) - sum(sum(abs(Tbase2-Tset)))) …
+ pic*(sum(sum(abs(Tw-Tsetw))) - sum(sum(abs(Tbasew-Tsetw))))) % discomfort
% discomfort
subject to % constraints
%heat pump
T(1,:slight_smile: == Tset(1,:); % initial condition
T(K+1,:slight_smile: == Tset(K+1,:); % final condition: return to setpoint
T(2:K+1,:slight_smile: == repmat(a1,K,1).T(1:K,:)…
+ (1-repmat(a1,K,1)).
(repmat(theta,1,n1) + repmat(R,K,1).*(Qdotc + qe));
zeros(K,n1) <= Qdotc <= (eta1.*pMax1 + pMaxAux).*ones(K,n1) % heat pump electric power capacity limits
abs(T - Tset) <= dT

%heat pump water heater
% building temperature
Tw(1,:slight_smile: == Tsetw(1,:); % initial condition
Tw(K+1,:slight_smile: == Tsetw(K+1,:); % final condition: return to setpoint
Tw(2:K+1,:slight_smile: == repmat(aw,K,1).Tw(1:K,:)…
+ (1-repmat(aw,K,1)).
(repmat(thetaw,1,n1) + repmat(Rw,K,1).*(etaw.*p2 - ww));
abs(Tw - Tsetw) <= dT

% heat pump power
zeros(K,n1) <= p2 <= pMaxR

% EV energy
e(1,:slight_smile: == e0 % initial condition
e(K+1,:slight_smile: == e(1,:slight_smile: % terminal condition: return to initial charge
e(2:K+1,:slight_smile: == repmat(a2,K,1).e(1:K,:)…
+ (1-repmat(a2,K,1)).repmat(tau,K,1).
(repmat(etac,K,1).
(ph + pw) - pd./repmat(etad,K,1))
repmat(eMin,K+1,1) <= e <= repmat(eMax,K+1,1)

% EV power
zeros(K,n2) <= ph <= repmat(pcMax,K,1)
zeros(K,n2) <= pw <= repmat(pcMax,K,1)
zeros(K,n2) <= pd <= repmat(pdMax,K,1)
for i=1:n2
    pd(mod(t,24)==tw(i),i) == etad(i)*ec(i)/dt % commute to work
    pd(mod(t,24)==th(i),i) == etad(i)*ec(i)/dt % commute to home
end
ph(~atHome) == 0 % at-home charging
pw(~atWork) == 0 % at-work charging

cvx_end

Don’t use quiet until everything is working well. Then you will see the solver and CVX output.

You haven’t told us what specifically happens when the problem ‘fails’ to solve. Perhaps the problem is reported by CVX as infeasible? That would mean there is no value of the optimization (decision) variables which simultaneously satisfies all the constraints. If so, follow the advice in Debugging infeasible models - YALMIP ,all but section 1 of which also applies to CVX.

There is no reason to choose the MIDCP categorization if there are no binary or integer optimization variables.

thank you for your response and suggestions:
by fail I meant this;

Calling Gurobi 9.00: 771044 variables, 515041 equality constraints

Gurobi Optimizer, licensed to CVX for CVX
Academic license - for non-commercial use only
Gurobi Optimizer version 9.0.0 build v9.0.0rc2 (mac64)
Optimize a model with 515041 rows, 771044 columns and 1422883 nonzeros
Model fingerprint: 0x1e25e33f
Model has 96800 quadratic constraints
Coefficient statistics:
Matrix range [7e-02, 1e+01]
QMatrix range [1e+00, 1e+00]
Objective range [1e-02, 5e+01]
Bounds range [0e+00, 0e+00]
RHS range [9e-03, 7e+02]
Presolve removed 335600 rows and 381841 columns
Presolve time: 0.11s

Barrier solved model in 0 iterations and 0.11 seconds
Model is infeasible or unbounded

User-callback calls 18, time in user-callback 0.00 sec

Status: Failed
Optimal value (cvx_optval): NaN

CVX exit status: Failed.

If the problem solved to optimality with a subset of the constraitns, but is unbounded or infeasible with all constraints, it would appear the problem is infeasible. Hence, follow the advice in the link (except section 1, which doers not apply to CVX).