⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 panmip.m

📁 由matlab开发的hybrid系统的描述语言
💻 M
📖 第 1 页 / 共 5 页
字号:
function [xopt, fopt, flag, Extendedflag] = ...
         panmip(H, f, C, d, ctype, rangevar, vartype, lb, ub, x0, Options) 

%===============================================================================
% function [xopt, fopt, flag, Extendedflag] = ...
%          panmip(H, f, C, d, ctype, rangevar, vartype, lb, ub, x0, Options)
%
% Title:   panmip.m
%
% Version: 1.35
%
% Project: Mixed Integer Programs
%
% Purpose: Interface to Mixed Integer Quadratic Programs and Mixed Integer
%          Linear Programs
%
%          Solves the following Mixed Integer Program
%
%          ##############################
%          min         0.5*x'H x + f' x
%          subject to  constraints
%          ##############################
%
%          The following types of contraints are allowed to be included in the
%          problem:
%                    'L'                C x <= d
%                    'E'                C x  = d
%                    'G'                C x >= d
%                    'R'  d+rangevar <= C x <= d            (rangevar < 0)
%                    'R'  d          <= C x <= d+rangevar   (rangevar > 0)
%
%                    'box'        lb <=   x <=  ub
%
%          ctype specifies the type of constraint, i.e. inequality,
%          equality, or ranged
%          The 'box'-bounds are specified with the input arguments lb, ub
%          vartype allows to specify, whether the variables are constrained
%          to be binary (0,1), integer, or real
%          x0 is taken as initial condition for the search.
%
% Requires:This function requires the availability of solvers for Mixed Integer
%          Linear Programs (MILP) and Mixed Integer quadratic programs (MIQP).
%
% Installation:
%          1.) Install one or more solvers for mixed integer continuous 
%              problems on your systems. The supported solvers are listed 
%              below
%          2.) Change the paths in this file under "Platform-Dependent settings"
%              Note that these are path definitions, which define the relevant 
%              locations of the solvers required by the routine.
%
%          The solvers supported are specified at the point Options.solver.
%          To run panmiqp, the solvers need the additional files mentioned next:
%
%          miqp:       miqp.m
%                      qphess.m
%
%          sunbaronQP: optionsQP
%          sunbaronLP: optionsLP
%                      baronshell, mainopt, libminos.so, 
%                      libbaronopt.a, libdummiesopt.a
%
%          cplex:      milp_cplex.mexsol
%     
%          cplex_file: cplex installation
%
%          xpress:     mip_xpress.mexsol
%
%          xpress_file:xpress installation  
%  
%          fletcher:   miqp_d.mexsol
%
%          mps:        (no additional files required)
%
%          If you are using panmip.m on the IfA network, there's no need to
%          copy any files into your home directory. Follow the instructions
%          on the hybrid homepage at:
%
%          http://control.ethz.ch/~hybrid/internal/ComputationalTools/howto.txt
%
%          for details or contact one of the authors.
%
% Authors: Domenico Mignone
%          Fabio Danilo Torrisi
%          
% History: date        subject    
%              
%          2000.10.05  Initial Version
%                      = Version 1.0
%          2000.10.20  Extendedflag.time is taken for the whole routine and not
%                        inherited from the solvers 
%                      = Version 1.01
%          2000.12.05  Option savecplex added 
%                      Extended handling of optional parameters included
%                      = Version 1.02
%          2000.12.06  Adding the solver option cplex_file 
%                      = Version 1.03
%          2000.12.07  Comments and options concerning cplex_file added
%                      Reduced platform dependend commands by introducing paths
%                        at the beginning of the function
%                      = Version 1.04
%          2000.12.08  Adding the solver option xpress_file
%                      = Version 1.05
%          2001.01.15  Option of deleting files corrected by closing files first
%                      = Version 1.06
%          2001.01.23  Infeasibilities of the problem caused by xpress are now
%                        handled without crash or panmip
%                      Inclusion of the ranged constraints in the generation of
%                        mps files and therefore correct consideration in those
%                        solvers handling ranged constraints
%                      Corrected transformation of ranged constraints for those
%                        not explicitly taking ranged constraints into account
%                      Subroutine writemps modified: verbosity and support of
%                        ranged constraints, equality and inequality 
%                        constraints in both directions
%                      New subroutine ctype2allmat
%                      Improved comments in the file-header in section purpose
%                      = Version 1.1
%          2001.01.31  Flag setting for the solver sunbaron revised
%                      File identifier for solver xpress_file corrected
%                      = Version 1.11
%          2001.02.01  Correct handling of LPs when called with CPLEX
%                      Introduction of comment section "Expertise" for further
%                        documentation of possible problems when using this 
%                        interface or the solver called within panmip.m
%                      Introduced check on length of the string when solvers
%                        are used, that get data from a solution file
%                      = Version 1.12
%          2001.02.02  Expertise report about linprog, lp, quadprog added
%                      Solvers sunbaronLP and sunbaronQP now also support
%                        +/- infinity in the box constraints by converting them
%                        to large numbers
%                      Recognition of variables with value 0 is now independent
%                        from the initial value for optimizer in "cplex_file"
%                      Initialisation of rangevar corrected
%                      = Version 1.13
%          2001.02.08  Opens solution file from Baron only if problem has
%                        provided a minimizer, the message "Successful 
%                        termination" is no longer sufficient to assert
%                        successful termination
%                      Option deletefile in "xpress_file"
%                      = Version 1.14
%          2001.02.16  Handling of "infinity" in baron modified
%                      = Version 1.15
%          2001.03.22  No additional file cplex2.bat is required for the option
%                        'cplex_file' under PC use. 
%                        This file is generated on the fly with
%                        the parameters denoting license file locations and
%                        cplex locations. These paths are located under 
%                        "platform dependent settings"
%                      = Version 1.16
%          2001.05.02  Generation of cplex2.bat only for nonunix systems
%                      Integrality tolerance is added as an input parameter for
%                        the option cplex_file
%                      Node selection strategy added for option cplex_file
%                      = Version 1.17
%          2001.06.01  Removed Extension ".mps" when calling xpress-mp. Even 
%                        though xpress worked fine even when calling the problem
%                        with the extension, in case of infeasible problems the
%                        infesibility was not recognized by panmip.m
%                      = Version 1.18
%          2001.06.05  Removed fatal EOF read message in screen_output of
%                        xpress-mp, as well as a bug introduced in the previous
%                        update
%                      = Version 1.19
%          2001.06.07  Additional output format of CPLEX in the solution file
%                        for MILPs is considered:
%                            Integer optimal, tolerance (0.0001/1e-06) .... etc.
%                      = Version 1.20
%          2001.06.12  Allows to solve QPs also with the option 'cplex_file'
%                      Generation of mps files for CPLEX for QPs
%                      Inclusion of the paths for xpress-mp under DOS
%                      = Version 1.21
%          2001.06.12  Default variable generation with the command "string"
%                        has been replaced by the command "char"
%                      = Version 1.22
%          2001.06.13  Added support for initial solution in the option 
%                        'cplex_file' when solving MILP
%                      = Version 1.23
%          2001.06.14  Added support for initial partial solution. A partial 
%                      solution is a sub-vector of x.
%                      = Version 1.24
%          2001.07.31  CPLEX mip tolerances added to cut off computations 
%                        before finding the optimal solution. These options
%                        are implemented in the option 'cplex_file'.
%                      = Version 1.25
%          2001.08.21  Corrected "if find(vartype==...)" to 
%                        "if ~isempty(find(vartype==...))"
%                      Supports integer (not only binary) in the generation of
%                        the mps file to be read by CPLEX
%                      = Version 1.26
%          2001.08.22  Implemetation of corrections originating on 2001.08.02 :
%                      Added support for the following cplex options: timelimit,
%                        number of integer solutions, load and save b&b tree
%                      = Version 1.27
%          2001.08.22  Additional option to suppress the error message when 
%                        calling CPLEX with nonzero Hessian matrix H, useful
%                        for using CPLEX to test, whether an MIQP is feasible
%                      = Version 1.28
%          2001.08.23  Fixing binary variables with box bounds is correctly
%                        handled in xpress_file
%                      Option "eliminatebox" which translates box bounds to
%                        inequalities, mainly for comparison purposes in
%                        solver xpress_file
%                      = Version 1.29
%          2001.09.09  Corrected a parameter check in sunbaronQP
%                      = Version 1.30
%          2001.09.11  Inclusion of zero coefficients of the cost function in
%                        the generation of the MPS file (option: suppresserr)
%                      = Version 1.31
%          2001.09.20  Display quality of solution is possible using CPLEX
%                        with the option cplex_file.quality
%                      = Version 1.32
%          2001.09.23  Corrected a parameter check in sunbaronLP
%                      = Version 1.33
%          2001.09.27  Added the cplex_file option to remove the presolving of
%                        the problem
%                      Improved string matching when reading the solution file
%                        by CPLEX
%                      = Version 1.34
%          2001.10.22  Correction of order of options in cplex_file
%                      = Version 1.35
%
% Inputs:  mandatory arguments:
%          --------------------
%          H, f : parameters of the cost function     
%          C, d : parameters defining the constraints   
%
%          When called without arguments panmip returns in xopt the version
%          number as a text string
% 
%          optional arguments:
%          -------------------
%          ctype :  A column array containing the sense of each constraint
%                   in the constraint matrix. Note that this is case sensitive.
%                     ctype(i) = 'L'  "<=" constraint
%                     ctype(i) = 'E'  "="  constraint
%                     ctype(i) = 'G'  ">=" constraint
%                     ctype(i) = 'R'  ranged constraint
%                   Note also, that the box constraints mentioned above are
%                   not specified within ctype, but with the input parameters
%                   lb and ub.
%                   (default: [ 'L', ... , 'L']' ... number of variables)
%          rangevar:An array of at least length numrows containing the range
%                   value of each ranged constraint. Ranged rows are those
%                   designated by 'R' in the array ctype. If the row is not
%                   ranged, the rngval array entry is ignored. If
%                   rangevar(i) > 0, then row i activity is in
%                   [b(i),b(i)+rangevar(i)],
%                   and if rangevar(i) <  0, then row i activity is in
%                   [b(i)+rangevar(i),b(i)].
%                   A range value for row i means that the value of row i
%                   must be between b(i) and b(i)+ rangevar(i).
%                   rangevar(i) can be positive or negative.
%                   Note that ranged constraints are a good method to specify 
%                   relaxations in equality constraints
%                   (default: [ 0, 0, ... 0 ] ... number of constraints)
%          vartype: A column array containing the types of the variables. Note
%                   that this is case sensitive
%                     vartype(i) = 'C' continuous variable
%                     vartype(i) = 'B' Binary(0/1) variable
%                     vartype(i) = 'I' Integer variable
%                   (default: ['C', ..., 'C']')
%          lb, ub:  lower and upper bounds on variables
%                   (default: -infty and +infty)
%          x0:      initial value for search
%          Options: Matlab structure allowing to specify several choices for
%                   the available solvers 
%
%          Options.bignumber : Default value to be used for the undefined simple
%                              bounds vlb, vub
%                              (default: inf)         
%
%          Options.x0ii : Initial solution index. Consider as initial solution
%                         x0(i) if x0ii(i) = 1. 
%                         NOTE: this option is implemented only for 'cplex_file'
%                         solver. If a solver does not allow use of partial 
%                         initial solution, and this option is set then x0 is 
%                         ignored. Default = ones(size(x));
%
%          Options.solver : MIQP or MILP solver. This is case sensitive
%                    {'miqp'|'sunbaronQP'|'sunbaronLP'|'cplex'|'cplex_file'| ...
%                     'xpress'|'fletcher'|'mps'}
%
%                    'miqp'       Bemporad and Mignone's code
%                    'sunbaronQP' Sahinidis' code MIQP
%                    'sunbaronLP' Sahinidis' code MILP
%                    'mps'        Generation of mps file of the problem
%                    'cplex'      CPLEX with mex interface
%                    'cplex_file' CPLEX with file exchange
%                    'xpress'     Dash-Opt's code
%                    'fletcher'   Fletcher and Leyffer's code
%                    (default: 'miqp')
%
%          Options.solver.field : Options for the specified solver
%                                 Here solver is one of the strings listed above
%                                 as Options.solver and field is a particular
%                                 option for the solver chosen.
%                                 Consider the use of the corresponding solver
%                                 to determine the possible fields,
%                                 e.g. Options.miqp.method = 'breadth';
%  
%          Below you find a list of possible fields, that can be used with
%          Options.solver, sorted by solver.
%
%          Options.miqp:                     
%          see header of miqp.m for possible settings
%         
%          Options.sunbaronQP: 
%          leave:      the baron files are not deleted after execution of baron,
%                      if Options.sunbaronQP.leave > 0
%                      (default: delete files)
%          preci:      number of significant digits to consider in the
%                      generation of the text input file for baron

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -