53#include "worhp/worhp.h"
55#if WORHP_MAJOR < 2 && WORHP_MINOR < 10
56#error "Require at least Worhp 1.10"
59#define NLPI_DESC "Worhp interface"
60#define NLPI_PRIORITY_IP 0
61#define NLPI_PRIORITY_SQP -2000
63#define DEFAULT_VERBLEVEL 0
64#define DEFAULT_SCALEDKKT TRUE
65#define DEFAULT_RANDSEED 107
67#define MAXPERTURB 0.01
148 switch( problem->
cnt->status )
183 SCIPdebugMsg(
scip,
"Worhp failed because of a NaN value in an evaluation!\n");
196 SCIPdebugMsg(
scip,
"Worhp failed because of a numerical error during optimization!\n");
207 SCIPdebugMsg(
scip,
"Worhp failed because maximal number of calls or iterations is reached!\n");
239 SCIPdebugMsg(
scip,
"Worhp failed because of convergence against infeasible stationary point!\n");
249 SCIPdebugMsg(
scip,
"Worhp failed because of convergence against infeasible stationary point!\n");
259 SCIPdebugMsg(
scip,
"Worhp failed because of regularization of Hessian matrix failed!\n");
278 SCIPdebugMsg(
scip,
"Worhp terminated successfully with a feasible point but KKT are not met!\n");
289 SCIPdebugMsg(
scip,
"Worhp terminated successfully with a feasible point but KKT are violated in unscaled space!\n");
298 SCIPdebugMsg(
scip,
"Worhp terminated at feasible solution without further progress!\n");
307 SCIPdebugMsg(
scip,
"Worhp terminated at feasible solution, optimality was not required!\n");
317 SCIPdebugMsg(
scip,
"Worhp terminated at acceptable solution due to limit or error!\n");
327 SCIPdebugMsg(
scip,
"Worhp previously found acceptable solution but terminated due to limit or error!\n");
336 SCIPdebugMsg(
scip,
"Worhp found acceptable solution but terminated due no further progress!\n");
346 SCIPdebugMsg(
scip,
"Worhp found acceptable solution but search direction is small or zero!\n");
357 SCIPdebugMsg(
scip,
"Worhp found acceptable solution but terminated perhaps due to nondifferentiability, unboundedness or at Fritz John point!\n");
365 SCIPerrorMessage(
"Worhp returned with unknown solution status %d\n", problem->
cnt->status);
375 if( problem->
opt->m > 0 )
381 if( problem->
opt->n > 0 )
399 for(
i = 0;
i < problem->
opt->n; ++
i )
401 if( problem->
opt->Lambda[
i] <= 0.0 )
440#ifdef SCIP_DEBUG_USERF
445 for(
i = 0;
i < problem->
opt->n; ++
i )
470#ifdef SCIP_DEBUG_USERG
475 for(
i = 0;
i < problem->
opt->n; ++
i )
478 for(
i = 0;
i < problem->
opt->m; ++
i )
504 problem->
wsp->DF.val) );
507 if( problem->
wsp->ScaleObj != 1.0 )
510 for(
i = 0;
i < problem->
opt->n; ++
i )
511 problem->
wsp->DF.val[
i] *= problem->
wsp->ScaleObj;
514#ifdef SCIP_DEBUG_USERDF
519 for(
i = 0;
i < problem->
opt->n; ++
i )
522 for(
i = 0;
i < problem->
opt->n; ++
i )
523 printf(
" DF[%d] = %g\n",
i, problem->
wsp->DF.val[
i]);
555 for(
i = 0;
i < problem->
wsp->DG.nnz; ++
i )
560#ifdef SCIP_DEBUG_USERDG
562 for(
i = 0;
i < problem->
opt->n; ++
i )
564 for(
i = 0;
i < problem->
wsp->DG.nnz; ++
i )
565 printf(
" DG[%d] = %g\n",
i, problem->
wsp->DG.val[
i]);
608 for(
i = 0;
i < problem->
wsp->HM.nnz; ++
i )
611 if( problem->
wsp->HM.perm[
i] - 1 >= nnonz )
612 problem->
wsp->HM.val[
i] = 0.0;
619 for(
i = 0;
i < problem->
opt->n; ++
i )
621 for(
i = 0;
i < problem->
wsp->HM.nnz; ++
i )
622 printf(
" HM[%d] = %g\n",
i, problem->
wsp->HM.val[
i]);
652 const SCIP_Real* lbs;
653 const SCIP_Real* ubs;
681 wsp->DF.nnz = opt->n;
685 wsp->DG.nnz =
offset[opt->m];
696 for(
i = 0;
i < opt->n; ++
i )
730 for(
i = 0;
i < opt->n; ++
i )
737 for(
i = 0;
i < opt->m; ++
i )
757 for(
i = 0;
i < opt->n; ++
i )
759 wsp->DF.row[
i] =
i + 1;
775 for(
i = 0;
i < opt->m; ++
i )
779 wsp->DG.row[nnonz] =
i + 1;
780 wsp->DG.col[nnonz] = cols[
j] + 1;
784 assert(nnonz == wsp->DG.nnz);
791 if( problem->
par->UserHM || problem->
par->FidifHM || problem->
par->BFGSmethod > 1 )
802 for(
i = 0;
i < opt->n; ++
i )
808 problem->
wsp->HM.row[nnonz] =
i + 1;
809 problem->
wsp->HM.col[nnonz] = cols[
j] + 1;
819 problem->
wsp->HM.row[
k] =
i + 1;
820 problem->
wsp->HM.col[
k] =
i + 1;
832 for(
i = 0;
i < wsp->HM.nnz; ++
i )
848 const SCIP_Real* lbs;
849 const SCIP_Real* ubs;
866 for(
i = 0;
i < problem->
opt->n; ++
i )
868 problem->
opt->XL[
i] = lbs[
i];
869 problem->
opt->XU[
i] = ubs[
i];
873 for(
i = 0;
i < problem->
opt->m; ++
i )
894 if( problem->
opt->initialised )
917 par->Algorithm = nlpidata->useip ? 2 : 1;
924 SCIPdebugMsg(
scip,
"warmstart parameter not supported by Worhp interface yet. Ignored.\n");
934 SCIPdebugMsg(
scip,
"fastfail parameter not supported by Worhp interface yet. Ignored.\n");
942 par->NLPprint =
nlpparam.verblevel - 1;
946 par->CheckValuesDF =
TRUE;
947 par->CheckValuesDG =
TRUE;
948 par->CheckValuesHM =
TRUE;
999 (*problem)->firstrun =
TRUE;
1008 WorhpPreInit((*problem)->opt, (*problem)->wsp, (*problem)->par, (*problem)->cnt);
1024 if( (*problem)->opt !=
NULL )
1041 if( (*problem)->oracle !=
NULL )
1066 problem->firstrun =
TRUE;
1086 problem->firstrun =
TRUE;
1105 problem->firstrun =
TRUE;
1119#ifdef SCIP_DISABLED_CODE
1129#ifdef SCIP_DISABLED_CODE
1136 int index = indices[
i];
1140 if(
REALABS(lbs[
i] - ubs[
i]) <= problem->feastol )
1141 problem->firstrun =
TRUE;
1144 problem->firstrun =
TRUE;
1169 for(
i = 0;
i < nconss; ++
i )
1171 int index = indices[
i];
1199 problem->firstrun =
TRUE;
1215 problem->firstrun =
TRUE;
1231 problem->firstrun =
TRUE;
1247 problem->firstrun =
TRUE;
1273 if( primalvalues !=
NULL )
1275 if( !problem->initguess )
1298 OptVar* opt = problem->opt;
1299 Params* par = problem->par;
1307 if( param.timelimit == 0.0 )
1310 problem->lastniter = 0;
1311 problem->lasttime = 0.0;
1318 problem->lastniter = -1;
1319 problem->lasttime = -1.0;
1321 if( param.verblevel == 0 )
1334 if( problem->firstrun )
1338 problem->firstrun =
FALSE;
1358 if( problem->initguess !=
NULL )
1368 SCIPdebugMsg(
scip,
"Worhp started without initial primal values; make up starting guess by projecting 0 onto variable bounds\n");
1370 for(
i = 0;
i < problem->opt->n; ++
i )
1387 for(
i = 0;
i < problem->opt->n; ++
i )
1409 Worhp(opt, wsp, par, cnt);
1510 problem->lastniter = wsp->MajorIter;
1523 return problem->lastsolstat;
1533 return problem->lasttermstat;
1542 if( primalvalues !=
NULL )
1543 *primalvalues = problem->lastprimal;
1545 if( consdualvalues !=
NULL )
1546 *consdualvalues = problem->lastdualcons;
1548 if( varlbdualvalues !=
NULL )
1549 *varlbdualvalues = problem->lastduallb;
1551 if( varubdualvalues !=
NULL )
1552 *varubdualvalues = problem->lastdualub;
1556 if( problem->lastprimal !=
NULL )
1576 statistics->niterations = problem->lastniter;
1579 statistics->consviol = problem->wsp->FeasOrigMax;
1601 nlpidata->useip = useip;
1604 (
void)
setenv(
"WORHP_DISABLE_KEYBOARD_HANDLER",
"1", 0);
1606#if DEFAULT_VERBLEVEL == 0
1664 return "Nonlinear programming solver developed at Research Institute Steinbeis (www.worhp.de)";
methods to interpret (evaluate) an expression "fast"
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
SCIP_RETCODE SCIPincludeNlpSolverWorhp(SCIP *scip, SCIP_Bool useip)
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 SCIPnlpiOracleEvalConstraintValues(SCIP *scip, SCIP_NLPIORACLE *oracle, const SCIP_Real *x, SCIP_Real *convals)
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 SCIPnlpiOraclePrintProblem(SCIP *scip, SCIP_NLPIORACLE *oracle, FILE *file)
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)
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 * SCIPgetSolverNameWorhp(void)
const char * SCIPgetSolverDescWorhp(void)
SCIP_Bool SCIPisWorhpAvailableWorhp(void)
SCIP_RETCODE SCIPincludeExternalCodeInformation(SCIP *scip, const char *name, const char *description)
#define SCIPfreeMemoryArrayNull(scip, ptr)
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
#define SCIPallocClearBlockMemory(scip, ptr)
#define SCIPduplicateMemoryArray(scip, ptr, source, num)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
#define SCIPfreeBlockMemory(scip, ptr)
#define SCIPfreeBlockMemoryArrayNull(scip, ptr, num)
#define SCIPallocBlockMemory(scip, ptr)
#define SCIPduplicateBlockMemoryArray(scip, ptr, source, 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_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPrandomGetReal(SCIP_RANDNUMGEN *randnumgen, SCIP_Real minrandval, SCIP_Real maxrandval)
int SCIPsnprintf(char *t, int len, const char *s,...)
SCIPfreeRandom(scip, &heurdata->randnumgen)
SCIPcreateRandom(scip, &heurdata->randnumgen, DEFAULT_RANDSEED, TRUE))
assert(minobj< SCIPgetCutoffbound(scip))
methods for catching the user CTRL-C interrupt
#define BMScopyMemoryArray(ptr, source, num)
static SCIP_RETCODE userG(SCIP *scip, SCIP_NLPIPROBLEM *problem)
static void noprint(int mode, const char s[])
static SCIP_RETCODE userDG(SCIP *scip, SCIP_NLPIPROBLEM *problem)
static SCIP_RETCODE userDF(SCIP *scip, SCIP_NLPIPROBLEM *problem)
static SCIP_RETCODE userHM(SCIP *scip, SCIP_NLPIPROBLEM *problem)
#define NLPI_PRIORITY_SQP
static SCIP_RETCODE userF(SCIP *scip, SCIP_NLPIPROBLEM *problem)
static SCIP_RETCODE initWorhp(SCIP *scip, SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem)
static SCIP_RETCODE updateWorhp(SCIP_NLPIPROBLEM *problem)
static void invalidateSolution(SCIP *scip, SCIP_NLPIPROBLEM *problem)
static SCIP_RETCODE freeWorhp(SCIP_NLPIPROBLEM *problem)
static SCIP_RETCODE handleNlpParam(SCIP *scip, SCIP_NLPI *nlpi, Params *par, const SCIP_NLPPARAM nlpparam)
#define DEFAULT_SCALEDKKT
static SCIP_RETCODE evaluateWorhpRun(SCIP *scip, 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_RANDNUMGEN * randnumgen
SCIP_NLPTERMSTAT lasttermstat
SCIP_NLPSOLSTAT lastsolstat
#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_LICENSEERROR
@ 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