Linear Optimization wih R2017b: Are the constraints correctly defined? (each constraint has multiple entries) - current result is that the Intlinprog stopped
2 次查看(过去 30 天)
显示 更早的评论
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);
end
end
%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);
2 个评论
Alan Weiss
2017-11-13
I don't see any initialization statements for the constraints in your loops. I am not sure that it matters, but I think it would be better practice to use statements such as
constr04 = optimconstr(NA,1);
constr03 = optimconstr(NA,NB);
More importantly, I do not see an error statement or full report of the output that solve returns. Could you please provide the exit flag and output structure and any error or warning messages?
Alan Weiss
MATLAB mathematical toolbox documentation
采纳的回答
更多回答(2 个)
Aurele Turnes
2017-11-13
I am not sure what problem you are trying to solve based on the drawing, but have you tried using "showproblem" on linsol to check the constraints visually?
Alan Weiss
2017-11-14
Based on what you have said, I strongly suspect that there are no integer feasible points for your problem. If you know of an integer feasible point, then I suggest that you see whether this point satisfies the constraints as you have formulated them by using the infeasibility function. This will help you identify an incorrectly formulated constraint.
You could also try to find an integer feasible point by setting your objective function to []. But as I already said, I am reasonably sure that there is none.
Alan Weiss
MATLAB mathematical toolbox documentation
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Problem-Based Optimization and Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!