Home > matpower6.0 > mpopt2qpopt.m

mpopt2qpopt

PURPOSE ^

MPOPT2QPOPT Create/modify MI/QPS_MATPOWER options struct from MPOPT.

SYNOPSIS ^

function qpopt = mpopt2qpopt(mpopt, model, alg)

DESCRIPTION ^

MPOPT2QPOPT   Create/modify MI/QPS_MATPOWER options struct from MPOPT.

   QPOPT = MPOPT2QPOPT(MPOPT, MODEL)
   QPOPT = MPOPT2QPOPT(MPOPT, MODEL, ALG)

   Uses a MATPOWER options struct, MPOPT, to create or modify an
   MIQPS_MATPOWER or QPS_MATPOWER options struct.

   Inputs (default values in parentheses):
       MPOPT : MATPOWER options struct
       MODEL ('MIQP') : (optional) one of the following model types, required
               for selection of solver in case ALG is 'DEFAULT' (solver
               precedence for each model type list in parentheses):
           'LP'   - linear program with all continuous variables
                   (GUROBI, CPLEX, MOSEK, OT (if Matlab), GLPK, BPMPD, MIPS)
           'QP'   - quadratic program with all continuous variables
                   (GUROBI, CPLEX, MOSEK, OT (if large-scale alg available),
                    BPMPD, MIPS)
           'MILP' - LP with mixed integer/continuous variables
                   (GUROBI, CPLEX, MOSEK, OT, GLPK)
           'MIQP' - (default) QP with mixed integer/continuous variables
                   (GUROBI, CPLEX, MOSEK)
       ALG ('opf.dc') : (optional) 'opf.dc', 'most', or any valid value of
               OPT.alg for QPS_MATPOWER or MIQPS_MATPOWER. The first two
               options indicate that it should be taken from
               MPOPT.opf.dc.solver or MPOPT.most.solver, respectively.

   Output:
       QPOPT : an options struct for use by QPS_MATPOWER or MIQPS_MATPOWER
               and friends

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function qpopt = mpopt2qpopt(mpopt, model, alg)
0002 %MPOPT2QPOPT   Create/modify MI/QPS_MATPOWER options struct from MPOPT.
0003 %
0004 %   QPOPT = MPOPT2QPOPT(MPOPT, MODEL)
0005 %   QPOPT = MPOPT2QPOPT(MPOPT, MODEL, ALG)
0006 %
0007 %   Uses a MATPOWER options struct, MPOPT, to create or modify an
0008 %   MIQPS_MATPOWER or QPS_MATPOWER options struct.
0009 %
0010 %   Inputs (default values in parentheses):
0011 %       MPOPT : MATPOWER options struct
0012 %       MODEL ('MIQP') : (optional) one of the following model types, required
0013 %               for selection of solver in case ALG is 'DEFAULT' (solver
0014 %               precedence for each model type list in parentheses):
0015 %           'LP'   - linear program with all continuous variables
0016 %                   (GUROBI, CPLEX, MOSEK, OT (if Matlab), GLPK, BPMPD, MIPS)
0017 %           'QP'   - quadratic program with all continuous variables
0018 %                   (GUROBI, CPLEX, MOSEK, OT (if large-scale alg available),
0019 %                    BPMPD, MIPS)
0020 %           'MILP' - LP with mixed integer/continuous variables
0021 %                   (GUROBI, CPLEX, MOSEK, OT, GLPK)
0022 %           'MIQP' - (default) QP with mixed integer/continuous variables
0023 %                   (GUROBI, CPLEX, MOSEK)
0024 %       ALG ('opf.dc') : (optional) 'opf.dc', 'most', or any valid value of
0025 %               OPT.alg for QPS_MATPOWER or MIQPS_MATPOWER. The first two
0026 %               options indicate that it should be taken from
0027 %               MPOPT.opf.dc.solver or MPOPT.most.solver, respectively.
0028 %
0029 %   Output:
0030 %       QPOPT : an options struct for use by QPS_MATPOWER or MIQPS_MATPOWER
0031 %               and friends
0032 
0033 %   MATPOWER
0034 %   Copyright (c) 2015-2016, Power Systems Engineering Research Center (PSERC)
0035 %   by Ray Zimmerman, PSERC Cornell
0036 %
0037 %   This file is part of MATPOWER.
0038 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0039 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0040 
0041 %% set default args
0042 if nargin < 3
0043     alg = '';
0044     if nargin < 2
0045         model = '';
0046     end
0047 end
0048 if isempty(model)
0049     model = 'MIQP';
0050 else
0051     model = upper(model);
0052 end
0053 skip_prices = 0;
0054 price_stage_warn_tol = [];
0055 
0056 %% get ALG from mpopt, if necessary
0057 switch alg
0058     case {'opf.dc', ''}
0059         alg = upper(mpopt.opf.dc.solver);
0060     case 'most'
0061         alg = upper(mpopt.most.solver);
0062         skip_prices             = mpopt.most.skip_prices;
0063         price_stage_warn_tol    = mpopt.most.price_stage_warn_tol;
0064     otherwise
0065         alg = upper(alg);
0066 end
0067 
0068 %% default solver
0069 switch alg
0070     case {'DEFAULT', 0}
0071         if have_fcn('gurobi')
0072             alg = 'GUROBI';     %% use Gurobi by default, if available
0073         elseif have_fcn('cplex')
0074             alg = 'CPLEX';      %% if not, then CPLEX, if available
0075         elseif have_fcn('mosek')
0076             alg = 'MOSEK';      %% if not, then MOSEK, if available
0077         elseif have_fcn('linprog') && strcmp(model, 'LP') && have_fcn('matlab') || ...
0078                 have_fcn('quadprog_ls') && strcmp(model, 'QP') || ...
0079                 have_fcn('intlinprog') && strcmp(model, 'MILP')
0080             alg = 'OT';         %% if not, then Optimization Tbx, if available
0081                                 %% and applicable
0082         elseif have_fcn('glpk') && model(end-1) == 'L'  %% LP or MILP
0083             alg = 'GLPK';       %% if not, then GLPK, if available & applicable
0084         elseif model(1) ~= 'M'  %% LP or QP
0085             if have_fcn('bpmpd')
0086                 alg = 'BPMPD';  %% if not, then BPMPD_MEX, if available
0087                                 %% and applicable
0088             else
0089                 alg = 'MIPS';   %% otherwise MIPS, if applicable
0090             end
0091         else
0092             error('mpopt2qpopt: Sorry, no solver available for %s models', model);
0093         end
0094 end
0095 
0096 %% create MI/QPS_MATPOWER options struct
0097 qpopt = struct('alg', alg, 'verbose', mpopt.verbose);
0098 switch alg
0099     case {'MIPS', 200, 250}
0100         %% set up options
0101         qpopt.mips_opt = mpopt.mips;
0102         if qpopt.mips_opt.feastol == 0      %% = MPOPT.opf.violation by default
0103             qpopt.mips_opt.feastol = mpopt.opf.violation;
0104         end
0105     case {'IPOPT', 400}
0106         qpopt.ipopt_opt = ipopt_options([], mpopt);
0107     case 'CLP'
0108         qpopt.clp_opt = clp_options([], mpopt);
0109     case {'CPLEX', 500}
0110         qpopt.cplex_opt = cplex_options([], mpopt);
0111     case 'GLPK'
0112         qpopt.glpk_opt = glpk_options([], mpopt);
0113     case {'GUROBI', 700}
0114         qpopt.grb_opt = gurobi_options([], mpopt);
0115     case {'MOSEK', 600}
0116         qpopt.mosek_opt = mosek_options([], mpopt);
0117     case {'OT', 300}
0118         if isfield(mpopt, 'linprog') && ~isempty(mpopt.linprog)
0119             qpopt.linprog_opt = mpopt.linprog;
0120         end
0121         if isfield(mpopt, 'quadprog') && ~isempty(mpopt.quadprog)
0122             qpopt.quadprog_opt = mpopt.quadprog;
0123         end
0124         if isfield(mpopt, 'intlinprog') && ~isempty(mpopt.intlinprog)
0125             qpopt.intlinprog_opt = mpopt.intlinprog;
0126         end
0127 end
0128 if model(1) == 'M'
0129     qpopt.skip_prices           = skip_prices;
0130     qpopt.price_stage_warn_tol  = price_stage_warn_tol;
0131 end

Generated on Fri 16-Dec-2016 12:45:37 by m2html © 2005