mip

PURPOSE ^

Calls the CPLEX MILP solver

SYNOPSIS ^

function mip

DESCRIPTION ^

 Calls the CPLEX MILP solver
 Version02
 Date: Dec 3, 2008, ver02
 By: Hooman Askari 
--------------------------------------------------------------------------
Inputs 
--------------------------------------------------------------------------
  code uploads the following variables from the disk   
     A:
       matrix defining linear constraints 
     b_U:    
       upper bounds on the linear inequalities  
     C:       
       coeefficients in linear objective function
     numBlocks:
        total number of blocks       
     numOfPeriods:
        total number of scheduling periods
--------------------------------------------------------------------------
 outputs
--------------------------------------------------------------------------
       Result:
           This is saved in Solution.mat
           a struct holding the CPLEX solution. the solution is in the 
           field x_k
--------------------------------------------------------------------------
   
--------------------------------------------------------------------------

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

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