1. Install CPLEX academic free version (V12)
2. Set up the path for Matlab.
Then, all the cplex functions are ready to go!! :)
BTW, CPLEX v.12 has the matlab built-in functions.
For other version, you can try CPLEXINT.
http://publib.boulder.ibm.com/infocenter/cosinfoc/v12r2/index.jsp?topic=%2Filog.odms.cplex.help%2FContent%2FOptimization%2FDocumentation%2FCPLEX%2F_pubskel%2FCPLEX1133.html
For license key problem, check this manual:
CPLEX Error 32201: ILM Error 16: CPLEX: license file not found or unreadable.
------------------------------------------------------
CPLEX for MATLAB Toolbox
The CPLEX® for MATLAB® Toolbox provides functions for solving a variety of mathematical programming problems. The toolbox functions are designed to take a model description as input and produce a solution as output.
For example:
x = cplexlp(f,Aineq,bineq,Aeq,beq,lb,ub)
finds the minimum of a linear programming problem specified by
min f*x st. Aineq*x <= bineq Aeq*x = beq lb <= x <= ub
The toolbox provides the functions cplexlp, cplexqp and cplexbilp to solve linear programming problems (LP), quadratic programming problems (QP) and binary integer programming problems (BILP).
The toolbox provides functions that support the solution of the basic problem types handled by CPLEX are:
Functions that support the solution of additional problem types handled by CPLEX are provided. These functions are:
- cplexqcp for quadratically constrained programming problems (QCP),
- cplexmilp for mixed integer linear programming problems (MIP),
- cplexmiqp for mixed integer quadratic programming problems (MIQP) and
- cplexmiqcp for mixed integer quadratically constrained mixed integer programming problems (MIQCP).
The solution of least square problems is supported through the functions:
- cplexlsqlin for linearly constrained least squares problems,
- cplexlsqmilp for linearly constrained mixed integer least squares problems,
- cplexlsqbilp for linearly constrained binary integer least squares problems,
- cplexlsqmiqcp for quadratically constrained mixed integer least squares problems,
- cplexlsqqcp for quadratically constrained programming problems,
- cplexlsqnonneglin for nonnegative least squares problems,
- cplexlsqnonnegmilp for nonnegative mixed integer least squares problems,
- cplexlsqnonnegmiqcp for nonnegative quadratically constrained mixed integer least squares problems and
- cplexlsqnonnegqcp for nonnegative quadratically constrained programming problems.
The advantage of the toolbox design is that you can reuse your code where you had used MATLAB® Optimization Toolbox functions to solve linear programming, quadratic programming, binary integer programming, linearly constrained least squares, and nonnegative least squares problems.
Setting and querying parameters in the CPLEX for MATLAB Toolbox
Options, also called parameters, can be set to control the solution of problems. The toolbox provides two types of options input. One type corresponds to the MATLAB Optimization Toolbox options, and the other type is the CPLEX parameters. You can use either or both of these types of options. If you use both, the CPLEX parameters will override the MATLAB options.
The toolbox options are listed in the following table.
Options corresponding to the MATLAB Optimization Toolbox
Diagnostics | 'on' | {'off'} |
Display | 'off' | 'iter' | 'final' | 'notify' |
MaxIter | refer to cplex.Param.simplex.limits.iterations |
Simplex | refer to cplex.Param.lpmethod |
refer to cplex.Param.qpmethod | |
refer to cplex.Param.mip.strategy.startalgorithm | |
BranchStrategy | refer to cplex.Param.mip.strategy.variableselect |
MaxNodes | refer to cplex.Param.mip.limits.nodes |
MaxTime | refer to cplex.Param.timelimit |
NodeDisplayInterval | refer to cplex.Param.mip.interval |
NodeSearchStrategy | refer to cplex.Param.mip.strategy.nodeselect |
TolFun | refer to cplex.Param.simplex.tolerances.optimality |
TolXInteger | refer to cplex.Param.mip.tolerances.integrality |
TolRLPFun | refer to cplex.Param.simplex.tolerances.optimality |
.
These options can be set using the toolbox function cplexoptimset. For example, the following code turns on the optimizer output and sets a node limit of 400,
options = cplexoptimset('Diagnostics', 'on', 'MaxNodes', 400);
Alternatively, these options can be set directly on the fields of the structure. For example, the following code has the same result as the previous one.
options = cplexoptimset; options.Diagnostics = 'on'; options.MaxNodes = 400;
The current and default values of the options can be queried with the function cplexoptimget.
If you need to use CPLEX parameters that do not correspond to the options in the MATLAB Optimization Toolbox, you can create a structure which contains all of the CPLEX parameters. For example, to set a node limit of 400 and instruct CPLEX to use traditional branch and cut style search:
opt = cplexoptimset('cplex'); opt.mip.limits.nodes=400; opt.mip.strategy.search=1;
Tip
If you are already familiar with the names of parameters in the Interactive Optimizer, then you quickly recognize names of parameters in CPLEX for MATLAB. For example, the command “
set mip limits nodes 1
” in the Interactive Optimizer corresponds to “opt.mip.limits.nodes = 1
;” in the CPLEX for MATLAB Toolbox where opt
was created with the line “opt = optimset('cplex');
”To assist in setting parameters, auto-completion of parameter names is available in the MATLAB environment.
没有评论:
发表评论