Unfortunately, solving the problem does not work properly. I am not an expert in Matlab but I assume that I have an issue with the defined constraints. I am concerned if they are defined correctly, since each constraint again should have multiple entries (for each i={1:NA} and each j={1:NB}. I would be more than happy if you could help me with this problem. The mathematical formulation of the constraints should be complete (Constraints C01, … , C04 are the main constraints and the model should already work with only these four).
Attached you will also find the whole code:
NA = 4;NB = 2;E_Pv = 4.0 + rand(NA,NB);E_L = 5.0 + rand(NA,NB);E_Nom = 7.5 * ones(1,NB);MIN_SOC = 0.3;% Decision Variables
x1 = optimvar('x1',NA,NB,'Type','integer','LowerBound',0,'UpperBound',Inf);x2 = optimvar('x2',NA,NB,'Type','integer','LowerBound',0,'UpperBound',Inf);x3 = optimvar('x3',NA,NB,'Type','integer','LowerBound',-Inf,'UpperBound',Inf);% Objective function
linprob = optimproblem('Objective', sum( -x8(:) ));%%Problem Constraints
constr01 = optimconstr(NA,NB);constr02 = optimconstr(NA,NB);constr03 = optimconstr(NA,NB);constr04 = optimconstr(NA,1);for i = 1:NA constr04(i,1) = x8(i) == sum( x6(i,:) + x3(i,:) - x9(i,:) ); for j = 1:NB constr01(i,j) = E_Pv(i,j) == x5(i,j) + x4(i,j) + x6(i,j) + x7(i,j); constr02(i,j) = E_L(i,j) == x5(i,j) + x2(i,j) + x9(i,j); endend%Call constraints
linprob.Constraints.C01 = constr01;linprob.Constraints.C02 = constr02;linprob.Constraints.C03 = constr03;linprob.Constraints.C04 = constr04;% Call solver
linsol = solve(linprob);tbl = struct2table(linsol);showproblem(linprob);
Best Answer