fines_dyke_blending_constraint1

PURPOSE ^

Constructs the blending constraint for dyke fines

SYNOPSIS ^

function [A_finesDykegrade b_finesDykeUgrade] = fines_dyke_blending_constraint1(Blocks120, numOfPeriods,MaxfinesDyke, MinfinesDyke)

DESCRIPTION ^

 Constructs the blending constraint for dyke fines 
--------------------------------------------------------------------------
 Date: July 30, 2010, ver01
 By: Eugene Ben-Awuah
--------------------------------------------------------------------------

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % Constructs the blending constraint for dyke fines
0002 %--------------------------------------------------------------------------
0003 % Date: July 30, 2010, ver01
0004 % By: Eugene Ben-Awuah
0005 %--------------------------------------------------------------------------
0006 
0007 function [A_finesDykegrade b_finesDykeUgrade] = fines_dyke_blending_constraint1...
0008                                                 (Blocks120, numOfPeriods,... 
0009                                                 MaxfinesDyke, MinfinesDyke)
0010 
0011 
0012 [numBlocks n] = size([Blocks120.EBV]');
0013 
0014 %vectors containing the relevant element and tonnage
0015 finesDykeGrade1 = [Blocks120.finesGradeDyke];
0016 DykeTonnage = [Blocks120.blockFinesDyke]/100;
0017 
0018 %initialize the finesDykeGrade vector by pre-allocating memory to increase speed
0019 finesDykeGrade2=zeros(1,numBlocks);
0020 finesDykeGrade3=zeros(1,numBlocks);
0021 
0022 %calculate the maximum and minimum grade constraint vectors based on the formula (refer Yashar's formulation:
0023 %finesDykeGradeMax=((finesDykeGrade1(1,iBlocks)-MaxfinesDyke)*DykeTonnage(1,iBlocks))
0024 %finesDykeGradeMin=((MinfinesDyke-finesDykeGrade1(1,iBlocks))*DykeTonnage(1,iBlocks))
0025 for iBlocks=1:numBlocks
0026     finesDykeGrade2(1,iBlocks)=((finesDykeGrade1(1,iBlocks)-MaxfinesDyke).*DykeTonnage(1,iBlocks));  
0027     finesDykeGrade3(1,iBlocks)=((MinfinesDyke-finesDykeGrade1(1,iBlocks)).*DykeTonnage(1,iBlocks));
0028 end
0029 %The 0.01 added to the minimum fines constraint eqn is to ensure that we
0030 %dont have a zero matrix. May not be needed if data is available for fines
0031 %at all locations. Does not affect NPV because decsion for dyke tonnage has
0032 %already been made.
0033 
0034 %pre-allocate memory and create maximum and minimum grade constraint matrix
0035 finesDykeGradeMax = zeros(numOfPeriods,numBlocks*numOfPeriods);
0036 finesDykeGradeMin = zeros(numOfPeriods,numBlocks*numOfPeriods);
0037 for iPeriods = 1:numOfPeriods
0038     finesDykeGradeMax(iPeriods,((numBlocks*(iPeriods-1)+1):iPeriods*numBlocks))...
0039     = finesDykeGrade2(1,:);
0040 
0041     finesDykeGradeMin(iPeriods,((numBlocks*(iPeriods-1)+1):iPeriods*numBlocks))...
0042     = finesDykeGrade3(1,:);
0043 end
0044 
0045 %create maximum and minimum grade constraint matrix with size (T, N*T) for
0046 %each block-period decision variable and size (T,T) period decision variable
0047 %totalling (T, T*Variables)
0048 [m,n] = size(finesDykeGradeMax);
0049 A_finesDykegradeMax = [zeros(m, numBlocks*numOfPeriods)...
0050                       zeros(m, numBlocks*numOfPeriods), finesDykeGradeMax...
0051                       zeros(m, numBlocks*numOfPeriods)...
0052                       zeros(m,m), zeros(m,m), zeros(m,m), zeros(m,m)];
0053          
0054 A_finesDykegradeMin = [zeros(m, numBlocks*numOfPeriods)...
0055                       zeros(m, numBlocks*numOfPeriods), finesDykeGradeMin...
0056                       zeros(m, numBlocks*numOfPeriods)...
0057                       zeros(m,m), zeros(m,m), zeros(m,m), zeros(m,m)];         
0058 
0059 A_finesDykegrade = [A_finesDykegradeMax; A_finesDykegradeMin];
0060 
0061 %create the target for the grade constraint matrix which is a (2T,1) matrix
0062 [m,n] = size(A_finesDykegrade);
0063 b_finesDykeUgrade = zeros(m,1);
0064 
0065 %convert to a sparse matrix
0066 A_finesDykegrade = sparse(A_finesDykegrade);
0067 b_finesDykeUgrade = sparse(b_finesDykeUgrade);
0068 
0069 % the mulitplier vector in the constraint matrix have different sizes
0070 % and units. (some are tonnage some are grade....). It is necessary to
0071 % transform the constraints matrix in a way that it unit less to be
0072 % solved by the MIP code.
0073 
0074 % divide each row vector by its norm [A(i,:)* A(i,:)']^1/2
0075 % A_miningNormVector(m,1) is vertical vector holding the respective
0076 % norm of each row of the A_mining matrix
0077 
0078 %b_Ugrade is all zero so doesn't need normalizing in cases where b_U
0079 %and b_L have values greater than zero they need to be normailized as
0080 %well.
0081 
0082 for i = 1:m %NB: This should be for i=1:m; the vector to be used to calculate
0083     %the norm should be the A_finesDykegrade but because the minimum side
0084     %is all zeros, finding the norm gives zero, hence normalizing with this
0085     %value results in NaN errors. This may be as a result of the model.
0086     %Correct this when actual oil sand model is used to be consistent with
0087     %the other normalization calculations.This has been fixed for now by adding
0088     % 0.01 to all the fines grade for the minimum fines constraint to avoid
0089     % zeros. Does not affect NPV since the decision for dyke material has
0090     %already been made.
0091     A_gradeNormVector(i,1) = norm(A_finesDykegrade(i,:));     
0092 end
0093     
0094 for i = 1:m   
0095 normA = A_gradeNormVector(i,1); 
0096 A_finesDykegrade(i,:) = A_finesDykegrade(i,:)/normA;
0097 end
0098 
0099 A_finesDykegrade;
0100 
0101 end

Generated on Fri 30-Jul-2010 16:56:05 by m2html © 2003