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
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
Mez
Mez 2017 年 11 月 13 日
編集済み: Mez 2017 年 11 月 13 日
Dear Alan, First of all, thanks for the new command 'optimconstr'. I implemented the command and the code improved now that way that all constraints are now correctly called. (As I can see with the command 'showproblem'). Regarding the output: I have updated the code above (it is the whole code as I run it in my Matlab. Output:
LP: Optimal objective value is 5.332383.
Cut Generation: Applied 3 Gomory cuts,
and 5 strong CG cuts.
Lower bound is 5.332383.
No feasible solution found.
Intlinprog stopped because no integer points satisfy the constraints.
Unfortunately, the problem is still not running properly. Maybe you have another command or recommendation?

サインインしてコメントする。

採用された回答

Mez
Mez 2017 年 11 月 14 日
Hi, thanks for your support.
Since the input variables were to small and randomly distributed with decimal points the solver was not able to find integer solutions. With slightly bigger numbers it is working now. :)

その他の回答 (2 件)

Aurele Turnes
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?
  1 件のコメント
Mez
Mez 2017 年 11 月 13 日
Thanks Aurele, I have updated the code above with your input (it is the whole code as I use it in my Matlab). Unfortunately, the problem is still not running properly. The constraints and the variable bounds seem okay, but the problem cannot find any integer solution. Maybe you have another command or recommendation which I can try? Thanks!

サインインしてコメントする。


Alan Weiss
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

カテゴリ

Help Center および File ExchangeGet 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!

Translated by