--amend
This commit is contained in:
parent
e5b5431e06
commit
bf949c82e6
5 changed files with 27 additions and 26 deletions
|
@ -1,10 +1,8 @@
|
||||||
function [B,D,c_B,c_D,x_B,x_D,index_B,index_D] = auxiliary (A_aug,c_aug,h,m,n)
|
function [B,D,c_B,c_D,x_B,x_D,index_B,index_D] = auxiliary (A_aug,c_aug,h,m,n)
|
||||||
% The auxiliary problem is always a minimization problem
|
% The auxiliary problem is always a minimization problem
|
||||||
|
|
||||||
% The output will be: B and D (basic and nonbasic matrices), c_B and c_D
|
% The output will be: B and D (basic and nonbasic matrices), c_B and c_D (subdivision of the coefficient vector in basic and nonbasic parts), x_B
|
||||||
% (subdivision of the coefficient vector in basic and nonbasic parts), x_B
|
% and x_D (basic and nonbasic variables) and index_B and index_D (to keep track of the variables indices)
|
||||||
% and x_D (basic and nonbasic variables) and index_B and index_D (to keep
|
|
||||||
% track of the variables indices)
|
|
||||||
|
|
||||||
% Redefine the problem by introducing the artificial variables required by
|
% Redefine the problem by introducing the artificial variables required by
|
||||||
% the auxiliary problem (the objective function has to reach value 0)
|
% the auxiliary problem (the objective function has to reach value 0)
|
||||||
|
@ -40,7 +38,6 @@ while(z~=0)
|
||||||
|
|
||||||
% Find nonnegative index
|
% Find nonnegative index
|
||||||
idxIN = find(r_D==min(r_D));
|
idxIN = find(r_D==min(r_D));
|
||||||
|
|
||||||
% Using Bland's rule to avoid cycling
|
% Using Bland's rule to avoid cycling
|
||||||
if(size(idxIN,2)>1)
|
if(size(idxIN,2)>1)
|
||||||
idxIN = min(idxIN);
|
idxIN = min(idxIN);
|
||||||
|
@ -85,21 +82,17 @@ while(z~=0)
|
||||||
Bih = B\h;
|
Bih = B\h;
|
||||||
|
|
||||||
% Compute reduced cost coefficients
|
% Compute reduced cost coefficients
|
||||||
r_D = c_Daux - (c_Baux * BiD);
|
r_D = c_Daux - c_Baux*BiD;
|
||||||
|
|
||||||
% Exercise 4: Uncomment this to experience "oscillation"
|
|
||||||
%fprintf("iteration %d: in %d out %d z %d\n", nIter+1, idxIN, idxOUT, z);
|
|
||||||
%B
|
|
||||||
%D
|
|
||||||
|
|
||||||
% Detect inefficient loop if nIter > total number of basic solutions
|
% Detect inefficient loop if nIter > total number of basic solutions
|
||||||
nIter = nIter + 1;
|
nIter = nIter + 1;
|
||||||
if nIter > itMax
|
if(nIter>itMax)
|
||||||
error('The original LP problem does not admit a feasible solution.');
|
error('The original LP problem does not admit a feasible solution.');
|
||||||
end
|
end
|
||||||
|
|
||||||
x_B = Bih - BiD*x_D;
|
x_B = Bih - BiD*x_D;
|
||||||
z = c_Baux*x_B;
|
z = c_Baux*x_B;
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
check = index_D<(n+m+1);
|
check = index_D<(n+m+1);
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
type = 'max';
|
type = 'max';
|
||||||
A = [4 3; 4 1; 4 2; 1 0; 0 1];
|
A = [4 3; 4 1; 4 2];
|
||||||
sign = [-1 ; -1 ; -1 ; 1 ; 1 ];
|
sign = [-1 ; -1 ; -1 ];
|
||||||
h = [12 ; 8 ; 8 ; 0 ; 0 ];
|
h = [12 ; 8 ; 8 ];
|
||||||
c = [3 4];
|
c = [3 4];
|
||||||
|
|
||||||
|
|
||||||
[z,x_B,index_B] = simplex (type,A,h,c,sign);
|
[z,x_B,index_B] = simplex (type,A,h,c,sign);
|
||||||
histogram([index_B x_B']')
|
histogram([index_B x_B']')
|
|
@ -34,7 +34,7 @@ while optCheck ~= tol
|
||||||
ratio = Bih ./ BiD(:,idxIN);
|
ratio = Bih ./ BiD(:,idxIN);
|
||||||
|
|
||||||
% Find the smallest positive ratio
|
% Find the smallest positive ratio
|
||||||
idxOUT = find(ratio == min(ratio(ratio > 0)));
|
idxOUT = find(ratio == min(ratio(ratio >= 0)));
|
||||||
|
|
||||||
out = B(:,idxOUT);
|
out = B(:,idxOUT);
|
||||||
c_out = c_B(1,idxOUT);
|
c_out = c_B(1,idxOUT);
|
||||||
|
|
Binary file not shown.
|
@ -361,16 +361,17 @@ The MATLAB implementation for this problem can be found under file
|
||||||
\texttt{Project\_6\_Claudio\_Maggioni/}).
|
\texttt{Project\_6\_Claudio\_Maggioni/}).
|
||||||
|
|
||||||
The simplex method implementation for this problem fails with an error in the
|
The simplex method implementation for this problem fails with an error in the
|
||||||
auxiliary problem initialization. The error message is ``The original LP problem does not admit a feasible
|
\texttt{simpleSolve} iterative method. The error message is
|
||||||
solution''. This error message appears when the simplex method does not
|
``Incorrect loop, more iterations than the number of basic solutions''.
|
||||||
|
This error message appears when the simplex method does not
|
||||||
converge in the expected maximum number of iterations. The large number of
|
converge in the expected maximum number of iterations. The large number of
|
||||||
iterations (793 before forced termination) is caused by an ``oscillation'' or
|
iterations (11 before forced termination) is caused by an ``oscillation'' or
|
||||||
vicious cycle of swap operations between matrix $B$ and matrix $D$. This
|
vicious cycle of swap operations between matrix $B$ and matrix $D$. This
|
||||||
oscillation is cause by the fact that entering and departing variable indexes do
|
oscillation is cause by the fact that entering and departing variable indexes do
|
||||||
not change, and stay fixed at values 6 and 4 from the second iteration onwards.
|
not change, and stay fixed at values 1 and 3 from the second iteration onwards.
|
||||||
This causes an unnecessary continuous oscillation between two solutions that are
|
This causes an unnecessary continuous oscillation between two solutions that are
|
||||||
equally not optimal ($z = 28$) according to the auxiliary problem definition,
|
equally not optimal ($\text{optCheck} = 1$) according to the simplex algorithm definition,
|
||||||
terminating the auxiliary algorithm abnormally after too many iterations.
|
terminating the simplex algorithm algorithm abnormally after too many iterations.
|
||||||
|
|
||||||
\subsection{Look at the number of constraints and at the number of unknowns:
|
\subsection{Look at the number of constraints and at the number of unknowns:
|
||||||
what can you notice about the underlying system of equations? Represent them
|
what can you notice about the underlying system of equations? Represent them
|
||||||
|
@ -385,6 +386,14 @@ triangular shape, and it is made up only of one constraint other than the
|
||||||
trivial positivity constraints at the axes (i.e. the constraints different from
|
trivial positivity constraints at the axes (i.e. the constraints different from
|
||||||
$4x +2y \leq 8$ do not make a difference in the feasability region).
|
$4x +2y \leq 8$ do not make a difference in the feasability region).
|
||||||
|
|
||||||
|
The system has 2 variables and 3 constraints, other than the positivity checks
|
||||||
|
on the variables. But, for what said above, 2 out of the three constraints are
|
||||||
|
useless and thus make the feasibility region defined like a 1-condition problem.
|
||||||
|
|
||||||
|
This lack of ``useful'' condition may cause a ill-defined set of constraints
|
||||||
|
that could produce two equally ``good'' not-optimal solutions, thus causing the
|
||||||
|
infinite loop in the simplex algorithm.
|
||||||
|
|
||||||
\begin{figure}[h]
|
\begin{figure}[h]
|
||||||
\centering
|
\centering
|
||||||
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45]
|
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45]
|
||||||
|
|
Reference in a new issue