【benders strategy】
OFF -1 默认分支定界求解
AUTO 0
USER 1 完全按照用户设定的annotation
WORKERS 2 先按照用户的annotation,再自动优化
FULL 3 自动确定主问题(整数变量部分)和子问题(连续型变量部分)
【key】
IloCplex::LongAnnotation bendersdec = _solver.newLongAnnotation(IloCplex::BendersAnnotation,0);
for (int i = 0; i < MFUtil::scnNum; i++)
{
for (int j = 0; j < _legList.size(); j++)
{
_solver.setAnnotation(bendersdec, _z_si[i][j], i+1);
}
}
_solver.setParam(IloCplex::Param::Benders::Strategy,
IloCplex::BendersUser);
【..\cplex\examples\src\cpp\ilobenders.cpp】
(默认:C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\examples\src)
model和ann文件均读入,cplex全自动模式(FULL)
// Example:
// ilobenders UFL_30_120_1.mps.gz UFL_30_120_1.ann
//
#include <ilcplex/ilocplex.h>
ILOSTLBEGIN
static void usage (const char *progname);
int
main (int argc, char **argv)
{
IloEnv env;
try {
IloModel model(env);
IloCplex cpx(env);
bool hasannofile = false;
// Check the arguments.
if ( argc == 3 ) {
hasannofile = true;
}
else if ( argc != 2 ) {
usage (argv[0]);
throw(-1);
}
IloObjective obj;
IloNumVarArray var(env);
IloRangeArray rng(env);
// Read the problem file.
cpx.importModel(model, argv[1], obj, var, rng);
// Extract the model.
cpx.extract(model);
// If provided, read the annotation file.
if ( hasannofile ) {
cpx.readAnnotations(argv[2]);
}
else {
// Set benders stra