Ipopt NLP interface.
This file can only be compiled if Ipopt is available. Otherwise, to resolve public functions, use nlpi_ipopt_dummy.c. Since the dummy code is C instead of C++, it has been moved into a separate file.
Definition in file nlpi_ipopt.cpp.
#include "nlpi/nlpi_ipopt.h"
#include "nlpi/nlpi.h"
#include "nlpi/nlpioracle.h"
#include "nlpi/exprinterpret.h"
#include "scip/interrupt.h"
#include "scip/pub_misc.h"
#include <new>
#include <sstream>
#include "IpoptConfig.h"
#include "IpIpoptApplication.hpp"
#include "IpIpoptCalculatedQuantities.hpp"
#include "IpSolveStatistics.hpp"
#include "IpJournalist.hpp"
#include "IpIpoptData.hpp"
#include "IpTNLPAdapter.hpp"
#include "IpOrigIpoptNLP.hpp"
#include "IpLapack.hpp"
Go to the source code of this file.
Macros | |
#define | NLPI_NAME "ipopt" |
#define | NLPI_DESC "Ipopt interface" |
#define | NLPI_PRIORITY 0 |
#define | DEFAULT_PRINTLEVEL J_STRONGWARNING |
#define | DEFAULT_MAXITER 3000 |
#define | MAXPERTURB 0.01 |
#define | FEASTOLFACTOR 0.05 |
#define | DEFAULT_RANDSEED 71 |
Functions | |
static void | invalidateSolution (SCIP_NLPIPROBLEM *problem) |
static void | setFeastol (SCIP_NLPIPROBLEM *nlpiproblem, SCIP_Real feastol) |
static | SCIP_DECL_NLPICOPY (nlpiCopyIpopt) |
static | SCIP_DECL_NLPIFREE (nlpiFreeIpopt) |
static | SCIP_DECL_NLPIGETSOLVERPOINTER (nlpiGetSolverPointerIpopt) |
static | SCIP_DECL_NLPICREATEPROBLEM (nlpiCreateProblemIpopt) |
static | SCIP_DECL_NLPIFREEPROBLEM (nlpiFreeProblemIpopt) |
SCIP_DECL_NLPIGETPROBLEMPOINTER (nlpiGetProblemPointerIpopt) | |
static | SCIP_DECL_NLPIADDVARS (nlpiAddVarsIpopt) |
static | SCIP_DECL_NLPIADDCONSTRAINTS (nlpiAddConstraintsIpopt) |
static | SCIP_DECL_NLPISETOBJECTIVE (nlpiSetObjectiveIpopt) |
static | SCIP_DECL_NLPICHGVARBOUNDS (nlpiChgVarBoundsIpopt) |
static | SCIP_DECL_NLPICHGCONSSIDES (nlpiChgConsSidesIpopt) |
static | SCIP_DECL_NLPIDELVARSET (nlpiDelVarSetIpopt) |
static | SCIP_DECL_NLPIDELCONSSET (nlpiDelConstraintSetIpopt) |
static | SCIP_DECL_NLPICHGLINEARCOEFS (nlpiChgLinearCoefsIpopt) |
static | SCIP_DECL_NLPICHGQUADCOEFS (nlpiChgQuadraticCoefsIpopt) |
static | SCIP_DECL_NLPICHGEXPRTREE (nlpiChgExprtreeIpopt) |
static | SCIP_DECL_NLPICHGNONLINCOEF (nlpiChgNonlinCoefIpopt) |
static | SCIP_DECL_NLPICHGOBJCONSTANT (nlpiChgObjConstantIpopt) |
static | SCIP_DECL_NLPISETINITIALGUESS (nlpiSetInitialGuessIpopt) |
static | SCIP_DECL_NLPISOLVE (nlpiSolveIpopt) |
static | SCIP_DECL_NLPIGETSOLSTAT (nlpiGetSolstatIpopt) |
static | SCIP_DECL_NLPIGETTERMSTAT (nlpiGetTermstatIpopt) |
static | SCIP_DECL_NLPIGETSOLUTION (nlpiGetSolutionIpopt) |
static | SCIP_DECL_NLPIGETSTATISTICS (nlpiGetStatisticsIpopt) |
static | SCIP_DECL_NLPIGETWARMSTARTSIZE (nlpiGetWarmstartSizeIpopt) |
static | SCIP_DECL_NLPIGETWARMSTARTMEMO (nlpiGetWarmstartMemoIpopt) |
static | SCIP_DECL_NLPISETWARMSTARTMEMO (nlpiSetWarmstartMemoIpopt) |
static | SCIP_DECL_NLPIGETINTPAR (nlpiGetIntParIpopt) |
static | SCIP_DECL_NLPISETINTPAR (nlpiSetIntParIpopt) |
static | SCIP_DECL_NLPIGETREALPAR (nlpiGetRealParIpopt) |
static | SCIP_DECL_NLPISETREALPAR (nlpiSetRealParIpopt) |
static | SCIP_DECL_NLPIGETSTRINGPAR (nlpiGetStringParIpopt) |
static | SCIP_DECL_NLPISETSTRINGPAR (nlpiSetStringParIpopt) |
static | SCIP_DECL_NLPISETMESSAGEHDLR (nlpiSetMessageHdlrIpopt) |
SCIP_RETCODE | SCIPcreateNlpSolverIpopt (BMS_BLKMEM *blkmem, SCIP_NLPI **nlpi) |
const char * | SCIPgetSolverNameIpopt (void) |
const char * | SCIPgetSolverDescIpopt (void) |
SCIP_Bool | SCIPisIpoptAvailableIpopt (void) |
void * | SCIPgetIpoptApplicationPointerIpopt (SCIP_NLPIPROBLEM *nlpiproblem) |
void * | SCIPgetNlpiOracleIpopt (SCIP_NLPIPROBLEM *nlpiproblem) |
void | SCIPsetModifiedDefaultSettingsIpopt (SCIP_NLPI *nlpi, const char *optionsstring) |
SCIP_RETCODE | LapackDsyev (SCIP_Bool computeeigenvectors, int N, SCIP_Real *a, SCIP_Real *w) |
static SCIP_RETCODE | SCIPsolveLinearProb3 (SCIP_Real *A, SCIP_Real *b, SCIP_Real *x, SCIP_Bool *success) |
SCIP_RETCODE | SCIPsolveLinearProb (int N, SCIP_Real *A, SCIP_Real *b, SCIP_Real *x, SCIP_Bool *success) |
Variables | |
static const int | convcheck_nchecks = 3 |
static const int | convcheck_startiter = 10 |
static const int | convcheck_maxiter [convcheck_nchecks] = { 5, 15, 30 } |
static const SCIP_Real | convcheck_minred [convcheck_nchecks] = { 1.0, 0.5, 0.1 } |
#define NLPI_NAME "ipopt" |
short concise name of solver
Definition at line 61 of file nlpi_ipopt.cpp.
Referenced by SCIPcreateNlpSolverIpopt().
#define NLPI_DESC "Ipopt interface" |
description of solver
Definition at line 62 of file nlpi_ipopt.cpp.
Referenced by SCIPcreateNlpSolverIpopt().
#define NLPI_PRIORITY 0 |
#define DEFAULT_PRINTLEVEL J_STRONGWARNING |
default print level of Ipopt
Definition at line 68 of file nlpi_ipopt.cpp.
Referenced by SCIP_DECL_NLPICREATEPROBLEM().
#define DEFAULT_MAXITER 3000 |
default iteration limit for Ipopt
Definition at line 70 of file nlpi_ipopt.cpp.
Referenced by SCIP_DECL_NLPICREATEPROBLEM().
#define MAXPERTURB 0.01 |
maximal perturbation of bounds in starting point heuristic
Definition at line 72 of file nlpi_ipopt.cpp.
Referenced by SCIPsetModifiedDefaultSettingsIpopt().
#define FEASTOLFACTOR 0.05 |
factor for user-given feasibility tolerance to get feasibility tolerance that is actually passed to Ipopt
Definition at line 73 of file nlpi_ipopt.cpp.
Referenced by setFeastol().
#define DEFAULT_RANDSEED 71 |
initial random seed
Definition at line 75 of file nlpi_ipopt.cpp.
Referenced by SCIP_NlpiProblem::SCIP_NlpiProblem().
|
static |
clears the last solution arrays and sets the solstat and termstat to unknown and other, resp.
problem | data structure of problem |
Definition at line 424 of file nlpi_ipopt.cpp.
References BMSfreeMemoryArrayNull, SCIP_NlpiProblem::lastsoldualcons, SCIP_NlpiProblem::lastsoldualvarlb, SCIP_NlpiProblem::lastsoldualvarub, SCIP_NlpiProblem::lastsolinfeas, SCIP_NlpiProblem::lastsolprimals, SCIP_NlpiProblem::lastsolstat, SCIP_NlpiProblem::lasttermstat, NULL, SCIP_INVALID, SCIP_NLPSOLSTAT_UNKNOWN, and SCIP_NLPTERMSTAT_OTHER.
Referenced by SCIP_DECL_NLPIADDCONSTRAINTS(), SCIP_DECL_NLPIADDVARS(), SCIP_DECL_NLPICHGCONSSIDES(), SCIP_DECL_NLPICHGEXPRTREE(), SCIP_DECL_NLPICHGLINEARCOEFS(), SCIP_DECL_NLPICHGNONLINCOEF(), SCIP_DECL_NLPICHGQUADCOEFS(), SCIP_DECL_NLPICHGVARBOUNDS(), SCIP_DECL_NLPIDELCONSSET(), SCIP_DECL_NLPIDELVARSET(), SCIP_DECL_NLPISETOBJECTIVE(), and SCIP_DECL_NLPISOLVE().
|
static |
sets feasibility tolerance parameters in Ipopt
Sets tol and constr_viol_tol to FEASTOLFACTOR*feastol and acceptable_tol and acceptable_viol_tol to feastol. Since the users and Ipopts conception of feasibility may differ, we let Ipopt try to compute solutions that are more accurate (w.r.t. constraint violation) than requested by the user. Only if Ipopt has problems to achieve this accuracy, we also accept solutions that are accurate w.r.t. feastol only. The additional effort for computing a more accurate solution should be small if one can assume fast convergence when close to a local minimizer.
Definition at line 448 of file nlpi_ipopt.cpp.
References FEASTOLFACTOR, and SCIP_NlpiProblem::ipopt.
Referenced by SCIP_DECL_NLPICREATEPROBLEM(), and SCIP_DECL_NLPISETREALPAR().
|
static |
copy method of NLP interface (called when SCIP copies plugins)
input:
Definition at line 475 of file nlpi_ipopt.cpp.
References NULL, SCIP_CALL, SCIP_NLPPAR_INFINITY, SCIP_OKAY, SCIPcreateNlpSolverIpopt(), SCIPnlpiGetData(), SCIPnlpiSetMessageHdlr(), and SCIPnlpiSetRealPar().
|
static |
destructor of NLP interface to free nlpi data
input:
Definition at line 506 of file nlpi_ipopt.cpp.
References NULL, SCIP_OKAY, and SCIPnlpiGetData().
|
static |
gets pointer for NLP solver to do dirty stuff
input:
return: void pointer to solver
Definition at line 528 of file nlpi_ipopt.cpp.
References NULL.
|
static |
creates a problem instance
input:
Definition at line 543 of file nlpi_ipopt.cpp.
References DEFAULT_MAXITER, DEFAULT_PRINTLEVEL, NULL, SCIP_CALL, SCIP_DEFAULT_FEASTOL, SCIP_ERROR, SCIP_NOMEMORY, SCIP_OKAY, SCIPerrorMessage, SCIPnlpiGetData(), SCIPnlpiOracleCreate(), SCIPnlpiOracleSetInfinity(), SCIPnlpiOracleSetProblemName(), and setFeastol().
|
static |
free a problem instance
input:
Definition at line 640 of file nlpi_ipopt.cpp.
References BMSfreeMemoryArrayNull, NULL, SCIP_CALL, SCIP_OKAY, and SCIPnlpiOracleFree().
SCIP_DECL_NLPIGETPROBLEMPOINTER | ( | nlpiGetProblemPointerIpopt | ) |
gets pointer to solver-internal problem instance to do dirty stuff
input:
return: void pointer to problem instance
Definition at line 671 of file nlpi_ipopt.cpp.
References NULL.
|
static |
add variables
input:
Definition at line 690 of file nlpi_ipopt.cpp.
References BMSfreeMemoryArrayNull, invalidateSolution(), NULL, SCIP_CALL, SCIP_OKAY, SCIPnlpiOracleAddVars(), and TRUE.
|
static |
add constraints
quadratic coefficiens: row oriented matrix for each constraint
input:
Definition at line 735 of file nlpi_ipopt.cpp.
References invalidateSolution(), NULL, SCIP_CALL, SCIP_OKAY, SCIPnlpiOracleAddConstraints(), and TRUE.
|
static |
sets or overwrites objective, a minimization problem is expected
May change sparsity pattern.
input:
Definition at line 775 of file nlpi_ipopt.cpp.
References invalidateSolution(), NULL, SCIP_CALL, SCIP_OKAY, SCIPnlpiOracleSetObjective(), and TRUE.
|
static |
change variable bounds
input:
Definition at line 803 of file nlpi_ipopt.cpp.
References invalidateSolution(), NULL, SCIP_CALL, SCIP_OKAY, and SCIPnlpiOracleChgVarBounds().
|
static |
change constraint bounds
input:
Definition at line 827 of file nlpi_ipopt.cpp.
References invalidateSolution(), NULL, SCIP_CALL, SCIP_OKAY, and SCIPnlpiOracleChgConsSides().
|
static |
delete a set of variables
input:
output:
Definition at line 852 of file nlpi_ipopt.cpp.
References BMSfreeMemoryArrayNull, invalidateSolution(), NULL, SCIP_CALL, SCIP_OKAY, SCIPnlpiOracleDelVarSet(), and TRUE.
|
static |
delete a set of constraints
input:
output:
Definition at line 879 of file nlpi_ipopt.cpp.
References invalidateSolution(), NULL, SCIP_CALL, SCIP_OKAY, SCIPnlpiOracleDelConsSet(), and TRUE.
|
static |
change one linear coefficient in a constraint or objective
input:
return: Error if coefficient did not exist before
Definition at line 907 of file nlpi_ipopt.cpp.
References invalidateSolution(), NULL, SCIP_CALL, SCIP_OKAY, and SCIPnlpiOracleChgLinearCoefs().
|
static |
change one coefficient in the quadratic part of a constraint or objective
input:
return: Error if coefficient did not exist before
Definition at line 931 of file nlpi_ipopt.cpp.
References invalidateSolution(), NULL, SCIP_CALL, SCIP_OKAY, and SCIPnlpiOracleChgQuadCoefs().
|
static |
replaces the expression tree of a constraint or objective
input:
Definition at line 952 of file nlpi_ipopt.cpp.
References invalidateSolution(), NULL, SCIP_CALL, SCIP_OKAY, and SCIPnlpiOracleChgExprtree().
|
static |
change the value of one parameter in the nonlinear part
input:
return: Error if parameter does not exist
Definition at line 976 of file nlpi_ipopt.cpp.
References invalidateSolution(), NULL, SCIP_CALL, SCIP_OKAY, and SCIPnlpiOracleChgExprParam().
|
static |
change the constant offset in the objective
input:
Definition at line 996 of file nlpi_ipopt.cpp.
References NULL, SCIP_CALL, SCIP_OKAY, and SCIPnlpiOracleChgObjConstant().
|
static |
sets initial guess for primal variables
input:
Definition at line 1018 of file nlpi_ipopt.cpp.
References BMScopyMemoryArray, BMSduplicateMemoryArray, BMSfreeMemoryArrayNull, NULL, SCIP_NOMEMORY, SCIP_OKAY, and SCIPnlpiOracleGetNVars().
|
static |
tries to solve NLP
input:
Definition at line 1051 of file nlpi_ipopt.cpp.
References FALSE, invalidateSolution(), NULL, SCIP_ERROR, SCIP_EXPRINTCAPABILITY_FUNCVALUE, SCIP_EXPRINTCAPABILITY_GRADIENT, SCIP_EXPRINTCAPABILITY_HESSIAN, SCIP_INVALID, SCIP_NLPSOLSTAT_UNKNOWN, SCIP_NLPTERMSTAT_EVALERR, SCIP_NLPTERMSTAT_OTHER, SCIP_NOMEMORY, SCIP_OKAY, SCIPdebugMessage, SCIPerrorMessage, SCIPexprintGetCapability(), SCIPnlpiOracleGetEvalCapability(), and SCIPnlpiOracleGetMaxDegree().
|
static |
gives solution status
input:
return: Solution Status
Definition at line 1158 of file nlpi_ipopt.cpp.
References NULL.
|
static |
gives termination reason
input:
return: Termination Status
Definition at line 1175 of file nlpi_ipopt.cpp.
References NULL.
|
static |
gives primal and dual solution values
input:
Definition at line 1194 of file nlpi_ipopt.cpp.
|
static |
gives solve statistics
input:
output:
Definition at line 1225 of file nlpi_ipopt.cpp.
References NULL, SCIP_OKAY, SCIPnlpStatisticsSetNIterations(), and SCIPnlpStatisticsSetTotalTime().
|
static |
gives required size of a buffer to store a warmstart object
input:
output:
Definition at line 1247 of file nlpi_ipopt.cpp.
References SCIP_ERROR, and SCIPerrorMessage.
|
static |
stores warmstart information in buffer
Required size of buffer should have been obtained by SCIPnlpiGetWarmstartSize before.
input:
output:
Definition at line 1266 of file nlpi_ipopt.cpp.
References SCIP_ERROR, and SCIPerrorMessage.
|
static |
sets warmstart information in solver
Write warmstart to buffer.
input:
Definition at line 1282 of file nlpi_ipopt.cpp.
References SCIP_OKAY, SCIPABORT, and SCIPerrorMessage.
|
static |
gets integer parameter of NLP
input:
output:
Definition at line 1301 of file nlpi_ipopt.cpp.
References NULL, SCIP_NLPPAR_FASTFAIL, SCIP_NLPPAR_FEASTOL, SCIP_NLPPAR_FROMSCRATCH, SCIP_NLPPAR_INFINITY, SCIP_NLPPAR_ITLIM, SCIP_NLPPAR_LOBJLIM, SCIP_NLPPAR_OPTFILE, SCIP_NLPPAR_RELOBJTOL, SCIP_NLPPAR_TILIM, SCIP_NLPPAR_VERBLEVEL, SCIP_OKAY, SCIP_PARAMETERUNKNOWN, SCIP_PARAMETERWRONGTYPE, and SCIPerrorMessage.
|
static |
sets integer parameter of NLP
input:
Definition at line 1397 of file nlpi_ipopt.cpp.
References MIN, NULL, SCIP_NLPPAR_FASTFAIL, SCIP_NLPPAR_FEASTOL, SCIP_NLPPAR_FROMSCRATCH, SCIP_NLPPAR_INFINITY, SCIP_NLPPAR_ITLIM, SCIP_NLPPAR_LOBJLIM, SCIP_NLPPAR_OPTFILE, SCIP_NLPPAR_RELOBJTOL, SCIP_NLPPAR_TILIM, SCIP_NLPPAR_VERBLEVEL, SCIP_OKAY, SCIP_PARAMETERUNKNOWN, SCIP_PARAMETERWRONGTYPE, SCIP_PARAMETERWRONGVAL, SCIPerrorMessage, SCIPmessagePrintWarning(), and SCIPnlpiGetData().
|
static |
gets floating point parameter of NLP
input:
output:
Definition at line 1539 of file nlpi_ipopt.cpp.
References NULL, SCIP_NLPPAR_FASTFAIL, SCIP_NLPPAR_FEASTOL, SCIP_NLPPAR_FROMSCRATCH, SCIP_NLPPAR_INFINITY, SCIP_NLPPAR_ITLIM, SCIP_NLPPAR_LOBJLIM, SCIP_NLPPAR_OPTFILE, SCIP_NLPPAR_RELOBJTOL, SCIP_NLPPAR_TILIM, SCIP_NLPPAR_VERBLEVEL, SCIP_OKAY, SCIP_PARAMETERUNKNOWN, SCIP_PARAMETERWRONGTYPE, SCIPerrorMessage, SCIPnlpiGetData(), and SCIPnlpiOracleGetInfinity().
|
static |
sets floating point parameter of NLP
input:
Definition at line 1636 of file nlpi_ipopt.cpp.
References NULL, SCIP_NLPPAR_FASTFAIL, SCIP_NLPPAR_FEASTOL, SCIP_NLPPAR_FROMSCRATCH, SCIP_NLPPAR_INFINITY, SCIP_NLPPAR_ITLIM, SCIP_NLPPAR_LOBJLIM, SCIP_NLPPAR_OPTFILE, SCIP_NLPPAR_RELOBJTOL, SCIP_NLPPAR_TILIM, SCIP_NLPPAR_VERBLEVEL, SCIP_OKAY, SCIP_PARAMETERUNKNOWN, SCIP_PARAMETERWRONGTYPE, SCIP_PARAMETERWRONGVAL, SCIPerrorMessage, SCIPmessagePrintWarning(), SCIPnlpiGetData(), SCIPnlpiOracleSetInfinity(), and setFeastol().
|
static |
gets string parameter of NLP
input:
output:
Definition at line 1769 of file nlpi_ipopt.cpp.
References NULL, SCIP_NLPPAR_FASTFAIL, SCIP_NLPPAR_FEASTOL, SCIP_NLPPAR_FROMSCRATCH, SCIP_NLPPAR_INFINITY, SCIP_NLPPAR_ITLIM, SCIP_NLPPAR_LOBJLIM, SCIP_NLPPAR_OPTFILE, SCIP_NLPPAR_RELOBJTOL, SCIP_NLPPAR_TILIM, SCIP_NLPPAR_VERBLEVEL, SCIP_OKAY, SCIP_PARAMETERUNKNOWN, SCIP_PARAMETERWRONGTYPE, and SCIPerrorMessage.
|
static |
sets string parameter of NLP
input:
Definition at line 1858 of file nlpi_ipopt.cpp.
References NULL, SCIP_ERROR, SCIP_NLPPAR_FASTFAIL, SCIP_NLPPAR_FEASTOL, SCIP_NLPPAR_FROMSCRATCH, SCIP_NLPPAR_INFINITY, SCIP_NLPPAR_ITLIM, SCIP_NLPPAR_LOBJLIM, SCIP_NLPPAR_OPTFILE, SCIP_NLPPAR_RELOBJTOL, SCIP_NLPPAR_TILIM, SCIP_NLPPAR_VERBLEVEL, SCIP_OKAY, SCIP_PARAMETERUNKNOWN, SCIP_PARAMETERWRONGTYPE, SCIPerrorMessage, and TRUE.
|
static |
sets message handler for message output
input:
Definition at line 1954 of file nlpi_ipopt.cpp.
References NULL, SCIP_OKAY, and SCIPnlpiGetData().
|
static |
solves a linear problem of the form Ax = b for a regular matrix 3*3 A
A | matrix data on input (size 3*3); filled column-wise |
b | right hand side vector (size 3) |
x | buffer to store solution (size 3) |
success | pointer to store if the solving routine was successful |
Definition at line 2817 of file nlpi_ipopt.cpp.
References BMScopyMemoryArray, FALSE, NULL, SCIP_OKAY, SCIP_Real, SCIPerrorMessage, and TRUE.
Referenced by SCIPsolveLinearProb().
|
static |
number of convergence checks
Definition at line 102 of file nlpi_ipopt.cpp.
Referenced by SCIP_NlpiProblem::SCIP_NlpiProblem(), and SCIPsetModifiedDefaultSettingsIpopt().
|
static |
iteration where to start convergence checking
Definition at line 103 of file nlpi_ipopt.cpp.
Referenced by SCIPsetModifiedDefaultSettingsIpopt().
|
static |
maximal number of iterations to achieve each convergence check
Definition at line 104 of file nlpi_ipopt.cpp.
Referenced by SCIPsetModifiedDefaultSettingsIpopt().
|
static |
minimal required infeasibility reduction in each convergence check
Definition at line 105 of file nlpi_ipopt.cpp.
Referenced by SCIPsetModifiedDefaultSettingsIpopt().