OBJ = OBJ + a*max(u);
for k = 1:N
OBJ = OBJ + u(:,k);
end
for k = 1:N
OBJ = OBJ + b*(elow(:,k) + eup(:,k));
endOBJ = a*max(u)+ sum(u) + b*(sum(elow) + sum(eup));
OBJ = OBJ + a*max(u);
for k = 1:N
OBJ = OBJ + u(:,k);
end
for k = 1:N
OBJ = OBJ + b*(elow(:,k) + eup(:,k));
end...OBJ = a*max(u)+ sum(u) + b*(sum(elow) + sum(eup));controller = optimizer(CON, OBJ, sdpsettings('verbose',1), [x0 d], u0);I looked up your wiki but it seems that it doesn't have an example that does the following:
[x0 d]
Thanks Johan!
OBJ = OBJ + a*max(u(:,k));
OBJ = a*max(u)+ sum(u) + b*(sum(elow) + sum(eup));(1-n(k))*Tlb_un + n(k)*Tlb - elow(:,k) <= x(5,k+1) <= (1-n(k))*Tub_un + n(k)*Tub + eup(:,k)
CON = CON + ( Tmin(k)- elow(:,k) <= x(5,k+1) <= Tmax(k)+ eup(:,k) );
Tmax_IC = [23 23 23 23 23 23 23 23 22 22 22 22 22 22 22 22 22 22 23 23 23 23 23 23]; % Temperature upper bound degreeC
Tmin_IC = [19 19 19 19 19 19 19 19 20 20 20 20 20 20 20 20 20 20 19 19 19 19 19 19]; % Temperature lower bound degree
n = binvar(1,N); %occupancy signal, 1 for occupied, 0 for unoccupied
Tlb_un = 19; %low bound temperature when unoccupied, degreeC
Tlb = 20; %low bound temperature when occupied, degreeC
Tub_un = 23; %upper bound temperature when unoccupied, degreeC
Tub = 22; %upper bound temperature when occupied, degreeC
CON = CON + ( (1-n(k))*Tlb_un + n(k)*Tlb - elow(:,k) <= x(5,k+1) <= (1-n(k))*Tub_un + n(k)*Tub + eup(:,k) );
n_IC = [0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0];
>> struct(controller).model.solver.callhandle
ans =
@call_cplexibm_qcmiqpn_flow = binvar(1,N); %signal for input(air flow rate), if n_flow=0 then input=0;
umax = 100; %max input
CON = CON + ( 0 <= u(:,k) <= (1-n_flow(k))*0 + n_flow(k)*umax ); % when n_flow=0, u=0; n_flow=1, 0<=u<=100;
%CON = CON + (0 <= u(:,k) <= 100); % 0 <= u <= 100 always (The one I used before)
controller = optimizer(CON, OBJ, sdpsettings('verbose',1,'solver','gurobi'), {x0 d n}, u0);
Error using optimizer (line 194)
Failed exporting the model: Solver not found (+gurobi)In an assignment A(I) = B, the number of elements in B and I must be the same.Error in optimizer/subsref (line 105)
x(keptvariables) = output.Primal;Error in MPCnewer (line 89)
[u_IC,errorcode] = controller{{x_IC d_IC n_IC}}; %get the new control signalsolvesdp([CON,x_IC==x0, d_IC==d, n_IC==n], OBJ, sdpsettings('verbose',1,'solver','ipopt'));
u_IC = double(u0);
solvesdp([CON,x_IC==x0, d_IC==d, n_IC==n])
Exiting due to infeasibility: 96 lower bounds exceed the corresponding upper bounds.