Scippy

SCIP

Solving Constraint Integer Programs

Detailed Description

Ipopt NLP interface.

Author
Stefan Vigerske
Benjamin Müller

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 "scip/pub_message.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
 

Functions

static void invalidateSolved (SCIP_NLPIPROBLEM *problem)
 
static void invalidateSolution (SCIP_NLPIPROBLEM *problem)
 
static SCIP_RETCODE ensureStartingPoint (SCIP *scip, SCIP_NLPIPROBLEM *problem, SCIP_Bool &warmstart)
 
static SCIP_RETCODE handleNlpParam (SCIP *scip, SCIP_NLPIDATA *nlpidata, SCIP_NLPIPROBLEM *nlpiproblem, const SCIP_NLPPARAM param)
 pass NLP solve parameters to Ipopt More...
 
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)
 
static 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_NLPICHGEXPR (nlpiChgExprIpopt)
 
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)
 
SCIP_RETCODE SCIPincludeNlpSolverIpopt (SCIP *scip)
 
const char * SCIPgetSolverNameIpopt (void)
 
const char * SCIPgetSolverDescIpopt (void)
 
SCIP_Bool SCIPisIpoptAvailableIpopt (void)
 
void * SCIPgetNlpiOracleIpopt (SCIP_NLPIPROBLEM *nlpiproblem)
 
SCIP_RETCODE SCIPcallLapackDsyevIpopt (SCIP_Bool computeeigenvectors, int N, SCIP_Real *a, SCIP_Real *w)
 
static SCIP_RETCODE solveLinearProb3 (SCIP_Real *A, SCIP_Real *b, SCIP_Real *x, SCIP_Bool *success)
 
SCIP_RETCODE SCIPsolveLinearEquationsIpopt (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 }
 
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...
 

Macro Definition Documentation

◆ NLPI_NAME

#define NLPI_NAME   "ipopt"

short concise name of solver

Definition at line 100 of file nlpi_ipopt.cpp.

◆ NLPI_DESC

#define NLPI_DESC   "Ipopt interface"

description of solver

Definition at line 101 of file nlpi_ipopt.cpp.

◆ NLPI_PRIORITY

#define NLPI_PRIORITY   1000

priority

Definition at line 102 of file nlpi_ipopt.cpp.

◆ MAXPERTURB

#define MAXPERTURB   0.01

maximal perturbation of bounds in starting point heuristic

Definition at line 104 of file nlpi_ipopt.cpp.

◆ FEASTOLFACTOR

#define FEASTOLFACTOR   0.9

factor for user-given feasibility tolerance to get feasibility tolerance that is actually passed to Ipopt

Definition at line 105 of file nlpi_ipopt.cpp.

◆ DEFAULT_RANDSEED

#define DEFAULT_RANDSEED   71

initial random seed

Definition at line 107 of file nlpi_ipopt.cpp.

Function Documentation

◆ invalidateSolved()

◆ invalidateSolution()

static void invalidateSolution ( SCIP_NLPIPROBLEM problem)
static

sets solution values to be invalid and calls invalidateSolved()

Parameters
problemdata structure of problem

Definition at line 495 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()

◆ handleNlpParam()

◆ SCIP_DECL_NLPICOPY()

static SCIP_DECL_NLPICOPY ( nlpiCopyIpopt  )
static

copy method of NLP interface (called when SCIP copies plugins)

Definition at line 888 of file nlpi_ipopt.cpp.

References SCIP_CALL, SCIP_OKAY, and SCIPincludeNlpSolverIpopt().

◆ SCIP_DECL_NLPIFREE()

static SCIP_DECL_NLPIFREE ( nlpiFreeIpopt  )
static

destructor of NLP interface to free nlpi data

Definition at line 897 of file nlpi_ipopt.cpp.

References NULL, and SCIP_OKAY.

◆ SCIP_DECL_NLPIGETSOLVERPOINTER()

static SCIP_DECL_NLPIGETSOLVERPOINTER ( nlpiGetSolverPointerIpopt  )
static

gets pointer for NLP solver to do dirty stuff

Definition at line 909 of file nlpi_ipopt.cpp.

References SCIP_NlpiProblem::ipopt, and NULL.

◆ SCIP_DECL_NLPICREATEPROBLEM()

◆ SCIP_DECL_NLPIFREEPROBLEM()

static SCIP_DECL_NLPIFREEPROBLEM ( nlpiFreeProblemIpopt  )
static

◆ SCIP_DECL_NLPIGETPROBLEMPOINTER()

static SCIP_DECL_NLPIGETPROBLEMPOINTER ( nlpiGetProblemPointerIpopt  )
static

gets pointer to solver-internal problem instance to do dirty stuff

Definition at line 1069 of file nlpi_ipopt.cpp.

References SCIP_NlpiProblem::nlp, and NULL.

◆ SCIP_DECL_NLPIADDVARS()

◆ SCIP_DECL_NLPIADDCONSTRAINTS()

◆ SCIP_DECL_NLPISETOBJECTIVE()

static SCIP_DECL_NLPISETOBJECTIVE ( nlpiSetObjectiveIpopt  )
static

sets or overwrites objective, a minimization problem is expected

Definition at line 1126 of file nlpi_ipopt.cpp.

References invalidateSolved(), NULL, SCIP_NlpiProblem::oracle, SCIP_NlpiProblem::samestructure, SCIP_CALL, SCIP_OKAY, SCIPnlpiOracleIsConstraintNonlinear(), and SCIPnlpiOracleSetObjective().

◆ SCIP_DECL_NLPICHGVARBOUNDS()

◆ SCIP_DECL_NLPICHGCONSSIDES()

static SCIP_DECL_NLPICHGCONSSIDES ( nlpiChgConsSidesIpopt  )
static

◆ SCIP_DECL_NLPIDELVARSET()

◆ SCIP_DECL_NLPIDELCONSSET()

◆ SCIP_DECL_NLPICHGLINEARCOEFS()

static SCIP_DECL_NLPICHGLINEARCOEFS ( nlpiChgLinearCoefsIpopt  )
static

change one linear coefficient in a constraint or objective

Definition at line 1333 of file nlpi_ipopt.cpp.

References invalidateSolved(), NULL, SCIP_NlpiProblem::oracle, SCIP_NlpiProblem::samestructure, SCIP_CALL, SCIP_OKAY, and SCIPnlpiOracleChgLinearCoefs().

◆ SCIP_DECL_NLPICHGEXPR()

static SCIP_DECL_NLPICHGEXPR ( nlpiChgExprIpopt  )
static

replaces the expression tree of a constraint or objective

Definition at line 1349 of file nlpi_ipopt.cpp.

References invalidateSolved(), NULL, SCIP_NlpiProblem::oracle, SCIP_NlpiProblem::samestructure, SCIP_CALL, SCIP_OKAY, and SCIPnlpiOracleChgExpr().

◆ SCIP_DECL_NLPICHGOBJCONSTANT()

static SCIP_DECL_NLPICHGOBJCONSTANT ( nlpiChgObjConstantIpopt  )
static

◆ SCIP_DECL_NLPISETINITIALGUESS()

◆ SCIP_DECL_NLPISOLVE()

◆ SCIP_DECL_NLPIGETSOLSTAT()

static SCIP_DECL_NLPIGETSOLSTAT ( nlpiGetSolstatIpopt  )
static

gives solution status

Definition at line 1669 of file nlpi_ipopt.cpp.

References NULL, and SCIP_NlpiProblem::solstat.

◆ SCIP_DECL_NLPIGETTERMSTAT()

static SCIP_DECL_NLPIGETTERMSTAT ( nlpiGetTermstatIpopt  )
static

gives termination reason

Definition at line 1679 of file nlpi_ipopt.cpp.

References NULL, and SCIP_NlpiProblem::termstat.

◆ SCIP_DECL_NLPIGETSOLUTION()

static SCIP_DECL_NLPIGETSOLUTION ( nlpiGetSolutionIpopt  )
static

◆ SCIP_DECL_NLPIGETSTATISTICS()

static SCIP_DECL_NLPIGETSTATISTICS ( nlpiGetStatisticsIpopt  )
static

◆ solveLinearProb3()

static SCIP_RETCODE solveLinearProb3 ( SCIP_Real A,
SCIP_Real b,
SCIP_Real x,
SCIP_Bool success 
)
static

solves a linear problem of the form Ax = b for a regular matrix 3*3 A

Parameters
Amatrix data on input (size 3*3); filled column-wise
bright hand side vector (size 3)
xbuffer to store solution (size 3)
successpointer to store if the solving routine was successful

Definition at line 2712 of file nlpi_ipopt.cpp.

References b, BMScopyMemoryArray, FALSE, NULL, SCIP_OKAY, SCIP_Real, SCIPdebugMessage, TRUE, and x.

Referenced by SCIPsolveLinearEquationsIpopt().

Variable Documentation

◆ convcheck_nchecks

const int convcheck_nchecks = 3
static

number of convergence checks

Definition at line 139 of file nlpi_ipopt.cpp.

◆ convcheck_startiter

const int convcheck_startiter = 10
static

iteration where to start convergence checking

Definition at line 140 of file nlpi_ipopt.cpp.

◆ convcheck_maxiter

const int convcheck_maxiter[convcheck_nchecks] = { 5, 15, 30 }
static

maximal number of iterations to achieve each convergence check

Definition at line 141 of file nlpi_ipopt.cpp.

◆ convcheck_minred

const SCIP_Real convcheck_minred[convcheck_nchecks] = { 1.0, 0.5, 0.1 }
static

minimal required infeasibility reduction in each convergence check

Definition at line 142 of file nlpi_ipopt.cpp.

◆ ipopt_int_params

const char* ipopt_int_params[]
static
Initial value:
=
{ "print_level" }

integer parameters of Ipopt to make available via SCIP parameters

Definition at line 145 of file nlpi_ipopt.cpp.

Referenced by SCIP_DECL_NLPICREATEPROBLEM(), and SCIPincludeNlpSolverIpopt().

◆ ipopt_string_params

const char* ipopt_string_params[]
static
Initial value:
=
{ "linear_solver",
"hsllib",
"pardisolib",
"linear_system_scaling",
"nlp_scaling_method",
"mu_strategy",
"hessian_approximation"
}

string parameters of Ipopt to make available via SCIP parameters

Definition at line 149 of file nlpi_ipopt.cpp.

Referenced by SCIP_DECL_NLPICREATEPROBLEM(), and SCIPincludeNlpSolverIpopt().