Detailed Description
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 "scip/nlpi_ipopt.h"
#include "scip/nlpioracle.h"
#include "scip/exprinterpret.h"
#include "scip/scip_nlpi.h"
#include "scip/scip_randnumgen.h"
#include "scip/scip_mem.h"
#include "scip/scip_message.h"
#include "scip/scip_general.h"
#include "scip/scip_numerics.h"
#include "scip/scip_param.h"
#include "scip/scip_solve.h"
#include "scip/scip_copy.h"
#include "scip/pub_misc.h"
#include "scip/pub_paramset.h"
#include <new>
#include <sstream>
#include <cstring>
#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.
Data Structures | |
struct | SCIP_NlpiProblem |
Macros | |
#define | NLPI_NAME "ipopt" |
#define | NLPI_DESC "Ipopt interface" |
#define | NLPI_PRIORITY 1000 |
#define | MAXPERTURB 0.01 |
#define | FEASTOLFACTOR 0.9 |
#define | DEFAULT_RANDSEED 71 |
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 } |
static const char * | ipopt_int_params [] |
integer parameters of Ipopt to make available via SCIP parameters More... | |
static const char * | ipopt_string_params [] |
string parameters of Ipopt to make available via SCIP parameters More... | |
struct SCIP_NlpiData | F77_FUNC |
Macro Definition Documentation
◆ NLPI_NAME
#define NLPI_NAME "ipopt" |
short concise name of solver
Definition at line 90 of file nlpi_ipopt.cpp.
Referenced by SCIP_DECL_NLPICREATEPROBLEM(), and SCIPincludeNlpSolverIpopt().
◆ NLPI_DESC
#define NLPI_DESC "Ipopt interface" |
description of solver
Definition at line 91 of file nlpi_ipopt.cpp.
Referenced by SCIPincludeNlpSolverIpopt().
◆ NLPI_PRIORITY
#define NLPI_PRIORITY 1000 |
◆ MAXPERTURB
#define MAXPERTURB 0.01 |
maximal perturbation of bounds in starting point heuristic
Definition at line 94 of file nlpi_ipopt.cpp.
Referenced by ensureStartingPoint().
◆ FEASTOLFACTOR
#define FEASTOLFACTOR 0.9 |
factor for user-given feasibility tolerance to get feasibility tolerance that is actually passed to Ipopt
Definition at line 95 of file nlpi_ipopt.cpp.
Referenced by handleNlpParam().
◆ DEFAULT_RANDSEED
#define DEFAULT_RANDSEED 71 |
initial random seed
Definition at line 97 of file nlpi_ipopt.cpp.
Referenced by ensureStartingPoint().
Function Documentation
◆ invalidateSolved()
|
static |
sets status codes to mark that last NLP solve is no longer valid (usually because the NLP changed)
- Parameters
-
problem data structure of problem
Definition at line 470 of file nlpi_ipopt.cpp.
References SCIP_NlpiProblem::lastniter, SCIP_NlpiProblem::lasttime, SCIP_INVALID, SCIP_NLPSOLSTAT_UNKNOWN, SCIP_NLPTERMSTAT_OTHER, SCIP_NlpiProblem::solboundviol, SCIP_NlpiProblem::solconsviol, SCIP_NlpiProblem::solobjval, SCIP_NlpiProblem::solstat, and SCIP_NlpiProblem::termstat.
Referenced by invalidateSolution(), SCIP_DECL_NLPICHGCONSSIDES(), SCIP_DECL_NLPICHGEXPR(), SCIP_DECL_NLPICHGLINEARCOEFS(), SCIP_DECL_NLPICHGVARBOUNDS(), SCIP_DECL_NLPIDELCONSSET(), SCIP_DECL_NLPIDELVARSET(), SCIP_DECL_NLPISETOBJECTIVE(), and SCIP_DECL_NLPISOLVE().
◆ invalidateSolution()
|
static |
sets solution values to be invalid and calls invalidateSolved()
- Parameters
-
problem data structure of problem
Definition at line 485 of file nlpi_ipopt.cpp.
References invalidateSolved(), NULL, SCIP_NlpiProblem::soldualgiven, SCIP_NlpiProblem::soldualvalid, SCIP_NlpiProblem::solprimalgiven, and SCIP_NlpiProblem::solprimalvalid.
Referenced by SCIP_DECL_NLPIADDVARS().
◆ ensureStartingPoint()
|
static |
makes sure a starting point (initial guess) is available
- Parameters
-
scip SCIP data structure problem data structure of problem warmstart whether a warmstart has been requested
Definition at line 501 of file nlpi_ipopt.cpp.
References DEFAULT_RANDSEED, MAX, MAXPERTURB, NULL, SCIP_NlpiProblem::oracle, SCIP_NlpiProblem::randnumgen, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBlockMemoryArray, SCIPcreateRandom(), SCIPdebugMsg, SCIPnlpiOracleGetNVars(), SCIPnlpiOracleGetVarLbs(), SCIPnlpiOracleGetVarUbs(), SCIPrandomGetReal(), SCIP_NlpiProblem::soldualcons, SCIP_NlpiProblem::soldualgiven, SCIP_NlpiProblem::soldualvalid, SCIP_NlpiProblem::soldualvarlb, SCIP_NlpiProblem::soldualvarub, SCIP_NlpiProblem::solprimalgiven, SCIP_NlpiProblem::solprimals, SCIP_NlpiProblem::solprimalvalid, and TRUE.
Referenced by SCIP_DECL_NLPISOLVE().
◆ handleNlpParam()
|
static |
pass NLP solve parameters to Ipopt
- Parameters
-
scip SCIP data structure nlpidata NLPI data nlpiproblem NLP param solve parameters
Definition at line 571 of file nlpi_ipopt.cpp.
References SCIP_NlpParam::expectinfeas, SCIP_NlpParam::fastfail, SCIP_NlpParam::feastol, FEASTOLFACTOR, SCIP_NlpiProblem::ipopt, SCIP_NlpParam::iterlimit, MAX, NULL, SCIP_NlpParam::opttol, SCIP_NlpiProblem::oracle, SCIP_CALL, SCIP_CALL_ABORT, SCIP_ERROR, SCIP_NLPPARAM_FASTFAIL_OFF, SCIP_OKAY, SCIP_Real, SCIPdebugMsg, SCIPerrorMessage, SCIPfloor(), SCIPinfoMessage(), SCIPisEQ(), SCIPisInfinity(), SCIPnlpiOracleGetConstraintLhs(), SCIPnlpiOracleGetConstraintRhs(), SCIPnlpiOracleGetHessianLagSparsity(), SCIPnlpiOracleGetJacobianSparsity(), SCIPnlpiOracleGetNConstraints(), SCIPnlpiOracleGetNVars(), SCIPnlpiOracleGetVarLbs(), SCIPnlpiOracleGetVarUbs(), SCIPnlpiOracleIsConstraintNonlinear(), SCIPnlpiOracleIsVarNonlinear(), SCIP_NlpParam::solvertol, SCIP_NlpParam::timelimit, SCIP_NlpParam::verblevel, and SCIP_NlpParam::warmstart.
Referenced by SCIP_DECL_NLPISOLVE().
◆ SCIP_DECL_NLPICOPY()
|
static |
copy method of NLP interface (called when SCIP copies plugins)
Definition at line 878 of file nlpi_ipopt.cpp.
References SCIP_CALL, SCIP_OKAY, and SCIPincludeNlpSolverIpopt().
◆ SCIP_DECL_NLPIFREE()
|
static |
destructor of NLP interface to free nlpi data
Definition at line 887 of file nlpi_ipopt.cpp.
◆ SCIP_DECL_NLPIGETSOLVERPOINTER()
|
static |
gets pointer for NLP solver to do dirty stuff
Definition at line 899 of file nlpi_ipopt.cpp.
References SCIP_NlpiProblem::ipopt, and NULL.
◆ SCIP_DECL_NLPICREATEPROBLEM()
|
static |
creates a problem instance
Definition at line 909 of file nlpi_ipopt.cpp.
References ipopt_int_params, ipopt_string_params, NLPI_NAME, NULL, paramname, SCIP_ALLOC, SCIP_CALL, SCIP_ERROR, SCIP_MAXSTRLEN, SCIP_NOMEMORY, SCIP_OKAY, SCIPerrorMessage, SCIPgetParam(), SCIPinfinity(), SCIPnlpiGetData(), SCIPnlpiOracleCreate(), SCIPnlpiOracleSetProblemName(), SCIPparamGetInt(), SCIPparamGetIntDefault(), and SCIPparamGetString().
◆ SCIP_DECL_NLPIFREEPROBLEM()
|
static |
free a problem instance
Definition at line 1026 of file nlpi_ipopt.cpp.
References NULL, SCIP_CALL, SCIP_OKAY, SCIPfreeBlockMemoryArrayNull, SCIPfreeRandom(), SCIPnlpiOracleFree(), SCIPnlpiOracleGetNConstraints(), and SCIPnlpiOracleGetNVars().
◆ SCIP_DECL_NLPIGETPROBLEMPOINTER()
|
static |
gets pointer to solver-internal problem instance to do dirty stuff
Definition at line 1059 of file nlpi_ipopt.cpp.
References SCIP_NlpiProblem::nlp, and NULL.
◆ SCIP_DECL_NLPIADDVARS()
|
static |
add variables
Definition at line 1069 of file nlpi_ipopt.cpp.
References invalidateSolution(), NULL, SCIP_NlpiProblem::oracle, SCIP_NlpiProblem::samestructure, SCIP_CALL, SCIP_OKAY, SCIPfreeBlockMemoryArrayNull, SCIPnlpiOracleAddVars(), SCIPnlpiOracleGetNVars(), SCIP_NlpiProblem::soldualvarlb, SCIP_NlpiProblem::soldualvarub, and SCIP_NlpiProblem::solprimals.
◆ SCIP_DECL_NLPIADDCONSTRAINTS()
|
static |
add constraints
Definition at line 1093 of file nlpi_ipopt.cpp.
References NULL, SCIP_NlpiProblem::oracle, SCIP_NlpiProblem::samestructure, SCIP_CALL, SCIP_OKAY, SCIPfreeBlockMemoryArrayNull, SCIPnlpiOracleAddConstraints(), SCIPnlpiOracleGetNConstraints(), SCIP_NlpiProblem::soldualcons, SCIP_NlpiProblem::soldualgiven, and SCIP_NlpiProblem::soldualvalid.
◆ SCIP_DECL_NLPISETOBJECTIVE()
|
static |
sets or overwrites objective, a minimization problem is expected
Definition at line 1116 of file nlpi_ipopt.cpp.
References invalidateSolved(), NULL, SCIP_NlpiProblem::oracle, SCIP_NlpiProblem::samestructure, SCIP_CALL, SCIP_OKAY, SCIPnlpiOracleIsConstraintNonlinear(), and SCIPnlpiOracleSetObjective().
◆ SCIP_DECL_NLPICHGVARBOUNDS()
|
static |
change variable bounds
Definition at line 1139 of file nlpi_ipopt.cpp.
References invalidateSolved(), MAX, NULL, SCIP_NlpiProblem::oracle, SCIP_NlpiProblem::samestructure, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPisInfinity(), SCIPnlpiOracleChgVarBounds(), SCIPnlpiOracleGetVarLbs(), SCIPnlpiOracleGetVarUbs(), SCIP_NlpiProblem::solprimals, and SCIP_NlpiProblem::solprimalvalid.
◆ SCIP_DECL_NLPICHGCONSSIDES()
|
static |
change constraint bounds
Definition at line 1183 of file nlpi_ipopt.cpp.
References invalidateSolved(), NULL, SCIP_NlpiProblem::oracle, SCIP_NlpiProblem::samestructure, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPisInfinity(), SCIPnlpiOracleChgConsSides(), SCIPnlpiOracleGetConstraintLhs(), and SCIPnlpiOracleGetConstraintRhs().
◆ SCIP_DECL_NLPIDELVARSET()
|
static |
delete a set of variables
Definition at line 1216 of file nlpi_ipopt.cpp.
References invalidateSolved(), NULL, SCIP_NlpiProblem::oracle, SCIP_NlpiProblem::samestructure, SCIP_CALL, SCIP_OKAY, SCIPnlpiOracleDelVarSet(), SCIPnlpiOracleGetNVars(), SCIPreallocBlockMemoryArray, SCIP_NlpiProblem::soldualvalid, SCIP_NlpiProblem::soldualvarlb, SCIP_NlpiProblem::soldualvarub, SCIP_NlpiProblem::solprimals, and SCIP_NlpiProblem::solprimalvalid.
◆ SCIP_DECL_NLPIDELCONSSET()
|
static |
delete a set of constraints
Definition at line 1278 of file nlpi_ipopt.cpp.
References invalidateSolved(), NULL, SCIP_NlpiProblem::oracle, SCIP_NlpiProblem::samestructure, SCIP_CALL, SCIP_OKAY, SCIPnlpiOracleDelConsSet(), SCIPnlpiOracleGetNConstraints(), SCIPreallocBlockMemoryArray, SCIP_NlpiProblem::soldualcons, and SCIP_NlpiProblem::soldualvalid.
◆ SCIP_DECL_NLPICHGLINEARCOEFS()
|
static |
change one linear coefficient in a constraint or objective
Definition at line 1323 of file nlpi_ipopt.cpp.
References invalidateSolved(), NULL, SCIP_NlpiProblem::oracle, SCIP_NlpiProblem::samestructure, SCIP_CALL, SCIP_OKAY, and SCIPnlpiOracleChgLinearCoefs().
◆ SCIP_DECL_NLPICHGEXPR()
|
static |
replaces the expression tree of a constraint or objective
Definition at line 1339 of file nlpi_ipopt.cpp.
References invalidateSolved(), NULL, SCIP_NlpiProblem::oracle, SCIP_NlpiProblem::samestructure, SCIP_CALL, SCIP_OKAY, and SCIPnlpiOracleChgExpr().
◆ SCIP_DECL_NLPICHGOBJCONSTANT()
|
static |
change the constant offset in the objective
Definition at line 1355 of file nlpi_ipopt.cpp.
References NULL, SCIP_NlpiProblem::oracle, SCIP_CALL, SCIP_INVALID, SCIP_OKAY, SCIP_Real, SCIPnlpiOracleChgObjConstant(), SCIPnlpiOracleGetObjectiveConstant(), and SCIP_NlpiProblem::solobjval.
◆ SCIP_DECL_NLPISETINITIALGUESS()
|
static |
sets initial guess for primal variables
Definition at line 1375 of file nlpi_ipopt.cpp.
References BMScopyMemoryArray, NULL, SCIP_NlpiProblem::oracle, SCIP_CALL, SCIP_OKAY, SCIPallocBlockMemoryArray, SCIPdebugMsg, SCIPnlpiOracleGetNConstraints(), SCIPnlpiOracleGetNVars(), SCIP_NlpiProblem::soldualcons, SCIP_NlpiProblem::soldualgiven, SCIP_NlpiProblem::soldualvalid, SCIP_NlpiProblem::soldualvarlb, SCIP_NlpiProblem::soldualvarub, SCIP_NlpiProblem::solprimalgiven, SCIP_NlpiProblem::solprimals, and SCIP_NlpiProblem::solprimalvalid.
◆ SCIP_DECL_NLPISOLVE()
|
static |
tries to solve NLP
Definition at line 1446 of file nlpi_ipopt.cpp.
References ensureStartingPoint(), SCIP_NlpiProblem::firstrun, handleNlpParam(), invalidateSolved(), SCIP_NlpiProblem::ipopt, SCIP_NlpiProblem::lastniter, SCIP_NlpiProblem::lasttime, SCIP_NlpiProblem::nlp, NULL, SCIP_NlpiProblem::oracle, SCIP_NlpiProblem::samestructure, SCIP_CALL, SCIP_ERROR, SCIP_EXPRINTCAPABILITY_FUNCVALUE, SCIP_EXPRINTCAPABILITY_GRADIENT, SCIP_EXPRINTCAPABILITY_HESSIAN, SCIP_NLPPARAM_PRINT, SCIP_NLPSOLSTAT_FEASIBLE, SCIP_NLPSOLSTAT_UNKNOWN, SCIP_NLPTERMSTAT_EVALERROR, SCIP_NLPTERMSTAT_OTHER, SCIP_NLPTERMSTAT_OUTOFMEMORY, SCIP_NLPTERMSTAT_TIMELIMIT, SCIP_NOMEMORY, SCIP_OKAY, SCIPdebugMsg, SCIPerrorMessage, SCIPexprintGetCapability(), SCIPgetSubscipDepth(), SCIPinfoMessage(), SCIPnlpiGetData(), SCIPnlpiOracleGetEvalCapability(), SCIPnlpiOracleGetProblemName(), SCIPnlpiOracleResetEvalTime(), SCIP_NlpiProblem::soldualvalid, SCIP_NlpiProblem::solprimalvalid, SCIP_NlpiProblem::solstat, SCIP_NlpiProblem::termstat, and SCIP_NlpiProblem::warmstart.
◆ SCIP_DECL_NLPIGETSOLSTAT()
|
static |
gives solution status
Definition at line 1659 of file nlpi_ipopt.cpp.
References NULL, and SCIP_NlpiProblem::solstat.
◆ SCIP_DECL_NLPIGETTERMSTAT()
|
static |
gives termination reason
Definition at line 1669 of file nlpi_ipopt.cpp.
References NULL, and SCIP_NlpiProblem::termstat.
◆ SCIP_DECL_NLPIGETSOLUTION()
|
static |
gives primal and dual solution values
Definition at line 1679 of file nlpi_ipopt.cpp.
References NULL, SCIP_OKAY, SCIP_NlpiProblem::soldualcons, SCIP_NlpiProblem::soldualvarlb, SCIP_NlpiProblem::soldualvarub, SCIP_NlpiProblem::solobjval, and SCIP_NlpiProblem::solprimals.
◆ SCIP_DECL_NLPIGETSTATISTICS()
|
static |
gives solve statistics
Definition at line 1704 of file nlpi_ipopt.cpp.
References SCIP_NlpiProblem::lastniter, SCIP_NlpiProblem::lasttime, NULL, SCIP_NlpiProblem::oracle, SCIP_OKAY, SCIPnlpiOracleGetEvalTime(), SCIP_NlpiProblem::solboundviol, and SCIP_NlpiProblem::solconsviol.
◆ solveLinearProb3()
|
static |
solves a linear problem of the form Ax = b for a regular matrix 3*3 A
- Parameters
-
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 2692 of file nlpi_ipopt.cpp.
References BMScopyMemoryArray, FALSE, NULL, SCIP_OKAY, SCIP_Real, SCIPdebugMessage, and TRUE.
Referenced by SCIPsolveLinearEquationsIpopt().
Variable Documentation
◆ convcheck_nchecks
|
static |
number of convergence checks
Definition at line 129 of file nlpi_ipopt.cpp.
Referenced by SCIP_NlpiProblem::SCIP_NlpiProblem(), and SCIPgetNlpiOracleIpopt().
◆ convcheck_startiter
|
static |
iteration where to start convergence checking
Definition at line 130 of file nlpi_ipopt.cpp.
Referenced by SCIPgetNlpiOracleIpopt().
◆ convcheck_maxiter
|
static |
maximal number of iterations to achieve each convergence check
Definition at line 131 of file nlpi_ipopt.cpp.
Referenced by SCIPgetNlpiOracleIpopt().
◆ convcheck_minred
|
static |
minimal required infeasibility reduction in each convergence check
Definition at line 132 of file nlpi_ipopt.cpp.
Referenced by SCIPgetNlpiOracleIpopt().
◆ ipopt_int_params
|
static |
integer parameters of Ipopt to make available via SCIP parameters
Definition at line 135 of file nlpi_ipopt.cpp.
Referenced by SCIP_DECL_NLPICREATEPROBLEM(), and SCIPincludeNlpSolverIpopt().
◆ ipopt_string_params
|
static |
string parameters of Ipopt to make available via SCIP parameters
Definition at line 139 of file nlpi_ipopt.cpp.
Referenced by SCIP_DECL_NLPICREATEPROBLEM(), and SCIPincludeNlpSolverIpopt().
◆ F77_FUNC
struct SCIP_NlpiData F77_FUNC |