


Solve the MILP problem with mining cuts and blocks modeled
--------------------------------------------------------------------------
Date: June 27, 2009, ver01
By: Hooman Askari
--------------------------------------------------------------------------
Inputs
--------------------------------------------------------------------------
loads the inputToMILPCutsBlocks.mat file generated by the adjacency
matrix program and clustering program.
--------------------------------------------------------------------------
outputs
save the solution in Solution.mat file
save the problem in the problem.mat file
--------------------------------------------------------------------------
Pseudo Code
--------------------------------------------------------------------------
set up the Objective function of mixed integer programming model
min f(x)= C^T.X
subject to
b_L <= A.X <= b_U
where:
C: tarnspose of coefficients in linear objective function
size-> C(numBlocks * numOfPeriods, 1)
X: vector containing mixed integer solution
A: matrix defining linear constraints
b_U: lower and upper bounds on the linear inequalities
b_L:

0001 % Solve the MILP problem with mining cuts and blocks modeled 0002 %-------------------------------------------------------------------------- 0003 % Date: June 27, 2009, ver01 0004 % By: Hooman Askari 0005 %-------------------------------------------------------------------------- 0006 %Inputs 0007 %-------------------------------------------------------------------------- 0008 % loads the inputToMILPCutsBlocks.mat file generated by the adjacency 0009 % matrix program and clustering program. 0010 %-------------------------------------------------------------------------- 0011 % outputs 0012 % save the solution in Solution.mat file 0013 % save the problem in the problem.mat file 0014 %-------------------------------------------------------------------------- 0015 % Pseudo Code 0016 %-------------------------------------------------------------------------- 0017 % set up the Objective function of mixed integer programming model 0018 % min f(x)= C^T.X 0019 % subject to 0020 % b_L <= A.X <= b_U 0021 % where: 0022 % C: tarnspose of coefficients in linear objective function 0023 % size-> C(numBlocks * numOfPeriods, 1) 0024 % X: vector containing mixed integer solution 0025 % A: matrix defining linear constraints 0026 % b_U: lower and upper bounds on the linear inequalities 0027 % b_L: 0028 0029 function main 0030 0031 % load the inputToMILPCutsBlocks.mat file variables, generated by the 0032 % MIP program and Mining Cut Clustering Program into memorey. 0033 0034 % Blocks, numBlocks, blocksIndices, sparsePrecedentArcs, numCuts, 0035 % miningCuts ,cutsAbove, blocksAbove, 0036 % mining and processing capacities: mcMax, mcMin, pcMax, pcMin 0037 % grade boundaries: oreGradeMin, oreGradeMax, sGradeMin, sGradeMax 0038 % pGradeMin, pGradeMax 0039 % numOfPeriods, numOfProcesses, numOfElements, interestRate 0040 load inputToMILPCutsBlocks 0041 0042 % creating an array of the capacities for different periods 0043 % in the format of pcMax(1,1:T) 0044 pcMax = repmat(pcMax,1,numOfPeriods); 0045 pcMin = repmat(pcMin,1,numOfPeriods); 0046 mcMax = repmat(mcMax,1,numOfPeriods); 0047 mcMin = repmat(mcMin,1,numOfPeriods); 0048 0049 % ---------------------------------------------------------------------- 0050 % objective funcation - equation (1) in documentation 0051 % construct objective function of coefficient vector of size 0052 % c( [(2K+N) * T], 1)= c( [(2*numCuts +numBlocks) * numOfPeriods], 1) 0053 % the vector contains the discounted oreValue and mining cost for each 0054 % period 0055 [c normC] = objective_function(Blocks,... 0056 miningCuts,... 0057 numOfPeriods,... 0058 interestRate); 0059 0060 % save the objective function to the hard drive 0061 save C c normC; 0062 clear c; 0063 % ---------------------------------------------------------------------- 0064 0065 % constructing matrix for all constraints A of size 0066 % A(numOfperiods * numBlocks, numOfperiods * numBlocks) 0067 0068 % grade blending constraints - equations (2) and (3) in documentation 0069 % A_grade = A(numOfElements * numOfPeriods , numBlocks * numOfPeriods) 0070 [A_grade b_Ugrade] = grade_blending_constraints(Blocks,... 0071 numBlocks,... 0072 numCuts,... 0073 numOfPeriods,... 0074 numOfElements,... 0075 oreGradeMin,... 0076 oreGradeMax,... 0077 sGradeMin,... 0078 sGradeMax,... 0079 pGradeMin,... 0080 pGradeMax); 0081 0082 n1 = length(b_Ugrade); 0083 disp('grade constriants:'); disp(n1) 0084 0085 save grade A_grade b_Ugrade; 0086 clear A_grade b_Ugrade; 0087 0088 %----------------------------------------------------------------------- 0089 % processing constraints - equations (4) and (5) 0090 % A_Processing(2* numOfElementsToBeProcessed * numOfPeriods 0091 % , numOfBlocks * numOfPeriods) 0092 0093 % 2 is for applying Min and Max 0094 [A_processing b_Upc]= processing_capacity_constraints(Blocks,... 0095 numBlocks,... 0096 numCuts,... 0097 numOfPeriods,... 0098 elementsProcessed,... 0099 pcMin,... 0100 pcMax); 0101 n2 = length(b_Upc)+ n1; 0102 disp('processing constriants:'); disp(n2) 0103 0104 save processing A_processing b_Upc; 0105 clear A_processing b_Upc; 0106 0107 %--------------------------------------------------------------------- 0108 % mining constraints - equations (6) and (7) in documentation 0109 % A_mining = A (2*numPeriods, numBlocks * numOfPeriods) 0110 [A_mining b_Umc]= mining_capacity_constraints(Blocks,... 0111 miningCuts,... 0112 numBlocks,... 0113 numCuts,... 0114 numOfPeriods,... 0115 rockTypesMined,... 0116 mcMin,... 0117 mcMax); 0118 n3 = length(b_Umc)+ n2; 0119 disp('mining constriants:'); disp(n3) 0120 0121 save mining A_mining b_Umc; 0122 clear A_mining b_Umc; 0123 0124 %--------------------------------------------------------------------- 0125 % slope constraints 0126 % A_slope = A ( numOfPeriods * numOfBlocksCovered 0127 % ,numBlocks * numOfPeriods) 0128 0129 % [A_slope b_Uslope] = slope_constraints(blocksAbove,... 0130 % numBlocks,... 0131 % numOfPeriods); 0132 0133 [A_slope b_Uslope] = slope_constraints(cutsAbove',... 0134 numCuts,... 0135 numOfPeriods); 0136 0137 n4 = length(b_Uslope)+ n3; 0138 disp('A-slope:'); disp(n4) 0139 0140 save slope A_slope b_Uslope; 0141 clear A_slope b_Uslope; 0142 clear blocksAbove 0143 0144 [A_slope2 b_Uslope2] = slope2_constraints(numCuts,... 0145 numOfPeriods); 0146 n5 = length(b_Uslope2)+ n4; 0147 disp('A-slope2:'); disp(n5) 0148 0149 save slope1 A_slope2 b_Uslope2; 0150 clear A_slope2 b_Uslope2; 0151 0152 %---------------------------------------------------------------------- 0153 % reserve constraints. equation (11) 0154 % checking that each block is extracted completely in one period or 0155 % over different periods. 0156 % A_reserve = A (numOfBlocks , numBlocks * numOfPeriods) 0157 [A_reserve b_Ureserve] = reserve_constraints( numBlocks,... 0158 numCuts,... 0159 numOfPeriods ); 0160 save reserve A_reserve b_Ureserve; 0161 clear A_reserve b_Ureserve; 0162 %---------------------------------------------------------------------- 0163 % ore processed always must be less than the tonnage mined 0164 0165 [A_ore_mining b_Uore_mining] = ore_mining_constraints( miningCuts,... 0166 numBlocks,... 0167 numCuts,... 0168 numOfPeriods ); 0169 save ore_mining A_ore_mining b_Uore_mining; 0170 clear A_ore_mining b_Uore_mining; 0171 %---------------------------------------------------------------------- 0172 0173 clear; 0174 load grade; load processing; load mining; load slope; load slope1; 0175 load reserve; load ore_mining; 0176 0177 % concatenating all the constraints into one matrix 0178 A = vertcat(A_ore_mining, A_grade, A_processing, A_mining,... 0179 A_slope, A_slope2, A_reserve); 0180 0181 clear A_grade A_processing A_mining A_slope A_slope2... 0182 A_reserve A_ore_mining; 0183 0184 save A A; 0185 clear A; 0186 0187 delete grade.mat; delete processing.mat; delete mining.mat; 0188 delete slope.mat; delete reserve.mat; 0189 0190 b_U = [b_Uore_mining; b_Ugrade; b_Upc; b_Umc; b_Uslope;... 0191 b_Uslope2; b_Ureserve]; 0192 0193 clear b_Ugrade b_Upc b_Umc b_Uslope b_Uslope2 b_Ureserve b_ore_mining; 0194 0195 % convert the sparse matrix to full matrix 0196 % cplex needs a full matrix. (Need to investigate this). 0197 b_U = full(b_U); 0198 save b_U b_U 0199 clear; 0200 %---------------------------------------------------------------------- 0201 % call tomlab/cplex sovler on the problem 0202 mip; 0203 0204 load inputToMILPCutsBlocks Blocks xdim ydim zdim; 0205 load inputToMILPCutsBlocks numOfPeriods numBlocks numCuts; 0206 0207 load Solution; 0208 load C normC; 0209 0210 % plot 0211 %---------------------------------------------------------------------- 0212 output_plot_cut( Blocks, Result, numOfPeriods, numBlocks,... 0213 numCuts, normC, xdim, ydim, zdim); 0214 %---------------------------------------------------------------------- 0215 0216 clear; 0217 load A; load b_U; load C; 0218 save problem; 0219 0220 clear; 0221 load Solution; load Period; load scheduledBlocks; load graphs; 0222 save Solution; 0223 clear; 0224 0225 delete A.mat; delete A_slope.mat; delete b_U.mat; delete Period.mat; 0226 delete C.mat; delete slope1.mat; delete xA.mat; delete xT.mat; 0227 delete yA.mat; delete scheduledBlocks.mat; delete ore_mining.mat; 0228 delete graphs.mat; 0229 0230 end 0231 0232 0233 0234 0235 0236 0237