0001
0002
0003
0004
0005
0006 function [A_slope2 b_Uslope2] = slope2_constraints(numBlocks,...
0007 numOfPeriods)
0008
0009 yA_slope = cell(numBlocks,1);
0010 xA_slope = cell(numBlocks,1);
0011
0012
0013
0014 blankTemp = sparse(1, numBlocks);
0015 yA=[]; save yA yA;
0016 xA=[]; save xA xA;
0017 xT=[]; save xT xT;
0018 index = 0;
0019
0020 for iBlocks = 1 : numBlocks
0021
0022
0023
0024 yVec = blankTemp;
0025 yVec(1, iBlocks)= 1;
0026
0027 yMatrixCell = cell(numOfPeriods,numOfPeriods);
0028 [yMatrixCell{:}] = deal(blankTemp);
0029
0030 for i = 1:numOfPeriods
0031 [yMatrixCell{i,1:(i)}] = deal(yVec);
0032 end
0033
0034 yMatrix = cell2mat(yMatrixCell);
0035 yMatrix = sparse(yMatrix);
0036
0037
0038
0039 xVec = blankTemp;
0040 xVec(1, iBlocks)= -1;
0041
0042
0043 A = cell(1, numOfPeriods);
0044 [A{:}] = deal(xVec);
0045 xMatrix = blkdiag(A{:});
0046
0047 yA_slope{iBlocks,1}= deal(yMatrix);
0048 xA_slope{iBlocks,1}= deal(xMatrix);
0049
0050 clear xMatrix yMatrix yVec xVec;
0051
0052
0053 xT_Ivec = blankTemp;
0054
0055 xT_IIvec = blankTemp;
0056
0057 xT_Ivec(1, iBlocks)= 1;
0058 xT_IIvec(1, iBlocks)= - 1;
0059
0060 B = cell(1, numOfPeriods);
0061 [B{:}] = deal(xT_Ivec);
0062 xT_I_MatrixCell = blkdiag(B{:});
0063
0064 xT_II_MatrixCell = cell(numOfPeriods-1,numOfPeriods);
0065 [xT_II_MatrixCell{:}] = deal(blankTemp);
0066
0067 for i = 1:numOfPeriods-1
0068 [xT_II_MatrixCell{i,i+1}] = deal(xT_IIvec);
0069 end
0070
0071 xT_II_MatrixCell = cell2mat(xT_II_MatrixCell);
0072
0073 xT_Matrix = xT_I_MatrixCell(1:end-1,:) + xT_II_MatrixCell;
0074
0075 xT_slope{iBlocks,1}= deal(xT_Matrix);
0076
0077 clear xT_I_MatrixCell xT_II_MatrixCell xT_Matrix
0078
0079 iBlocks
0080
0081
0082
0083 index = index + 1;
0084 if index >= 2000
0085 load yA;
0086 yA =[yA; cell2mat(yA_slope)];
0087 save yA yA;
0088 clear yA yA_slope
0089
0090 load xA;
0091 xA =[xA; cell2mat(xA_slope)];
0092 save xA xA;
0093 clear xA xA_slope
0094
0095 load xT;
0096 xT =[xT; cell2mat(xT_slope)];
0097 save xT xT
0098 clear xT_slope xT;
0099
0100 index = 0;
0101 end
0102
0103 end
0104
0105
0106 pack;
0107
0108 load yA; load xA; load xT;
0109 yA =[yA; cell2mat(yA_slope)];
0110 xA =[xA; cell2mat(xA_slope)];
0111 xT =[xT; cell2mat(xT_slope)];
0112 save yA yA; save xA xA; save xT xT
0113 clear yA xA yA_slope xA_slope xT_slope xT;
0114
0115 load yA; load xA; load xT
0116 [m n] = size(yA);
0117 [m1 n1] = size(xT);
0118
0119
0120
0121
0122 load inputToMILPCutsBlocks numBlocks numCuts
0123
0124 A_slope2 = [xA sparse(m, numBlocks*numOfPeriods) yA;...
0125 xT sparse(m1, numBlocks*numOfPeriods) sparse(m1, numCuts*numOfPeriods)];
0126
0127 b_Uslope2 = sparse((m+m1),1);
0128
0129 end