표준 선형계획 문제(Standard LP Definition)
표준 선형계획 문제는 다음과 같이 세 가지 구성요소가 있습니다. 설계변수(Design Variables), 목적함수(Cost Function), 제약조건(Constraints) 이 그 구성요소 입니다. 아래 예제를 통해 표준 선형계획 문제로 변환하는 방법을 소개합니다.
1. 설계변수
- 시스템을 나타내는 변수의 집합
- 변수의 수치값이 정해지면 설계 결정
2. 설계 제약조건
- 자원의 한계, 재료강도, 시스템 응답, 치수 등
- 만족하면 유용시스템(Feasible System)
3. 목적함수
- 어떤 설계가 더 좋은지 판단 기준
- 원가의 최소화, 경량화
clear;
Noofvariables=2;
C=[400
600];
Info=[1
1;1/28 1/14;1/14 1/24];
b=[16;1;1];
s=eye(size(Info,1));
A=[Info s
b];
Cost=zeros(1,size(A,2));
Cost(1:Noofvariables)=C;
BV=Noofvariables+1:1:size(A,2)-1;
ZjCj=Cost(BV)*A-Cost;
ZCj=[ZjCj;A];
SimTable=array2table(ZCj)
RUN=true;
iter=0;
while RUN
iter=iter+1;
if any(ZjCj<0)
fprintf('
The current BFS is Not optimal \n');
fprintf('\n--------------
The next iteration results --------------\n');
disp('OLD
basic variable (BV) = ');
disp(BV);
ZC=ZjCj(1:end-1);
[EnterCol, pvt_col]=min(ZC);
fprintf('The
Most positive Element in %d corresponding to column %d \n'...
,EnterCol,pvt_col);
fprintf('Entering
variable is %d \n',pvt_col);
if all(A(:,pvt_col)<=0)
error('LPP
is unbounded. all enteries <=0 in
column %d',pvt_col);
else
sol=A(:,end);
Column=A(:,pvt_col);
for i=1:size(Column,1)
if Column(i)>0
ratio(i)=sol(i)./Column(i);
else
ratio(i)=inf;
end
end
[MinRatio, pvt_row]=min(ratio);
fprintf('Minimum
ratio corresponding to PIVOT row is %d \n',pvt_row);
fprintf('Leving
varaible is %d \n',BV(pvt_row));
end
BV(pvt_row)=pvt_col;
disp('New
basic varaibles (BV) =');
disp(BV);
pvt_key=A(pvt_row, pvt_col);
A(pvt_row,:)=A(pvt_row,:)./pvt_key;
for i=1:size(A,1)
if i~=pvt_row
A(i,:)=A(i,:)-A(i,pvt_col).*A(pvt_row,:);
end
end
ZjCj=ZjCj-ZjCj(pvt_col).*A(pvt_row,:);
ZCj=[ZjCj;A];
TABLE=array2table(ZCj)
BFS=zeros(1,size(A,2));
BFS(BV)=A(:,end);
BFS(end)=sum(BFS.*Cost);
Current_BFS=array2table(BFS)
else
RUN=false;
fprintf('
---------------------------\n');
fprintf('
The Current BFS is optimal \n');
fprintf('
---------------------------\n');
end
end
실행 결과


댓글 없음
댓글 쓰기