43#if defined(_MSC_VER) && defined(SCIP_THREADSAFE)
62#define NLPI_NAME "filtersqp"
63#define NLPI_DESC "Sequential Quadratic Programming trust region solver by R. Fletcher and S. Leyffer"
64#define NLPI_PRIORITY -1000
66#define RANDSEED 26051979
67#define MAXPERTURB 0.01
69#define WORKSPACEGROWTHFACTOR 2
71#define OPTTOLFACTOR 0.5
145#ifdef FNAME_LCASE_DECOR
146# define F77_FUNC(name,NAME) name ## _
148#ifdef FNAME_UCASE_DECOR
149# define F77_FUNC(name,NAME) NAME ## _
151#ifdef FNAME_LCASE_NODECOR
152# define F77_FUNC(name,NAME) name
154#ifdef FNAME_UCASE_NODECOR
155# define F77_FUNC(name,NAME) NAME
269#ifdef SCIP_THREADSAFE
307 assert(
now.sec >= nlpidata->starttime.sec);
308 assert(
now.sec > nlpidata->starttime.sec ||
now.usec >= nlpidata->starttime.usec);
310 return (SCIP_Real)(
now.sec - nlpidata->starttime.sec) + 1
e-6 * (SCIP_Real)(
now.usec - nlpidata->starttime.usec);
343 SCIPdebugMsg(problem->
scip,
"interrupted or timelimit reached, issuing arithmetic exception in objfun\n");
381 for(
j = 0;
j < *m; ++
j )
386 SCIPdebugMsg(problem->
scip,
"arithmetic exception in confun for constraint %d\n",
j);
430 SCIPdebugMsg(problem->
scip,
"arithmetic exception in gradient for constraints\n");
435 SCIPdebugMsg(problem->
scip,
"arithmetic exception in gradient for objective\n");
499 for(
i = 0;
i < *m; ++
i )
500 lambda[
i] = -lam[*n+
i];
511 for(
i = 0;
i < nnz + *n + 2; ++
i )
569 (*la)[0] =
nvars+nnz+1;
577 for(
i = 0;
i < nnz; ++
i )
586#ifdef SCIP_MORE_DEBUG
588 printf(
"la[%2d] = %2d\n",
i, (*la)[
i]);
633 *lasize = 1 + nnz +
nvars + 1;
639 for(
i = 0;
i < nnz; ++
i )
640 (*la)[1+
i] = col[
i] + 1;
643 for( v = 0; v <=
nvars; ++v )
644 (*la)[(*la)[0]+v] =
offset[v] + 1;
648#ifdef SCIP_MORE_DEBUG
649 for(
i = 0;
i < 1 + nnz +
nvars + 1; ++
i )
650 printf(
"lw[%2d] = %2d\n",
i, (*la)[
i]);
679 for(
i = 0;
i < n; ++
i )
687 SCIPdebugMsg(problem->
scip,
"FilterSQP started without initial primal values; make up something by projecting 0 onto variable bounds and perturb\n");
689 if( data->randnumgen ==
NULL )
694 for(
i = 0;
i < n; ++
i )
719 SCIPdebugMsg(problem->
scip,
"could not evaluate or constraint %d in %s starting point or Jacobian not available\n",
i-1, problem->
initguess !=
NULL ?
"provided" :
"made up");
757 SCIPdebugMsg(
scip,
"fast fail parameter not supported by FilterSQP interface yet. Ignored.\n");
866 if( problem->
rstat[4] <= feastol )
874 if( problem->
rstat[4] <= feastol )
894 if( problem->
rstat[4] <= feastol )
939 if( (*nlpidata)->randnumgen !=
NULL )
958 (*problem)->scip =
scip;
979 if( (*problem)->oracle !=
NULL )
1025 problem->warmstart =
FALSE;
1032 if( problem->primalvalues !=
NULL )
1037 if( problem->varlbdualvalues !=
NULL )
1042 if( problem->varubdualvalues !=
NULL )
1047 if( problem->x !=
NULL )
1052 if( problem->lam !=
NULL )
1057 if( problem->bl !=
NULL )
1064 if( problem->s !=
NULL )
1073 if( problem->bl !=
NULL )
1083 for(
i = nconss-1;
i >= 0; --
i )
1123 problem->warmstart =
FALSE;
1130 if( problem->consdualvalues !=
NULL )
1135 if( problem->c !=
NULL )
1140 if( problem->lam !=
NULL )
1145 if( problem->bl !=
NULL )
1154 if( problem->s !=
NULL )
1163 if( problem->bl !=
NULL )
1170 for(
i = 0;
i < nconss; ++
i )
1222 if( problem->bl !=
NULL )
1228 problem->bl[indices[
i]] = lbs[
i];
1229 problem->bu[indices[
i]] = ubs[
i];
1249 if( problem->bl !=
NULL )
1256 for(
i = 0;
i < nconss; ++
i )
1280 problem->warmstart =
FALSE;
1307 problem->warmstart =
FALSE;
1361 problem->cstype[
idxcons] = expr !=
NULL ?
'N' :
'L';
1396 if( primalvalues !=
NULL )
1398 if( problem->initguess ==
NULL )
1447 if( param.timelimit == 0.0 )
1450 problem->niterations = 0;
1451 problem->solvetime = 0.0;
1463 iprint = param.verblevel;
1466 if( !param.warmstart )
1467 problem->warmstart =
FALSE;
1479 ifail = problem->warmstart ? -1 : 0;
1484 if( problem->warmstart )
1485 memset(problem->istat+1, 0,
sizeof(problem->istat)-
sizeof(*problem->istat));
1487 memset(problem->istat, 0,
sizeof(problem->istat));
1488 memset(problem->rstat, 0,
sizeof(problem->rstat));
1489 problem->niterations = 0;
1491 if( problem->x ==
NULL )
1495 if( problem->c ==
NULL )
1499 if( problem->lam ==
NULL )
1507 if( problem->s ==
NULL )
1512 if( problem->la ==
NULL )
1518 maxa = problem->la[0]-1;
1520 if( problem->hessiannz ==
NULL )
1527 if( problem->bl ==
NULL )
1538 for(
i = 0;
i < m; ++
i )
1563 lh1 = problem->hessiannz[0]-1 + 8 + 2*n + m;
1571 if( !problem->warmstart )
1582#ifdef SCIP_THREADSAFE
1594 for( nruns = 1; ; ++nruns )
1596 maxiter = param.iterlimit - problem->niterations;
1600 &
maxf, &
mlp, &problem->mxwk, &problem->mxiwk,
1602 problem->x, problem->c, &f, &problem->fmin, problem->bl,
1603 problem->bu, problem->s, problem->a, problem->la, problem->ws,
1604 problem->lws, problem->lam, problem->cstype, user,
1605 iuser, &maxiter, problem->istat,
1608 problem->niterations += problem->istat[1];
1614 if(
ifail < 8 && (
ifail != 0 || problem->rstat[0] <= param.opttol) )
1617 if( param.verblevel > 0 )
1619 SCIPinfoMessage(
scip,
NULL,
"FilterSQP terminated with status %d in run %d, absolute KKT violation is %g\n",
ifail, nruns, problem->rstat[0]);
1625 if( param.verblevel > 0 )
1635 if( param.verblevel > 0 )
1648 if( param.verblevel > 0 )
1655 epsfactor = param.opttol / problem->rstat[0];
1660 if( param.verblevel > 0 )
1706#ifdef SCIP_THREADSAFE
1721 return problem->solstat;
1730 return problem->termstat;
1739 if( primalvalues !=
NULL )
1743 *primalvalues = problem->primalvalues;
1746 if( consdualvalues !=
NULL )
1750 *consdualvalues = problem->consdualvalues;
1753 if( varlbdualvalues !=
NULL )
1757 *varlbdualvalues = problem->varlbdualvalues;
1760 if( varubdualvalues !=
NULL )
1764 *varubdualvalues = problem->varubdualvalues;
1769 if( problem->primalvalues !=
NULL )
1788 statistics->niterations = problem->niterations;
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
SCIP_RETCODE SCIPincludeNlpSolverFilterSQP(SCIP *scip)
SCIP_RETCODE SCIPnlpiOracleEvalObjectiveValue(SCIP *scip, SCIP_NLPIORACLE *oracle, const SCIP_Real *x, SCIP_Real *objval)
SCIP_RETCODE SCIPnlpiOracleChgLinearCoefs(SCIP *scip, SCIP_NLPIORACLE *oracle, int considx, int nentries, const int *varidxs, const SCIP_Real *newcoefs)
SCIP_RETCODE SCIPnlpiOracleChgVarBounds(SCIP *scip, SCIP_NLPIORACLE *oracle, int nvars, const int *indices, const SCIP_Real *lbs, const SCIP_Real *ubs)
SCIP_RETCODE SCIPnlpiOracleAddConstraints(SCIP *scip, SCIP_NLPIORACLE *oracle, int nconss, const SCIP_Real *lhss, const SCIP_Real *rhss, const int *nlininds, int *const *lininds, SCIP_Real *const *linvals, SCIP_EXPR **exprs, const char **consnames)
SCIP_Bool SCIPnlpiOracleIsConstraintNonlinear(SCIP_NLPIORACLE *oracle, int considx)
SCIP_RETCODE SCIPnlpiOracleDelVarSet(SCIP *scip, SCIP_NLPIORACLE *oracle, int *delstats)
SCIP_RETCODE SCIPnlpiOracleCreate(SCIP *scip, SCIP_NLPIORACLE **oracle)
SCIP_RETCODE SCIPnlpiOracleGetJacobianSparsity(SCIP *scip, SCIP_NLPIORACLE *oracle, const int **offset, const int **col)
SCIP_RETCODE SCIPnlpiOracleGetHessianLagSparsity(SCIP *scip, SCIP_NLPIORACLE *oracle, const int **offset, const int **col)
SCIP_RETCODE SCIPnlpiOracleEvalObjectiveGradient(SCIP *scip, SCIP_NLPIORACLE *oracle, const SCIP_Real *x, SCIP_Bool isnewx, SCIP_Real *objval, SCIP_Real *objgrad)
SCIP_RETCODE SCIPnlpiOracleResetEvalTime(SCIP *scip, SCIP_NLPIORACLE *oracle)
SCIP_RETCODE SCIPnlpiOracleSetObjective(SCIP *scip, SCIP_NLPIORACLE *oracle, const SCIP_Real constant, int nlin, const int *lininds, const SCIP_Real *linvals, SCIP_EXPR *expr)
SCIP_Real SCIPnlpiOracleGetConstraintRhs(SCIP_NLPIORACLE *oracle, int considx)
SCIP_Real SCIPnlpiOracleGetEvalTime(SCIP *scip, SCIP_NLPIORACLE *oracle)
SCIP_RETCODE SCIPnlpiOracleChgConsSides(SCIP *scip, SCIP_NLPIORACLE *oracle, int nconss, const int *indices, const SCIP_Real *lhss, const SCIP_Real *rhss)
SCIP_Real SCIPnlpiOracleGetConstraintLhs(SCIP_NLPIORACLE *oracle, int considx)
SCIP_RETCODE SCIPnlpiOracleAddVars(SCIP *scip, SCIP_NLPIORACLE *oracle, int nvars, const SCIP_Real *lbs, const SCIP_Real *ubs, const char **varnames)
int SCIPnlpiOracleGetNVars(SCIP_NLPIORACLE *oracle)
int SCIPnlpiOracleGetNConstraints(SCIP_NLPIORACLE *oracle)
SCIP_RETCODE SCIPnlpiOracleEvalHessianLag(SCIP *scip, SCIP_NLPIORACLE *oracle, const SCIP_Real *x, SCIP_Bool isnewx_obj, SCIP_Bool isnewx_cons, SCIP_Real objfactor, const SCIP_Real *lambda, SCIP_Real *hessian)
SCIP_RETCODE SCIPnlpiOracleEvalJacobian(SCIP *scip, SCIP_NLPIORACLE *oracle, const SCIP_Real *x, SCIP_Bool isnewx, SCIP_Real *convals, SCIP_Real *jacobi)
SCIP_RETCODE SCIPnlpiOracleDelConsSet(SCIP *scip, SCIP_NLPIORACLE *oracle, int *delstats)
SCIP_RETCODE SCIPnlpiOracleSetProblemName(SCIP *scip, SCIP_NLPIORACLE *oracle, const char *name)
SCIP_RETCODE SCIPnlpiOracleChgObjConstant(SCIP *scip, SCIP_NLPIORACLE *oracle, SCIP_Real objconstant)
SCIP_RETCODE SCIPnlpiOracleEvalConstraintValue(SCIP *scip, SCIP_NLPIORACLE *oracle, int considx, const SCIP_Real *x, SCIP_Real *conval)
const SCIP_Real * SCIPnlpiOracleGetVarLbs(SCIP_NLPIORACLE *oracle)
const SCIP_Real * SCIPnlpiOracleGetVarUbs(SCIP_NLPIORACLE *oracle)
SCIP_RETCODE SCIPnlpiOracleFree(SCIP *scip, SCIP_NLPIORACLE **oracle)
SCIP_RETCODE SCIPnlpiOracleChgExpr(SCIP *scip, SCIP_NLPIORACLE *oracle, int considx, SCIP_EXPR *expr)
const char * SCIPgetSolverDescFilterSQP(void)
const char * SCIPgetSolverNameFilterSQP(void)
SCIP_Bool SCIPisFilterSQPAvailableFilterSQP(void)
SCIP_RETCODE SCIPincludeExternalCodeInformation(SCIP *scip, const char *name, const char *description)
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
#define SCIPallocClearBlockMemory(scip, ptr)
#define SCIPensureBlockMemoryArray(scip, ptr, arraysizeptr, minsize)
#define SCIPallocClearBlockMemoryArray(scip, ptr, num)
int SCIPcalcMemGrowSize(SCIP *scip, int num)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
#define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum)
#define SCIPfreeBlockMemory(scip, ptr)
#define SCIPfreeBlockMemoryArrayNull(scip, ptr, num)
SCIP_RETCODE SCIPincludeNlpi(SCIP *scip, const char *name, const char *description, int priority, SCIP_DECL_NLPICOPY((*nlpicopy)), SCIP_DECL_NLPIFREE((*nlpifree)), SCIP_DECL_NLPIGETSOLVERPOINTER((*nlpigetsolverpointer)), SCIP_DECL_NLPICREATEPROBLEM((*nlpicreateproblem)), SCIP_DECL_NLPIFREEPROBLEM((*nlpifreeproblem)), SCIP_DECL_NLPIGETPROBLEMPOINTER((*nlpigetproblempointer)), SCIP_DECL_NLPIADDVARS((*nlpiaddvars)), SCIP_DECL_NLPIADDCONSTRAINTS((*nlpiaddconstraints)), SCIP_DECL_NLPISETOBJECTIVE((*nlpisetobjective)), SCIP_DECL_NLPICHGVARBOUNDS((*nlpichgvarbounds)), SCIP_DECL_NLPICHGCONSSIDES((*nlpichgconssides)), SCIP_DECL_NLPIDELVARSET((*nlpidelvarset)), SCIP_DECL_NLPIDELCONSSET((*nlpidelconsset)), SCIP_DECL_NLPICHGLINEARCOEFS((*nlpichglinearcoefs)), SCIP_DECL_NLPICHGEXPR((*nlpichgexpr)), SCIP_DECL_NLPICHGOBJCONSTANT((*nlpichgobjconstant)), SCIP_DECL_NLPISETINITIALGUESS((*nlpisetinitialguess)), SCIP_DECL_NLPISOLVE((*nlpisolve)), SCIP_DECL_NLPIGETSOLSTAT((*nlpigetsolstat)), SCIP_DECL_NLPIGETTERMSTAT((*nlpigettermstat)), SCIP_DECL_NLPIGETSOLUTION((*nlpigetsolution)), SCIP_DECL_NLPIGETSTATISTICS((*nlpigetstatistics)), SCIP_NLPIDATA *nlpidata)
SCIP_NLPIDATA * SCIPnlpiGetData(SCIP_NLPI *nlpi)
SCIP_Bool SCIPisSolveInterrupted(SCIP *scip)
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_Real SCIPrandomGetReal(SCIP_RANDNUMGEN *randnumgen, SCIP_Real minrandval, SCIP_Real maxrandval)
SCIPfreeRandom(scip, &heurdata->randnumgen)
SCIPcreateRandom(scip, &heurdata->randnumgen, DEFAULT_RANDSEED, TRUE))
assert(minobj< SCIPgetCutoffbound(scip))
#define BMSallocMemoryArray(ptr, num)
#define BMSfreeMemoryArray(ptr)
#define BMScopyMemoryArray(ptr, source, num)
#define BMSreallocBlockMemoryArray(mem, ptr, oldnum, newnum)
#define BMSclearMemoryArray(ptr, num)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
static SCIP_RETCODE handleNlpParam(SCIP *scip, SCIP_NLPIPROBLEM *nlpiproblem, const SCIP_NLPPARAM param)
static SCIP_TIME gettime(void)
#define WORKSPACEGROWTHFACTOR
static SCIP_RETCODE setupGradients(SCIP *scip, SCIP_NLPIORACLE *oracle, fint **la, int *lasize, real **a)
static SCIP_Real timeelapsed(SCIP_NLPIDATA *nlpidata)
static SCIP_RETCODE processSolveOutcome(SCIP_NLPIDATA *nlpidata, SCIP_NLPIPROBLEM *problem, fint ifail, SCIP_Real feastol, SCIP_Real opttol, real *x, real *lam)
void F77_FUNC(filtersqp, FILTERSQP)
static SCIP_RETCODE setupHessian(SCIP *scip, SCIP_NLPIORACLE *oracle, fint **la, int *lasize)
static SCIP_RETCODE setupStart(SCIP_NLPIDATA *data, SCIP_NLPIPROBLEM *problem, real *x, SCIP_Bool *success)
static SCIP_Bool timelimitreached(SCIP_NLPIDATA *nlpidata, SCIP_NLPIPROBLEM *nlpiproblem)
static void invalidateSolution(SCIP_NLPIPROBLEM *problem)
methods to store an NLP and request function, gradient, and Hessian values
public data structures and miscellaneous methods
public methods for memory management
public methods for message handling
public methods for NLPI solver interfaces
public methods for numerical tolerances
public methods for random numbers
SCIP_NLPPARAM_FASTFAIL fastfail
SCIP_Real * varubdualvalues
SCIP_NLPTERMSTAT termstat
SCIP_Real * consdualvalues
SCIP_Real * varlbdualvalues
#define SCIP_DECL_NLPISOLVE(x)
#define SCIP_DECL_NLPICHGLINEARCOEFS(x)
#define SCIP_DECL_NLPICHGOBJCONSTANT(x)
#define SCIP_NLPPARAM_PRINT(param)
#define SCIP_DECL_NLPIGETSOLUTION(x)
#define SCIP_DECL_NLPISETOBJECTIVE(x)
#define SCIP_DECL_NLPICREATEPROBLEM(x)
#define SCIP_DECL_NLPIGETSTATISTICS(x)
#define SCIP_DECL_NLPIDELCONSSET(x)
#define SCIP_DECL_NLPICHGCONSSIDES(x)
#define SCIP_DECL_NLPIDELVARSET(x)
#define SCIP_DECL_NLPICHGEXPR(x)
#define SCIP_DECL_NLPIADDVARS(x)
enum SCIP_NlpSolStat SCIP_NLPSOLSTAT
#define SCIP_DECL_NLPISETINITIALGUESS(x)
#define SCIP_DECL_NLPIFREEPROBLEM(x)
@ SCIP_NLPTERMSTAT_TIMELIMIT
@ SCIP_NLPTERMSTAT_NUMERICERROR
@ SCIP_NLPTERMSTAT_EVALERROR
@ SCIP_NLPTERMSTAT_LOBJLIMIT
@ SCIP_NLPTERMSTAT_ITERLIMIT
@ SCIP_NLPTERMSTAT_OUTOFMEMORY
@ SCIP_NLPTERMSTAT_INTERRUPT
#define SCIP_DECL_NLPICOPY(x)
#define SCIP_DECL_NLPIGETSOLSTAT(x)
#define SCIP_DECL_NLPICHGVARBOUNDS(x)
#define SCIP_DECL_NLPIFREE(x)
#define SCIP_DECL_NLPIADDCONSTRAINTS(x)
@ SCIP_NLPSOLSTAT_UNBOUNDED
@ SCIP_NLPSOLSTAT_GLOBINFEASIBLE
@ SCIP_NLPSOLSTAT_LOCINFEASIBLE
@ SCIP_NLPSOLSTAT_FEASIBLE
@ SCIP_NLPSOLSTAT_UNKNOWN
#define SCIP_DECL_NLPIGETTERMSTAT(x)
enum SCIP_NlpTermStat SCIP_NLPTERMSTAT
struct SCIP_NlpiData SCIP_NLPIDATA
enum SCIP_Retcode SCIP_RETCODE