


Constructs the mining capacity constraints matrix
--------------------------------------------------------------------------
Updated May 27, 2009
Date: Aug 13, 2008, ver01
By: Hooman Askari
--------------------------------------------------------------------------
Inputs
--------------------------------------------------------------------------
Blocks:
a struct containing Blocks(numBlocks) elements with the field
correspoiding to the input file format.
numBlocks:
a 1*1 vector containing the total number of blocks
numOfPeriods:
a 1*1 vector containing the number of periods
numOfElements:
a 1*1 vector containing the number of Elements
varargin: variable number of input arguments
holding the min and max of mining capacity
in this case: mcMin and mcMax
a 1*1 vector containing the min and max capacity of mining
--------------------------------------------------------------------------
outputs
A_mining = mining capacity constraints
A_mining = [zeros(m, numCuts * numOfPeriods )...
zeros(m, numBlocks * numOfPeriods )...
A_mining ];
b_Umc
--------------------------------------------------------------------------
--------------------------------------------------------------------------
Pseudo Code
--------------------------------------------------------------------------

0001 % Constructs the mining capacity constraints matrix 0002 %-------------------------------------------------------------------------- 0003 % Updated May 27, 2009 0004 % Date: Aug 13, 2008, ver01 0005 % By: Hooman Askari 0006 %-------------------------------------------------------------------------- 0007 %Inputs 0008 %-------------------------------------------------------------------------- 0009 % Blocks: 0010 % a struct containing Blocks(numBlocks) elements with the field 0011 % correspoiding to the input file format. 0012 % numBlocks: 0013 % a 1*1 vector containing the total number of blocks 0014 % numOfPeriods: 0015 % a 1*1 vector containing the number of periods 0016 % numOfElements: 0017 % a 1*1 vector containing the number of Elements 0018 % varargin: variable number of input arguments 0019 % holding the min and max of mining capacity 0020 % in this case: mcMin and mcMax 0021 % a 1*1 vector containing the min and max capacity of mining 0022 % 0023 %-------------------------------------------------------------------------- 0024 % outputs 0025 % A_mining = mining capacity constraints 0026 % A_mining = [zeros(m, numCuts * numOfPeriods )... 0027 % zeros(m, numBlocks * numOfPeriods )... 0028 % A_mining ]; 0029 % b_Umc 0030 % 0031 %-------------------------------------------------------------------------- 0032 % 0033 %-------------------------------------------------------------------------- 0034 % Pseudo Code 0035 % 0036 %-------------------------------------------------------------------------- 0037 0038 function [A_mining b_Umc]= mining_capacity_constraints(Blocks,... 0039 miningCuts,... 0040 numBlocks,... 0041 numCuts,... 0042 numOfPeriods,... 0043 rockTypesMined,... 0044 varargin) 0045 0046 % elementsProcessed(1, number of elements processed) 0047 % this array contains the indices from numOfElements 0048 % example [1 3 4]: elements 1 3 and 4 are processed 0049 0050 0051 % unpacking varargin 0052 % unpacks the minimum and maximum processing capacity for each element 0053 % processed into two arrays 0054 % pcElementsMin (1, 1:numOfElementsProcessed) = element's 0055 % minimum processing capacity 0056 % pcElementsMax (1, 1:numOfElementsProcessed) = element's 0057 % maximum processing capacity 0058 % the matrix column index corrosponds to the element index 0059 % example: second element maximum is in elementsMax(1,2) 0060 iMin = 1; 0061 iMax = 1; 0062 for i =1:numOfPeriods 0063 for k = 1:length(varargin); 0064 % check to see if the index of varargin is odd 0065 % add the variable to the elementsMin 0066 % other wise add it to the elementsMax 0067 if rem(k,2)~= 0 0068 if isempty(varargin{1,k}) 0069 mcElementsMin(1,iMin) = NaN; 0070 else 0071 mcElementsMin(1,iMin) = varargin{1,k}(1,i); 0072 end 0073 iMin = iMin + 1; 0074 else 0075 if isempty(varargin{1,k}) 0076 mcElementsMax(1,iMax) = NaN; 0077 else 0078 mcElementsMax(1,iMax) = varargin{1,k}(1,i); 0079 end 0080 iMax = iMax + 1; 0081 end 0082 end 0083 end 0084 0085 % this is used in mining capacity 0086 blockTonnage = [Blocks.BlockTonnage]; 0087 0088 %----------------------------------------------------------------------- 0089 % NOTE: 0090 cutTonnage = zeros(1, numCuts); 0091 0092 % this for loop constructs the summation of the cut tonnages. 0093 for i = 1:numCuts 0094 temp = miningCuts{i}; 0095 cutTonnage(i) = sum(blockTonnage(temp)); 0096 end 0097 0098 %----------------------------------------------------------------------- 0099 % NOTE: I substitute cutTonnage with blockTonnage here because didn't 0100 % want to change the code from here on. From this point on in the 0101 % mining capacity constraints code where ever there is a refrence to 0102 % blockTonnage it is actually refering to the cutTonnage! 0103 %----------------------------------------------------------------------- 0104 %----------------------------------------------------------------------- 0105 blockTonnage = cutTonnage; 0106 %----------------------------------------------------------------------- 0107 %----------------------------------------------------------------------- 0108 0109 totalBlockTonnage = sum(blockTonnage) 0110 0111 miningCapacity = totalBlockTonnage / numOfPeriods 0112 0113 0114 % initialize the A_grade vector 0115 A_mining =[]; 0116 b_Umc =[]; 0117 0118 for i = 1: length(rockTypesMined) 0119 0120 %unequality constraints for elements number iElements minimum 0121 if ~isnan (mcElementsMin(rockTypesMined(i))) 0122 %minMCVector = blockTonnage.*-1; 0123 minMcVector = blockTonnage((rockTypesMined(i)),:).*-1; 0124 A_mining = update_constraints(A_mining,... 0125 numCuts,... 0126 numOfPeriods,... 0127 minMcVector); 0128 0129 %updateValue = mcMin*-1; 0130 updateValue = mcElementsMin(rockTypesMined(i))*-1; 0131 b_Umc = update_boundaries(b_Umc, numOfPeriods, updateValue); 0132 end 0133 0134 %unequality constraints for elements number iElements maximum 0135 if ~isnan (mcElementsMax(rockTypesMined(i))) 0136 0137 maxPcVector = blockTonnage((rockTypesMined(i)),:); 0138 A_mining = update_constraints(A_mining,... 0139 numCuts,... 0140 numOfPeriods,... 0141 maxPcVector); 0142 %updateValue = mcMax; 0143 updateValue = mcElementsMax(rockTypesMined(i)); 0144 b_Umc = update_boundaries(b_Umc, numOfPeriods, updateValue); 0145 end 0146 0147 end % i = 1: length(rockTypesMined) 0148 0149 A_mining = sparse(A_mining); 0150 b_Umc = sparse(b_Umc); 0151 0152 [m n] = size(A_mining); 0153 0154 % the mulitplier vector in the constraints matrix have different sizes 0155 % and units. (some are tonnage some are grade....). It is necessary to 0156 % transform the constraints matrix in a way that it unit less to be 0157 % solved by the MIP code. 0158 0159 % divide each row vector by its norm [A(i,:)* A(i,:)']^1/2 0160 % A_miningNormVector(m,1) is vertical vector holding the respective 0161 % norm of each row of the A_mining matrix 0162 0163 for i = 1:m 0164 A_miningNormVector(i,1) = norm(A_mining(i,:)); 0165 end 0166 0167 for i = 1:m 0168 0169 normA = A_miningNormVector(i,1); 0170 A_mining(i,:) = A_mining(i,:)/normA; 0171 0172 % normalizing the upper bound 0173 b_Umc(i)= b_Umc(i)/normA; 0174 end 0175 0176 0177 A_mining = [zeros(m, numCuts * numOfPeriods )... 0178 zeros(m, numBlocks * numOfPeriods )... 0179 A_mining ]; 0180 0181 end 0182