필터 지우기
필터 지우기

How to run please this example perfectly to get optimal solution .. Thank you

조회 수: 1 (최근 30일)
f = [0 ; - 10 ; 0 ; - 6; - 20] ;
A = [1 0 0 0 0 ;
0 1 0 0 0 ;
0 0 1 0 0 ;
0 0 0 1 0 ;
0 0 0 0 1] ;
B = [4 ; 3 ; 3 ; 2 ; 2] ;
Aeq = [1 - 1 - 1 0 0 ; 0 0 1 - 1 - 1] ;
beq = [0; 0; 0; 0; 0];
lb = zeros (5, 1) ;
ub = zeros (5, 1) ;
x = linprog(f,A,B,Aeq,beq,lb,ub)
[x,fval] = linprog(f,A,Aeq,beq,lb,ub);

채택된 답변

Steven Lord
Steven Lord 2023년 5월 4일
lb = zeros (5, 1) ;
ub = zeros (5, 1) ;
So based on the way you've constructed the bounds, all the elements of your solution have to be greater than or equal to 0 and less than or equal to 0. The only possible solution that satisfies both sets of bounds is zeros(5, 1).
Are you sure that ub shouldn't be something like ones(5, 1)?
  댓글 수: 7
Steven Lord
Steven Lord 2023년 5월 4일
Yes, I saw that. I would have expected them also to appear in the "Therefore, the problem can be posed as the following linear program:" section as inequalities like the last three bound constraints. But due to a lack of space on the page I wonder if students solving the problem could overlook the last two equations (which I assumed appeared after the diagram on page 262.)
Dalia ElNakib
Dalia ElNakib 2023년 5월 6일
Many Thanks for your clarifications.
Really appreciate your efforts.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Torsten
Torsten 2023년 5월 4일
f = [0 ; -10 ; 0 ; -6; -20] ;
A = [1 0 0 0 0 ;
0 1 0 0 0 ;
0 0 1 0 0 ;
0 0 0 1 0 ;
0 0 0 0 1] ;
B = [4 ; 3 ; 3 ; 2 ; 2] ;
Aeq = [1 -1 -1 0 0 ; 0 0 1 -1 -1] ;
beq = [0; 0];
lb = zeros (5, 1) ;
ub = zeros (5, 1) ;
[x,fval] = linprog(f,A,B,Aeq,beq,lb,ub)
Optimal solution found.
x = 5×1
0 0 0 0 0
fval = 0
  댓글 수: 2
Dalia ElNakib
Dalia ElNakib 2023년 5월 4일
f = [0 ; -10 ; 0 ; -6; -20] ;
A = [1 0 0 0 0 ;
0 1 0 0 0 ;
0 0 1 0 0 ;
0 0 0 1 0 ;
0 0 0 0 1] ;
B = [4 ; 3 ; 3 ; 2 ; 2] ;
Aeq = [1 -1 -1 0 0 ; 0 0 1 -1 -1] ;
beq = [0; 0];
lb = zeros (5, 1) ;
ub = ones(5, 1);
[x,fval] = linprog(f,A,B,Aeq,beq,lb,ub);
Optimal solution found.
Dalia ElNakib
Dalia ElNakib 2023년 5월 4일
편집: Dalia ElNakib 2023년 5월 4일
Thank you so much
Both work to ge the optimal solution
Either:
lb = zeros (5, 1) ;
ub = zeros (5, 1) ;
Or
lb = zeros (5, 1) ;
ub = ones (5, 1) ;
f = [0 ; -10 ; 0 ; -6; -20] ;
A = [1 0 0 0 0 ;
0 1 0 0 0 ;
0 0 1 0 0 ;
0 0 0 1 0 ;
0 0 0 0 1] ;
B = [4 ; 3 ; 3 ; 2 ; 2] ;
Aeq = [1 -1 -1 0 0 ; 0 0 1 -1 -1] ;
beq = [0; 0];
lb = zeros (5, 1) ;
ub = zeros(5, 1);
[x,fval] = linprog(f,A,B,Aeq,beq,lb,ub);
Optimal solution found.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by