processing_capacity_constraints

PURPOSE ^

Constructs the processing capacity constraint matrix

SYNOPSIS ^

function [A_processing b_Upc]=processing_capacity_constraints(Blocks,numBlocks,numCuts,numOfPeriods,elementsProcessed,varargin)

DESCRIPTION ^

 Constructs the processing capacity constraint 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 each processing capacity 
       in this case: pcMin and pcMax
            a 1*1 vector containing the min and max processing capacity
            for each processes. 

--------------------------------------------------------------------------
 outputs
       A_processing = [zeros(m, numCuts * numOfPeriods )...
                       A_processing... 
                       zeros(m, numCuts * numOfPeriods)]; 
      
       b_processing = processing boundary conditions 
--------------------------------------------------------------------------
   
--------------------------------------------------------------------------
 Pseudo Code
   
--------------------------------------------------------------------------

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % Constructs the processing capacity constraint 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 each processing capacity
0020 %       in this case: pcMin and pcMax
0021 %            a 1*1 vector containing the min and max processing capacity
0022 %            for each processes.
0023 %
0024 %--------------------------------------------------------------------------
0025 % outputs
0026 %       A_processing = [zeros(m, numCuts * numOfPeriods )...
0027 %                       A_processing...
0028 %                       zeros(m, numCuts * numOfPeriods)];
0029 %
0030 %       b_processing = processing boundary conditions
0031 %--------------------------------------------------------------------------
0032 %
0033 %--------------------------------------------------------------------------
0034 % Pseudo Code
0035 %
0036 %--------------------------------------------------------------------------
0037 
0038 function  [A_processing b_Upc]=...
0039                     processing_capacity_constraints(Blocks,...
0040                                                     numBlocks,...
0041                                                     numCuts,...
0042                                                     numOfPeriods,...
0043                                                     elementsProcessed,...
0044                                                     varargin)
0045    % elementsProcessed(1, number of elements processed)
0046    % this array contains the indices from numOfElements
0047    % example [1 3 4]: elements 1 3 and 4 are processed
0048    
0049    % unpacking varargin
0050    % unpacks the minimum and maximum processing capacity for each element
0051    % processed into two arrays
0052    % pcElementsMin (1, 1:numOfElementsProcessed) = element's
0053    % minimum processing capacity
0054    % pcElementsMax (1, 1:numOfElementsProcessed) = element's
0055    % maximum processing capacity
0056    % the matrix column index corrosponds to the element index
0057    % example: second element maximum is in  elementsMax(1,2)
0058    iMin = 1;
0059    iMax = 1;
0060    for i =1:numOfPeriods
0061        for k = 1:length(varargin);
0062             % check to see if the index of varargin is odd
0063             % add the variable to the elementsMin
0064             % other wise add it to the elementsMax
0065             if rem(k,2)~= 0
0066                 if isempty(varargin{1,k})
0067                     pcElementsMin(1,iMin) = NaN;
0068                 else
0069                     pcElementsMin(1,iMin) = varargin{1,k}(1,i);
0070                 end
0071                 iMin = iMin + 1;
0072             else
0073                 if isempty(varargin{1,k})
0074                     pcElementsMax(1,iMax) = NaN;
0075                 else
0076                     pcElementsMax(1,iMax) = varargin{1,k}(1,i);
0077                 end
0078                 iMax = iMax + 1;
0079             end
0080        end
0081    end 
0082    % vectors containing the relevant elements
0083    oreTonnage = [Blocks.OreTonnes]';
0084    sTonnage = [Blocks.S]'/100;
0085    pTonnage = [Blocks.P]'/100;
0086    
0087    % elementsTonnage(numberOfElments, numBlocks)
0088    elementsTonnage = [oreTonnage'; sTonnage'; pTonnage'];
0089    
0090  totalProcessed  = sum(elementsTonnage(1,:))
0091  processingCapacity = totalProcessed / numOfPeriods
0092    
0093 % initialize the A_grade vector
0094 A_processing =[];
0095 b_Upc =[];
0096  
0097 for i = 1: length(elementsProcessed) 
0098         
0099        %unequality constraints for elements number iElements minimum
0100        if ~isnan (pcElementsMin(elementsProcessed(i)))
0101            %minPCVector = oreTonnage.*-1;
0102            minPcVector = elementsTonnage((elementsProcessed(i)),:).*-1;
0103            A_processing = update_constraints(A_processing,...
0104                                              numBlocks,...
0105                                              numOfPeriods,...
0106                                              minPcVector);
0107            %updateValue = mcMin*-1;
0108            updateValue = pcElementsMin(elementsProcessed(i))*-1;
0109            b_Upc = update_boundaries(b_Upc, numOfPeriods, updateValue);
0110        end
0111 
0112        %unequality constraints for elements number iElements maximum
0113       if ~isnan (pcElementsMax(elementsProcessed(i)))
0114            % maxMWTVector =(oreGrade-oreGradeMax).* oreTonnage;
0115            maxPcVector = elementsTonnage((elementsProcessed(i)),:);
0116            A_processing = update_constraints(A_processing,...
0117                                              numBlocks,...
0118                                              numOfPeriods,...
0119                                              maxPcVector);
0120            %updateValue = mcMax;
0121            updateValue = pcElementsMax(elementsProcessed(i));
0122            b_Upc = update_boundaries(b_Upc, numOfPeriods, updateValue);
0123       end
0124       
0125 end % i = 1: length(elementsProcessed)
0126 
0127    A_processing = sparse(A_processing);
0128    b_Upc = sparse(b_Upc);
0129    
0130    [m n] = size(A_processing);
0131    
0132    % the mulitplier vector in the constraints matrix have different sizes
0133    % and units. (some are tonnage some are grade....). It is necessary to
0134    % transform the constraints matrix in a way that it unit less to be
0135    % solved by the MIP code.
0136    
0137    % divide each row vector by its norm [A(i,:)* A(i,:)']^1/2
0138    % A_processingNormVector(m,1) is vertical vector holding the respective
0139    % norm of each row of the A_processing matrix
0140    
0141    for i = 1:m  
0142       A_processingNormVector(i,1) = norm(A_processing(i,:));     
0143    end
0144    
0145    for i = 1:m  
0146       normA = A_processingNormVector(i,1); 
0147       A_processing(i,:) = A_processing(i,:)/normA;     
0148       
0149       % normalizing the upper bound
0150       b_Upc(i)= b_Upc(i)/normA;
0151    end
0152 
0153    A_processing = [zeros(m, numCuts * numOfPeriods )...
0154                    A_processing... 
0155                    zeros(m, numCuts * numOfPeriods)]; 
0156 end
0157 
0158 
0159

Generated on Wed 08-Jul-2009 18:57:55 by m2html © 2003