--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)
|
||||
% The auxiliary problem is always a minimization problem
|
||||
|
||||
% 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
|
||||
% and x_D (basic and nonbasic variables) and index_B and index_D (to keep
|
||||
% track of the variables indices)
|
||||
% 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
|
||||
% 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
|
||||
% the auxiliary problem (the objective function has to reach value 0)
|
||||
|
@ -40,7 +38,6 @@ while(z~=0)
|
|||
|
||||
% Find nonnegative index
|
||||
idxIN = find(r_D==min(r_D));
|
||||
|
||||
% Using Bland's rule to avoid cycling
|
||||
if(size(idxIN,2)>1)
|
||||
idxIN = min(idxIN);
|
||||
|
@ -85,21 +82,17 @@ while(z~=0)
|
|||
Bih = B\h;
|
||||
|
||||
% Compute reduced cost coefficients
|
||||
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
|
||||
r_D = c_Daux - c_Baux*BiD;
|
||||
|
||||
% Detect inefficient loop if nIter > total number of basic solutions
|
||||
nIter = nIter + 1;
|
||||
if nIter > itMax
|
||||
if(nIter>itMax)
|
||||
error('The original LP problem does not admit a feasible solution.');
|
||||
end
|
||||
|
||||
x_B = Bih - BiD*x_D;
|
||||
z = c_Baux*x_B;
|
||||
|
||||
end
|
||||
|
||||
check = index_D<(n+m+1);
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
type = 'max';
|
||||
A = [4 3; 4 1; 4 2; 1 0; 0 1];
|
||||
sign = [-1 ; -1 ; -1 ; 1 ; 1 ];
|
||||
h = [12 ; 8 ; 8 ; 0 ; 0 ];
|
||||
A = [4 3; 4 1; 4 2];
|
||||
sign = [-1 ; -1 ; -1 ];
|
||||
h = [12 ; 8 ; 8 ];
|
||||
c = [3 4];
|
||||
|
||||
|
||||
[z,x_B,index_B] = simplex (type,A,h,c,sign);
|
||||
histogram([index_B x_B']')
|
|
@ -34,7 +34,7 @@ while optCheck ~= tol
|
|||
ratio = Bih ./ BiD(:,idxIN);
|
||||
|
||||
% Find the smallest positive ratio
|
||||
idxOUT = find(ratio == min(ratio(ratio > 0)));
|
||||
idxOUT = find(ratio == min(ratio(ratio >= 0)));
|
||||
|
||||
out = B(:,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/}).
|
||||
|
||||
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
|
||||
solution''. This error message appears when the simplex method does not
|
||||
\texttt{simpleSolve} iterative method. The error message is
|
||||
``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
|
||||
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
|
||||
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
|
||||
equally not optimal ($z = 28$) according to the auxiliary problem definition,
|
||||
terminating the auxiliary algorithm abnormally after too many iterations.
|
||||
equally not optimal ($\text{optCheck} = 1$) according to the simplex algorithm definition,
|
||||
terminating the simplex algorithm algorithm abnormally after too many iterations.
|
||||
|
||||
\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
|
||||
|
@ -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
|
||||
$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]
|
||||
\centering
|
||||
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45]
|
||||
|
|
Reference in a new issue