


Calls CPLEX solver for the optimization problem -------------------------------------------------------------------------- Date: July 30, 2010, ver01 By: Eugene Ben-Awuah --------------------------------------------------------------------------


0001 % Calls CPLEX solver for the optimization problem 0002 %-------------------------------------------------------------------------- 0003 % Date: July 30, 2010, ver01 0004 % By: Eugene Ben-Awuah 0005 %-------------------------------------------------------------------------- 0006 0007 function [Result]= goal_program() 0008 0009 0010 load A 0011 load b_U 0012 %load inputToMILPCutsBlocks numBlocks numCuts numOfPeriods 0013 load inputToGPBlocks 0014 load b_L 0015 0016 load C; 0017 %load inputToMILPCutsBlocks xIP 0018 0019 % name used in TOMLAB solvers 0020 Name='Mine Schedule Goal Programming'; 0021 0022 [m,n] = size(A); 0023 0024 % numberOfNonZeroElements = nnz(A) 0025 0026 % Make problem on standard form for mipSolve 0027 % Compile the range of the deviational variables for each goal 0028 %x_U_d1 = repmat(miningd1,numOfPeriods,1); 0029 x_U_d1 = [miningd1]'; 0030 %x_U_d2 = repmat(processingd2,numOfPeriods,1); 0031 x_U_d2 = [processingd2]'; 0032 %x_U_d3 = repmat(dykemd3,numOfPeriods,1); 0033 x_U_d3 = [dykemd3]'; 0034 %x_U_d4 = repmat(dykemd4,numOfPeriods,1); 0035 x_U_d4 = [dykemd4]'; 0036 x_U_d = [x_U_d1; x_U_d2; x_U_d3; x_U_d4]; 0037 0038 [m1 m2] = size(x_U_d); 0039 x_L = zeros(n,1); 0040 x_U = ones(n-m1,1); 0041 x_U = [x_U;x_U_d]; 0042 x_0 = zeros(n,1); 0043 0044 fprintf('Mine Scheduling Problem. Variables %d. Constraints %d\n',n,m); 0045 0046 x_min = x_L; x_max = x_U; % f_Low = -1E7; 0047 f_Low =[]; % f_Low <= f_optimal must hold 0048 0049 %b_L = -inf*ones(m,1); % lower bound; 0050 f_opt = []; % f_opt = -141278; 0051 0052 % Problem number not used 0053 nProblem = []; 0054 % Do not use any prior knowledge 0055 fIP = []; 0056 % Do not use any prior knowledge 0057 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0058 xIP = []; 0059 % Just define the Prob structure, not any permanent setup file 0060 setupFile = []; 0061 % The optimal integer solution is not known 0062 x_opt = []; 0063 % No variable priorities, largest fractional part will be used 0064 VarWeight = []; 0065 % Run with the knapsack heuristic 0066 KNAPSACK = 1; 0067 0068 % reserve constraint equality 0069 % set the lower bound to the upper bound to enforce the equality 0070 % b_L(numRows+1:end) = b_U(numRows+1:end); 0071 0072 % this is for the binary product equality 0073 %b_L( (end - (numBlocks + numCuts) )+1 : end ) = ... 0074 %b_U( (end - (numBlocks + numCuts) )+1 : end ); 0075 0076 idx_int = (1:numBlocks*numOfPeriods)'; 0077 % intVars[]; % no integer variable 0078 IntVars = [idx_int]; 0079 0080 % Assign routine for defining an MIP problem. 0081 % intVars hold the blocks that have ore and are used as binary 0082 % variables. 0083 Prob = mipAssign(c, A, b_L, b_U, x_L, x_U, x_0, Name, setupFile, ... 0084 nProblem, IntVars, VarWeight, KNAPSACK, fIP, xIP,... 0085 f_Low, x_min, x_max, f_opt, x_opt); 0086 0087 % Prob = bincont2lin(Prob, idx_prod, idx_bin, idx_cont); 0088 0089 Prob.optParam.IterPrint = 1; % Set to 1 to see iterations zero otherwise. 0090 Prob.Solver.Alg = 2; % Depth First, then Breadth search 0091 Prob.PriLev = 3; 0092 % print iterations information while runnning 0093 Prob.PriLevOpt = 1; 0094 0095 % Calling driver routine tomRun to run the solver. 0096 % The 1 sets the print level after optimization. 0097 0098 0099 % emphasis on memory message 0100 Prob.MIP.cpxControl.NODEFILEIND = 2; 0101 Prob.MIP.cpxControl.MEMORYEMPHASIS = 1; 0102 0103 % Sets an absolute tolerance on the gap between the best integer 0104 % objective and the objective of the best node remaining. 0105 %instruct CPLEX to stop as soon as it has found a feasible integer 0106 % solution proved to be within X% percent of optimal. 0107 % here is set to 5% 0108 Prob.MIP.cpxControl.EPGAP = 0.05; 0109 0110 %Species the amount by which an integer variable can be different from 0111 %an integer and still be considered feasible. 0112 % default = 0.01 0113 Prob.MIP.cpxControl.EPMRK = 0.05; 0114 0115 % Description: Optimality tolerance. 0116 % Influences the reduced-cost tolerance for optimality. 0117 % This parameter governs how closely CPLEX must approach 0118 % the theoretically optimal solution. default 10e-6 0119 Prob.MIP.cpxControl.EPOPT = 10e-4; 0120 0121 % MIP node log display information. 0122 Prob.MIP.cpxControl.MIPDISPLAY = 4; 0123 0124 % MIP emphasis indicator. Emphasize feasibility over optimality 0125 Prob.MIP.cpxControl.MIPEMPHASIS = 1; 0126 0127 % Name of the file to write the CPLEX log information to. 0128 Prob.CPLEX.LogFile = 'logFile.txt'; 0129 0130 % sensitivity analysis 0131 % only for LP problems IntVars =[]; 0132 %saRequest.obj.index = 1:n; 0133 %Prob.CPLEX.sa = saRequest; 0134 0135 %exitFlag = checkFuncs(Prob, 'cplex', 1); 0136 0137 Prob.CPLEX.confgrps = ... 0138 cpxBuildConflict( length(x_L), length(b_L), 0, 0, 0, 'full' ); 0139 0140 Prob.CPLEX.conflictFile = 'cplexC.txt'; 0141 0142 %Result = tomRun('mipSolve', Prob, 1); 0143 Result = tomRun('cplex', Prob, 1); 0144 %Result = tomRun('xpress-mp', Prob, 1); 0145 %Result = tomRun('miqpBB', Prob, 1); 0146 %Result = tomRun('minlpBB', Prob, 1); 0147 %print results as print level 2 0148 0149 PriLev = 3; 0150 PrintResult(Result,PriLev); 0151 0152 % profile report; 0153 0154 f = Result.f_k; 0155 0156 save Solution Result f; 0157 end