55#if defined(_MSC_VER) && defined(SCIP_THREADSAFE)
63#define NLPI_NAME "filtersqp"
64#define NLPI_DESC "Sequential Quadratic Programming trust region solver by R. Fletcher and S. Leyffer"
65#define NLPI_PRIORITY -1000
67#define RANDSEED 26051979
68#define MAXPERTURB 0.01
70#define WORKSPACEGROWTHFACTOR 2
72#define OPTTOLFACTOR 0.5
146#ifdef FNAME_LCASE_DECOR
147# define F77_FUNC(name,NAME) name ## _
149#ifdef FNAME_UCASE_DECOR
150# define F77_FUNC(name,NAME) NAME ## _
152#ifdef FNAME_LCASE_NODECOR
153# define F77_FUNC(name,NAME) name
155#ifdef FNAME_UCASE_NODECOR
156# define F77_FUNC(name,NAME) NAME
270#ifdef SCIP_THREADSAFE
308 assert(
now.sec >= nlpidata->starttime.sec);
309 assert(
now.sec > nlpidata->starttime.sec ||
now.usec >= nlpidata->starttime.usec);
311 return (SCIP_Real)(
now.sec - nlpidata->starttime.sec) + 1
e-6 * (SCIP_Real)(
now.usec - nlpidata->starttime.usec);
344 SCIPdebugMsg(problem->
scip,
"interrupted or timelimit reached, issuing arithmetic exception in objfun\n");
382 for(
j = 0;
j < *m; ++
j )
387 SCIPdebugMsg(problem->
scip,
"arithmetic exception in confun for constraint %d\n",
j);
431 SCIPdebugMsg(problem->
scip,
"arithmetic exception in gradient for constraints\n");
436 SCIPdebugMsg(problem->
scip,
"arithmetic exception in gradient for objective\n");
500 for(
i = 0;
i < *m; ++
i )
501 lambda[
i] = -lam[*n+
i];
512 for(
i = 0;
i < nnz + *n + 2; ++
i )
570 (*la)[0] =
nvars+nnz+1;
578 for(
i = 0;
i < nnz; ++
i )
587#ifdef SCIP_MORE_DEBUG
589 printf(
"la[%2d] = %2d\n",
i, (*la)[
i]);
634 *lasize = 1 + nnz +
nvars + 1;
640 for(
i = 0;
i < nnz; ++
i )
641 (*la)[1+
i] = col[
i] + 1;
644 for( v = 0; v <=
nvars; ++v )
645 (*la)[(*la)[0]+v] =
offset[v] + 1;
649#ifdef SCIP_MORE_DEBUG
650 for(
i = 0;
i < 1 + nnz +
nvars + 1; ++
i )
651 printf(
"lw[%2d] = %2d\n",
i, (*la)[
i]);
680 for(
i = 0;
i < n; ++
i )
688 SCIPdebugMsg(problem->
scip,
"FilterSQP started without initial primal values; make up something by projecting 0 onto variable bounds and perturb\n");
690 if( data->randnumgen ==
NULL )
695 for(
i = 0;
i < n; ++
i )
720 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");
758 SCIPdebugMsg(
scip,
"fast fail parameter not supported by FilterSQP interface yet. Ignored.\n");
867 if( problem->
rstat[4] <= feastol )
875 if( problem->
rstat[4] <= feastol )
895 if( problem->
rstat[4] <= feastol )
940 if( (*nlpidata)->randnumgen !=
NULL )
959 (*problem)->scip =
scip;
980 if( (*problem)->oracle !=
NULL )
1026 problem->warmstart =
FALSE;
1033 if( problem->primalvalues !=
NULL )
1038 if( problem->varlbdualvalues !=
NULL )
1043 if( problem->varubdualvalues !=
NULL )
1048 if( problem->x !=
NULL )
1053 if( problem->lam !=
NULL )
1058 if( problem->bl !=
NULL )
1065 if( problem->s !=
NULL )
1074 if( problem->bl !=
NULL )
1084 for(
i = nconss-1;
i >= 0; --
i )
1124 problem->warmstart =
FALSE;
1131 if( problem->consdualvalues !=
NULL )
1136 if( problem->c !=
NULL )
1141 if( problem->lam !=
NULL )
1146 if( problem->bl !=
NULL )
1155 if( problem->s !=
NULL )
1164 if( problem->bl !=
NULL )
1171 for(
i = 0;
i < nconss; ++
i )
1223 if( problem->bl !=
NULL )
1229 problem->bl[indices[
i]] = lbs[
i];
1230 problem->bu[indices[
i]] = ubs[
i];
1250 if( problem->bl !=
NULL )
1257 for(
i = 0;
i < nconss; ++
i )
1281 problem->warmstart =
FALSE;
1308 problem->warmstart =
FALSE;
1362 problem->cstype[
idxcons] = expr !=
NULL ?
'N' :
'L';
1397 if( primalvalues !=
NULL )
1399 if( problem->initguess ==
NULL )
1448 if( param.timelimit == 0.0 )
1451 problem->niterations = 0;
1452 problem->solvetime = 0.0;
1464 iprint = param.verblevel;
1467 if( !param.warmstart )
1468 problem->warmstart =
FALSE;
1480 ifail = problem->warmstart ? -1 : 0;
1485 if( problem->warmstart )
1486 memset(problem->istat+1, 0,
sizeof(problem->istat)-
sizeof(*problem->istat));
1488 memset(problem->istat, 0,
sizeof(problem->istat));
1489 memset(problem->rstat, 0,
sizeof(problem->rstat));
1490 problem->niterations = 0;
1492 if( problem->x ==
NULL )
1496 if( problem->c ==
NULL )
1500 if( problem->lam ==
NULL )
1508 if( problem->s ==
NULL )
1513 if( problem->la ==
NULL )
1519 maxa = problem->la[0]-1;
1521 if( problem->hessiannz ==
NULL )
1528 if( problem->bl ==
NULL )
1539 for(
i = 0;
i < m; ++
i )
1564 lh1 = problem->hessiannz[0]-1 + 8 + 2*n + m;
1572 if( !problem->warmstart )
1583#ifdef SCIP_THREADSAFE
1595 for( nruns = 1; ; ++nruns )
1597 maxiter = param.iterlimit - problem->niterations;
1601 &
maxf, &
mlp, &problem->mxwk, &problem->mxiwk,
1603 problem->x, problem->c, &f, &problem->fmin, problem->bl,
1604 problem->bu, problem->s, problem->a, problem->la, problem->ws,
1605 problem->lws, problem->lam, problem->cstype, user,
1606 iuser, &maxiter, problem->istat,
1609 problem->niterations += problem->istat[1];
1615 if(
ifail < 8 && (
ifail != 0 || problem->rstat[0] <= param.opttol) )
1618 if( param.verblevel > 0 )
1620 SCIPinfoMessage(
scip,
NULL,
"FilterSQP terminated with status %d in run %d, absolute KKT violation is %g\n",
ifail, nruns, problem->rstat[0]);
1626 if( param.verblevel > 0 )
1636 if( param.verblevel > 0 )
1649 if( param.verblevel > 0 )
1656 epsfactor = param.opttol / problem->rstat[0];
1661 if( param.verblevel > 0 )
1707#ifdef SCIP_THREADSAFE
1722 return problem->solstat;
1731 return problem->termstat;
1740 if( primalvalues !=
NULL )
1744 *primalvalues = problem->primalvalues;
1747 if( consdualvalues !=
NULL )
1751 *consdualvalues = problem->consdualvalues;
1754 if( varlbdualvalues !=
NULL )
1758 *varlbdualvalues = problem->varlbdualvalues;
1761 if( varubdualvalues !=
NULL )
1765 *varubdualvalues = problem->varubdualvalues;
1770 if( problem->primalvalues !=
NULL )
1789 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 methods for message output
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