


Setup objective function for the MILP cuts and blocks scheduling problem
--------------------------------------------------------------------------
Date: May 27, 2009, ver01
By: Hooman Askari
--------------------------------------------------------------------------
Inputs
--------------------------------------------------------------------------
Blocks:
is a struct holding all the block model information.
miningCuts:
is a CellArray holding the indices of blocks in each cut.
numOfPeriods:
number of scheduling periods.
interestRate:
minimum acceptable rate of return.
--------------------------------------------------------------------------
outputs
v: normalized value of oreValue(N, T)= a matrix of discounted ore
values (oreValue) as defined in the documentation.
q: normalized value miningCost(N, T)= a matrix of discounted mining
cost(miningCost)as defined in the document.
qCut : qCut(numCuts*numOfPeriods, 1)is the summation of
q values(mining costs)for each mining cut.
normVQ: norm of vector [v ; q]; After optimization the value of the
objective function must be multiplied by normVQ to get the
disounted cash flow value of the produciton schedule.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
Pseudo Code
v: holds the discounted oreValue with respect to the period
each column holds the discounted ore value of that period
[1:numberOfPeriods]
q: The same concept explained above is valid about q.
--------------------------------------------------------------------------

0001 % Setup objective function for the MILP cuts and blocks scheduling problem 0002 %-------------------------------------------------------------------------- 0003 % Date: May 27, 2009, ver01 0004 % By: Hooman Askari 0005 %-------------------------------------------------------------------------- 0006 %Inputs 0007 %-------------------------------------------------------------------------- 0008 % Blocks: 0009 % is a struct holding all the block model information. 0010 % miningCuts: 0011 % is a CellArray holding the indices of blocks in each cut. 0012 % numOfPeriods: 0013 % number of scheduling periods. 0014 % interestRate: 0015 % minimum acceptable rate of return. 0016 %-------------------------------------------------------------------------- 0017 % outputs 0018 % v: normalized value of oreValue(N, T)= a matrix of discounted ore 0019 % values (oreValue) as defined in the documentation. 0020 % 0021 % q: normalized value miningCost(N, T)= a matrix of discounted mining 0022 % cost(miningCost)as defined in the document. 0023 % 0024 % qCut : qCut(numCuts*numOfPeriods, 1)is the summation of 0025 % q values(mining costs)for each mining cut. 0026 % 0027 % normVQ: norm of vector [v ; q]; After optimization the value of the 0028 % objective function must be multiplied by normVQ to get the 0029 % disounted cash flow value of the produciton schedule. 0030 %-------------------------------------------------------------------------- 0031 % 0032 %-------------------------------------------------------------------------- 0033 % Pseudo Code 0034 % v: holds the discounted oreValue with respect to the period 0035 % each column holds the discounted ore value of that period 0036 % [1:numberOfPeriods] 0037 % 0038 % q: The same concept explained above is valid about q. 0039 % 0040 %-------------------------------------------------------------------------- 0041 function [c normVQ] = objective_function(Blocks,... 0042 miningCuts,... 0043 numOfPeriods,... 0044 interestRate) 0045 0046 % get the number of blocks in the model 0047 [numBlocks n] = size([Blocks.EBV]'); 0048 0049 % get the number of mining cuts in the model 0050 [m numCuts] = size(miningCuts); 0051 0052 % These are the same varaibles as defined in the main document 0053 % using the longer notation for readability of code 0054 % N = numBlocks; 0055 % T = numOfPeriods; 0056 % K = numCuts; 0057 0058 % mining cuts is a CellArray containing the block indices of each cut 0059 C = miningCuts; 0060 0061 % constructs coefficients of the objective funciton (see documentation) 0062 % oreValue is an attribute of each block 0063 % see repmat help 0064 oreValue = repmat([Blocks.oreValue]', 1, numOfPeriods); 0065 0066 % constructs coefficients of the objective funciton (see documentation) 0067 % miningCost is an attribute of each block 0068 % see repmat help 0069 miningCost = repmat([Blocks.miningCost]', 1, numOfPeriods); 0070 0071 % the for loop discounts the block values and assign it to the proper 0072 % cells in the objective function vector (v and q) 0073 for iPeriods = 1:numOfPeriods 0074 % v is a matrix holding the discounted oreValue as defined in the 0075 % documentation. 0076 % v(N, T) = discounted oreValue(N, T) 0077 % ex. v(1:N, 2)= holds the discounted orevales of the blocks in 0078 % the 2nd period. 0079 v(1:numBlocks, iPeriods)= oreValue(1:numBlocks,iPeriods)/... 0080 ((1+interestRate)^iPeriods); 0081 0082 % q is a matrix holding the discounted miningCosts as defined in 0083 % the documentation. 0084 % q(N, T) = disounted miningCost(N, T) 0085 % ex. q(1:N, 3)= holds the discounted mining cost of all the blocks 0086 % in the in the 3rd period. 0087 q(1:numBlocks, iPeriods)= miningCost(1:numBlocks,iPeriods)/... 0088 ((1+interestRate)^iPeriods); 0089 0090 end 0091 0092 % initialize the qCut matrix; 0093 qCut = zeros(numCuts, numOfPeriods); 0094 0095 % this for loop constructs the summation of q values for each cut in 0096 % each period. 0097 % qCut(K, T) holds the the summation of q values for each cut this is 0098 % used in the objective function 0099 for i = 1:numCuts 0100 temp = miningCuts{i}; 0101 qCut(i,:) = sum(q(temp,:)); 0102 end 0103 0104 % the MILP function minimizes the function f(x) we multiply by -1 to 0105 % maximize the funciton passed to TOMLAB 0106 v = v * (-1); 0107 0108 % in documentation q is the mining cost and in the input file it has a 0109 % negative sign to represent it as cost 0110 qCut = qCut * (-1); 0111 0112 % we need to calcualte a single norm for v and q matrices. 0113 % see the documentation of the code for the format of the objective 0114 % function. After optimization the value of the objective function must 0115 % be multiplied with the norm to get the real disounted cash flow value 0116 % of the produciton schedule. 0117 combinedVQ = [v; qCut]; 0118 normVQ = norm( combinedVQ ); 0119 0120 % normalizing the v matrix 0121 % ore value vector norm 0122 v = v /normVQ; 0123 0124 % normalizing the q matrix 0125 % mining cost vector norm 0126 qCut = qCut /normVQ; 0127 0128 % reshape the matrix into a vector 0129 qCut = reshape(qCut, numCuts*numOfPeriods, 1); 0130 0131 % reshape v matrix into vector 0132 v = reshape(v, numBlocks*numOfPeriods, 1); 0133 0134 % this is the coefficient of the objective function 0135 % size of this vector is c( K.T + N.T + K.T, 1) or c( (2K + N)T, 1) 0136 c =[zeros(numCuts*numOfPeriods,1); v; qCut]; 0137 0138 end