SCIP Doxygen Documentation
Loading...
Searching...
No Matches

Detailed Description

implementation of NLPI oracle

Author
Stefan Vigerske

Definition in file nlpioracle.c.

#include "scip/scip.h"
#include "scip/nlpioracle.h"
#include "scip/exprinterpret.h"
#include "scip/expr_pow.h"
#include "scip/expr_varidx.h"
#include <string.h>

Go to the source code of this file.

Data Structures

struct  SCIP_NlpiOracleCons
struct  SCIP_NlpiOracle

Functions

Local functions
static SCIP_RETCODE ensureVarsSize (SCIP *scip, SCIP_NLPIORACLE *oracle, int minsize)
static SCIP_RETCODE ensureConssSize (SCIP *scip, SCIP_NLPIORACLE *oracle, int minsize)
static SCIP_RETCODE ensureConsLinSize (SCIP *scip, SCIP_NLPIORACLECONS *cons, int minsize)
static SCIP_RETCODE ensureIntArraySize (SCIP *scip, int **intarray, int *len, int minsize)
static SCIP_RETCODE ensureClearBoolArraySize (SCIP *scip, SCIP_Bool **boolarray, int *len, int minsize)
static void invalidateJacobiSparsity (SCIP *scip, SCIP_NLPIORACLE *oracle)
static void invalidateHessianLagSparsity (SCIP *scip, SCIP_NLPIORACLE *oracle)
static SCIP_RETCODE updateVariableCounts (SCIP *scip, SCIP_NLPIORACLE *oracle, int factor, int nlinidxs, const int *linidxs, SCIP_EXPR *expr)
static void sortLinearCoefficients (int *nidxs, int *idxs, SCIP_Real *coefs)
static SCIP_RETCODE createConstraint (SCIP *scip, SCIP_NLPIORACLE *oracle, SCIP_NLPIORACLECONS **cons, int nlinidxs, const int *linidxs, const SCIP_Real *lincoefs, SCIP_EXPR *expr, SCIP_Real lhs, SCIP_Real rhs, const char *name)
static SCIP_RETCODE freeConstraint (SCIP *scip, SCIP_NLPIORACLE *oracle, SCIP_NLPIORACLECONS **cons, SCIP_Bool updatevarcount)
static SCIP_RETCODE freeConstraints (SCIP *scip, SCIP_NLPIORACLE *oracle)
static SCIP_RETCODE moveVariable (SCIP *scip, SCIP_NLPIORACLE *oracle, int fromidx, int toidx)
static void freeVariables (SCIP *scip, SCIP_NLPIORACLE *oracle)
static void mapIndices (int *indexmap, int nindices, int *indices)
static void clearDeletedLinearElements (int **linidxs, SCIP_Real **coefs, int *nidxs)
static SCIP_RETCODE evalFunctionValue (SCIP *scip, SCIP_NLPIORACLE *oracle, SCIP_NLPIORACLECONS *cons, const SCIP_Real *x, SCIP_Real *val)
static SCIP_RETCODE evalFunctionGradient (SCIP *scip, SCIP_NLPIORACLE *oracle, SCIP_NLPIORACLECONS *cons, const SCIP_Real *x, SCIP_Bool isnewx, SCIP_Real *RESTRICT val, SCIP_Real *RESTRICT grad)
static SCIP_RETCODE computeRowJacobianSparsity (SCIP *scip, SCIP_NLPIORACLE *oracle, int *nnz, int *nvarnnz)
static SCIP_RETCODE hessLagSparsitySetNzFlagForExpr (SCIP *scip, SCIP_NLPIORACLE *oracle, int **nz, int *len, int *nnz, int *nzcount, SCIP_EXPR *expr, SCIP_EXPRINTDATA *exprintdata, int dim, SCIP_Bool colwise)
static SCIP_RETCODE hessLagAddExpr (SCIP *scip, SCIP_NLPIORACLE *oracle, SCIP_Real weight, const SCIP_Real *x, SCIP_Bool new_x, SCIP_EXPR *expr, SCIP_EXPRINTDATA *exprintdata, int *hesoffset, int *hesnzidcs, SCIP_Real *values, SCIP_Bool colwise)
static void printName (char *buffer, char *name, int idx, char prefix, const char *suffix, SCIP_Bool longnames)
static SCIP_RETCODE printFunction (SCIP *scip, SCIP_NLPIORACLE *oracle, FILE *file, SCIP_NLPIORACLECONS *cons, SCIP_Bool longvarnames)
static SCIP_RETCODE exprIsNonSmooth (SCIP *scip, SCIP_EXPR *expr, SCIP_Bool *nonsmooth)
public function
SCIP_RETCODE SCIPnlpiOracleCreate (SCIP *scip, SCIP_NLPIORACLE **oracle)
SCIP_RETCODE SCIPnlpiOracleFree (SCIP *scip, SCIP_NLPIORACLE **oracle)
SCIP_RETCODE SCIPnlpiOracleSetProblemName (SCIP *scip, SCIP_NLPIORACLE *oracle, const char *name)
const char * SCIPnlpiOracleGetProblemName (SCIP_NLPIORACLE *oracle)
SCIP_RETCODE SCIPnlpiOracleAddVars (SCIP *scip, SCIP_NLPIORACLE *oracle, int nvars, const SCIP_Real *lbs, const SCIP_Real *ubs, const char **varnames)
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_RETCODE SCIPnlpiOracleSetObjective (SCIP *scip, SCIP_NLPIORACLE *oracle, const SCIP_Real constant, int nlin, const int *lininds, const SCIP_Real *linvals, SCIP_EXPR *expr)
SCIP_RETCODE SCIPnlpiOracleChgVarBounds (SCIP *scip, SCIP_NLPIORACLE *oracle, int nvars, const int *indices, const SCIP_Real *lbs, const SCIP_Real *ubs)
SCIP_RETCODE SCIPnlpiOracleChgConsSides (SCIP *scip, SCIP_NLPIORACLE *oracle, int nconss, const int *indices, const SCIP_Real *lhss, const SCIP_Real *rhss)
SCIP_RETCODE SCIPnlpiOracleDelVarSet (SCIP *scip, SCIP_NLPIORACLE *oracle, int *delstats)
SCIP_RETCODE SCIPnlpiOracleDelConsSet (SCIP *scip, SCIP_NLPIORACLE *oracle, int *delstats)
SCIP_RETCODE SCIPnlpiOracleChgLinearCoefs (SCIP *scip, SCIP_NLPIORACLE *oracle, int considx, int nentries, const int *varidxs, const SCIP_Real *newcoefs)
SCIP_RETCODE SCIPnlpiOracleChgExpr (SCIP *scip, SCIP_NLPIORACLE *oracle, int considx, SCIP_EXPR *expr)
SCIP_RETCODE SCIPnlpiOracleChgObjConstant (SCIP *scip, SCIP_NLPIORACLE *oracle, SCIP_Real objconstant)
int SCIPnlpiOracleGetNVars (SCIP_NLPIORACLE *oracle)
int SCIPnlpiOracleGetNConstraints (SCIP_NLPIORACLE *oracle)
const SCIP_RealSCIPnlpiOracleGetVarLbs (SCIP_NLPIORACLE *oracle)
const SCIP_RealSCIPnlpiOracleGetVarUbs (SCIP_NLPIORACLE *oracle)
char ** SCIPnlpiOracleGetVarNames (SCIP_NLPIORACLE *oracle)
SCIP_Bool SCIPnlpiOracleIsVarNonlinear (SCIP *scip, SCIP_NLPIORACLE *oracle, int varidx)
void SCIPnlpiOracleGetVarCounts (SCIP *scip, SCIP_NLPIORACLE *oracle, const int **lincounts, const int **nlcounts)
SCIP_Real SCIPnlpiOracleGetObjectiveConstant (SCIP_NLPIORACLE *oracle)
SCIP_Real SCIPnlpiOracleGetConstraintLhs (SCIP_NLPIORACLE *oracle, int considx)
SCIP_Real SCIPnlpiOracleGetConstraintRhs (SCIP_NLPIORACLE *oracle, int considx)
char * SCIPnlpiOracleGetConstraintName (SCIP_NLPIORACLE *oracle, int considx)
SCIP_Real SCIPnlpiOracleGetConstraintLinearCoef (SCIP_NLPIORACLE *oracle, int considx, int varpos)
SCIP_Bool SCIPnlpiOracleIsConstraintNonlinear (SCIP_NLPIORACLE *oracle, int considx)
SCIP_EXPRINTCAPABILITY SCIPnlpiOracleGetEvalCapability (SCIP *scip, SCIP_NLPIORACLE *oracle)
SCIP_RETCODE SCIPnlpiOracleEvalObjectiveValue (SCIP *scip, SCIP_NLPIORACLE *oracle, const SCIP_Real *x, SCIP_Real *objval)
SCIP_RETCODE SCIPnlpiOracleEvalConstraintValue (SCIP *scip, SCIP_NLPIORACLE *oracle, int considx, const SCIP_Real *x, SCIP_Real *conval)
SCIP_RETCODE SCIPnlpiOracleEvalConstraintValues (SCIP *scip, SCIP_NLPIORACLE *oracle, const SCIP_Real *x, SCIP_Real *convals)
SCIP_RETCODE SCIPnlpiOracleEvalObjectiveGradient (SCIP *scip, SCIP_NLPIORACLE *oracle, const SCIP_Real *x, SCIP_Bool isnewx, SCIP_Real *objval, SCIP_Real *objgrad)
SCIP_RETCODE SCIPnlpiOracleEvalConstraintGradient (SCIP *scip, SCIP_NLPIORACLE *oracle, const int considx, const SCIP_Real *x, SCIP_Bool isnewx, SCIP_Real *conval, SCIP_Real *congrad)
SCIP_RETCODE SCIPnlpiOracleGetJacobianRowSparsity (SCIP *scip, SCIP_NLPIORACLE *oracle, const int **rowoffsets, const int **cols, const SCIP_Bool **colnlflags, int *nnlnz)
SCIP_RETCODE SCIPnlpiOracleGetJacobianColSparsity (SCIP *scip, SCIP_NLPIORACLE *oracle, const int **coloffsets, const int **rows, const SCIP_Bool **rownlflags, int *nnlnz)
SCIP_RETCODE SCIPnlpiOracleGetObjGradientNnz (SCIP *scip, SCIP_NLPIORACLE *oracle, const int **nz, const SCIP_Bool **nlnz, int *nnz, int *nnlnz)
SCIP_RETCODE SCIPnlpiOracleEvalJacobian (SCIP *scip, SCIP_NLPIORACLE *oracle, const SCIP_Real *x, SCIP_Bool isnewx, SCIP_Real *convals, SCIP_Real *jacobi)
SCIP_RETCODE SCIPnlpiOracleGetHessianLagSparsity (SCIP *scip, SCIP_NLPIORACLE *oracle, const int **offset, const int **allnz, SCIP_Bool colwise)
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_Bool colwise)
SCIP_RETCODE SCIPnlpiOracleResetEvalTime (SCIP *scip, SCIP_NLPIORACLE *oracle)
SCIP_Real SCIPnlpiOracleGetEvalTime (SCIP *scip, SCIP_NLPIORACLE *oracle)
SCIP_RETCODE SCIPnlpiOraclePrintProblem (SCIP *scip, SCIP_NLPIORACLE *oracle, FILE *file)
SCIP_RETCODE SCIPnlpiOraclePrintProblemGams (SCIP *scip, SCIP_NLPIORACLE *oracle, SCIP_Real *initval, FILE *file)

Typedef Documentation

◆ SCIP_NLPIORACLECONS

Definition at line 61 of file nlpioracle.c.

Function Documentation

◆ ensureVarsSize()

SCIP_RETCODE ensureVarsSize ( SCIP * scip,
SCIP_NLPIORACLE * oracle,
int minsize )
static

ensures that those arrays in oracle that store information on variables have at least a given length

Parameters
scipSCIP data structure
oracleNLPIORACLE data structure
minsizeminimal required size

Definition at line 123 of file nlpioracle.c.

References assert(), NULL, SCIP_CALL, SCIP_OKAY, SCIPcalcMemGrowSize(), SCIPreallocBlockMemoryArray, SCIP_NlpiOracle::varlbs, SCIP_NlpiOracle::varlincount, SCIP_NlpiOracle::varnames, SCIP_NlpiOracle::varnlcount, SCIP_NlpiOracle::varssize, and SCIP_NlpiOracle::varubs.

Referenced by SCIPnlpiOracleAddVars().

◆ ensureConssSize()

SCIP_RETCODE ensureConssSize ( SCIP * scip,
SCIP_NLPIORACLE * oracle,
int minsize )
static

ensures that constraints array in oracle has at least a given length

Parameters
scipSCIP data structure
oracleNLPIORACLE data structure
minsizeminimal required size

Definition at line 156 of file nlpioracle.c.

References assert(), SCIP_NlpiOracle::conss, SCIP_NlpiOracle::consssize, NULL, SCIP_CALL, SCIP_OKAY, and SCIPensureBlockMemoryArray.

Referenced by SCIPnlpiOracleAddConstraints().

◆ ensureConsLinSize()

SCIP_RETCODE ensureConsLinSize ( SCIP * scip,
SCIP_NLPIORACLECONS * cons,
int minsize )
static

ensures that arrays for linear part in a oracle constraints have at least a given length

Parameters
scipSCIP data structure
consoracle constraint
minsizeminimal required size

Definition at line 172 of file nlpioracle.c.

References assert(), SCIP_NlpiOracleCons::lincoefs, SCIP_NlpiOracleCons::linidxs, SCIP_NlpiOracleCons::linsize, NULL, SCIP_CALL, SCIP_OKAY, SCIPcalcMemGrowSize(), and SCIPreallocBlockMemoryArray.

Referenced by SCIPnlpiOracleChgLinearCoefs().

◆ ensureIntArraySize()

SCIP_RETCODE ensureIntArraySize ( SCIP * scip,
int ** intarray,
int * len,
int minsize )
static

ensures that a given array of integers has at least a given length

Parameters
scipSCIP data structure
intarrayarray of integers
lenlength of array (modified if reallocated)
minsizeminimal required array length

Definition at line 198 of file nlpioracle.c.

References assert(), NULL, SCIP_CALL, SCIP_OKAY, and SCIPensureBlockMemoryArray.

Referenced by computeRowJacobianSparsity(), and hessLagSparsitySetNzFlagForExpr().

◆ ensureClearBoolArraySize()

SCIP_RETCODE ensureClearBoolArraySize ( SCIP * scip,
SCIP_Bool ** boolarray,
int * len,
int minsize )
static

ensures that a given array of booleans has at least a given length, and clears the newly allocated memory

Parameters
scipSCIP data structure
boolarrayarray of bools
lenlength of array (modified if reallocated)
minsizeminimal required array length

Definition at line 216 of file nlpioracle.c.

References assert(), BMSclearMemoryArray, NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, and SCIPensureBlockMemoryArray.

Referenced by computeRowJacobianSparsity().

◆ invalidateJacobiSparsity()

◆ invalidateHessianLagSparsity()

void invalidateHessianLagSparsity ( SCIP * scip,
SCIP_NLPIORACLE * oracle )
static

Invalidates the sparsity pattern of the Hessian of the Lagragian. Should be called when the objective is set or constraints are added or deleted.

Parameters
scipSCIP data structure
oraclepointer to store NLPIORACLE data structure

Definition at line 296 of file nlpioracle.c.

References assert(), SCIP_NlpiOracle::heslagnzs, SCIP_NlpiOracle::heslagoffsets, NULL, SCIP_NlpiOracle::nvars, SCIPdebugMessage, and SCIPfreeBlockMemoryArray.

Referenced by SCIPnlpiOracleAddConstraints(), SCIPnlpiOracleAddVars(), SCIPnlpiOracleChgExpr(), SCIPnlpiOracleDelConsSet(), SCIPnlpiOracleDelVarSet(), SCIPnlpiOracleFree(), and SCIPnlpiOracleSetObjective().

◆ updateVariableCounts()

SCIP_RETCODE updateVariableCounts ( SCIP * scip,
SCIP_NLPIORACLE * oracle,
int factor,
int nlinidxs,
const int * linidxs,
SCIP_EXPR * expr )
static

increases or decreases variable counts in oracle w.r.t. linear and nonlinear appearance

Parameters
scipSCIP data structure
oracleoracle data structure
factorwhether to add (factor=1) or remove (factor=-1) variable counts
nlinidxsnumber of linear indices
linidxsindices of variables in linear part
exprexpression

Definition at line 319 of file nlpioracle.c.

References assert(), FALSE, NULL, SCIP_CALL, SCIP_EXPRITER_DFS, SCIP_OKAY, SCIPcreateExpriter(), SCIPexpriterGetNext(), SCIPexpriterInit(), SCIPexpriterIsEnd(), SCIPfreeExpriter(), SCIPgetIndexExprVaridx(), SCIPisExprVaridx(), SCIP_NlpiOracle::varlincount, and SCIP_NlpiOracle::varnlcount.

Referenced by createConstraint(), freeConstraint(), SCIPnlpiOracleChgExpr(), SCIPnlpiOracleChgLinearCoefs(), and SCIPnlpiOracleDelConsSet().

◆ sortLinearCoefficients()

void sortLinearCoefficients ( int * nidxs,
int * idxs,
SCIP_Real * coefs )
static

sorts a linear term, merges duplicate entries and removes entries with coefficient 0.0

Parameters
nidxsnumber of variables
idxsindices of variables
coefscoefficients of variables

Definition at line 364 of file nlpioracle.c.

References assert(), NULL, SCIP_Real, and SCIPsortIntReal().

Referenced by createConstraint(), and SCIPnlpiOracleChgLinearCoefs().

◆ createConstraint()

SCIP_RETCODE createConstraint ( SCIP * scip,
SCIP_NLPIORACLE * oracle,
SCIP_NLPIORACLECONS ** cons,
int nlinidxs,
const int * linidxs,
const SCIP_Real * lincoefs,
SCIP_EXPR * expr,
SCIP_Real lhs,
SCIP_Real rhs,
const char * name )
static

creates a NLPI constraint from given constraint data

Parameters
scipSCIP data structure
oraclepointer to NLPIORACLE data structure
consbuffer where to store pointer to constraint
nlinidxslength of linear part
linidxsindices of linear part, or NULL if nlinidxs == 0
lincoefscoefficients of linear part, or NULL if nlinidxs == 0
exprexpression, or NULL
lhsleft-hand-side of constraint
rhsright-hand-side of constraint
namename of constraint, or NULL

Definition at line 413 of file nlpioracle.c.

References assert(), EPSEQ, EPSLE, SCIP_NlpiOracle::exprinterpreter, NULL, SCIP_CALL, SCIP_DEFAULT_EPSILON, SCIP_OKAY, SCIP_Real, SCIPallocClearBlockMemory, SCIPcaptureExpr(), SCIPduplicateBlockMemoryArray, SCIPexprintCompile(), sortLinearCoefficients(), and updateVariableCounts().

Referenced by SCIPnlpiOracleAddConstraints(), SCIPnlpiOracleCreate(), and SCIPnlpiOracleSetObjective().

◆ freeConstraint()

SCIP_RETCODE freeConstraint ( SCIP * scip,
SCIP_NLPIORACLE * oracle,
SCIP_NLPIORACLECONS ** cons,
SCIP_Bool updatevarcount )
static

frees a constraint

Parameters
scipSCIP data structure
oraclepointer to NLPIORACLE data structure
conspointer to constraint that should be freed
updatevarcountwhether the update variable counts (typically TRUE)

Definition at line 476 of file nlpioracle.c.

References assert(), SCIP_NlpiOracle::exprinterpreter, NULL, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIPdebugMessage, SCIPexprintFreeData(), SCIPfreeBlockMemory, SCIPfreeBlockMemoryArrayNull, SCIPreleaseExpr(), and updateVariableCounts().

Referenced by freeConstraints(), SCIPnlpiOracleDelConsSet(), SCIPnlpiOracleFree(), and SCIPnlpiOracleSetObjective().

◆ freeConstraints()

SCIP_RETCODE freeConstraints ( SCIP * scip,
SCIP_NLPIORACLE * oracle )
static

frees all constraints

Attention
This omits updating the variable counts in the oracle.
Parameters
scipSCIP data structure
oraclepointer to NLPIORACLE data structure

Definition at line 520 of file nlpioracle.c.

References assert(), SCIP_NlpiOracle::conss, SCIP_NlpiOracle::consssize, FALSE, freeConstraint(), i, SCIP_NlpiOracle::nconss, NULL, SCIP_CALL, SCIP_OKAY, SCIPdebugMessage, and SCIPfreeBlockMemoryArrayNull.

Referenced by SCIPnlpiOracleDelConsSet(), and SCIPnlpiOracleFree().

◆ moveVariable()

SCIP_RETCODE moveVariable ( SCIP * scip,
SCIP_NLPIORACLE * oracle,
int fromidx,
int toidx )
static

moves one variable The place where it moves to need to be empty (all NULL) but allocated. Note that this function does not update the variable indices in the constraints!

Parameters
scipSCIP data structure
oraclepointer to store NLPIORACLE data structure
fromidxindex of variable to move
toidxindex of place where to move variable to

Definition at line 549 of file nlpioracle.c.

References assert(), NULL, nvars, SCIP_OKAY, SCIPdebugMessage, SCIPinfinity(), SCIP_NlpiOracle::varlbs, SCIP_NlpiOracle::varlincount, SCIP_NlpiOracle::varnames, SCIP_NlpiOracle::varnlcount, and SCIP_NlpiOracle::varubs.

Referenced by SCIPnlpiOracleDelVarSet().

◆ freeVariables()

void freeVariables ( SCIP * scip,
SCIP_NLPIORACLE * oracle )
static

◆ mapIndices()

void mapIndices ( int * indexmap,
int nindices,
int * indices )
static

applies a mapping of indices to one array of indices

Parameters
indexmapmapping from old variable indices to new indices
nindicesnumber of indices in indices1 and indices2
indicesarray of indices to adjust

Definition at line 622 of file nlpioracle.c.

References assert(), and NULL.

Referenced by SCIPnlpiOracleDelVarSet().

◆ clearDeletedLinearElements()

void clearDeletedLinearElements ( int ** linidxs,
SCIP_Real ** coefs,
int * nidxs )
static

removes entries with index -1 (marked as deleted) from array of linear elements assumes that array is sorted by index, i.e., all -1 are at the beginning

Parameters
linidxsvariable indices
coefsvariable coefficients
nidxsnumber of indices

Definition at line 642 of file nlpioracle.c.

References assert(), i, NULL, SCIP_Real, and SCIPdebugMessage.

Referenced by SCIPnlpiOracleDelVarSet().

◆ evalFunctionValue()

SCIP_RETCODE evalFunctionValue ( SCIP * scip,
SCIP_NLPIORACLE * oracle,
SCIP_NLPIORACLECONS * cons,
const SCIP_Real * x,
SCIP_Real * val )
static

computes the value of a function

Parameters
scipSCIP data structure
oraclepointer to NLPIORACLE data structure
consoracle constraint
xthe point where to evaluate
valpointer to store function value

Definition at line 680 of file nlpioracle.c.

References ABS, assert(), SCIP_NlpiOracleCons::expr, SCIP_NlpiOracleCons::exprintdata, SCIP_NlpiOracle::exprinterpreter, SCIP_NlpiOracleCons::lincoefs, SCIP_NlpiOracleCons::linidxs, SCIP_NlpiOracleCons::nlinidxs, NULL, SCIP_NlpiOracle::nvars, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPdebugMessage, SCIPexprintEval(), SCIPisFinite, SCIPisInfinity(), and x.

Referenced by SCIPnlpiOracleEvalConstraintValue(), SCIPnlpiOracleEvalConstraintValues(), and SCIPnlpiOracleEvalObjectiveValue().

◆ evalFunctionGradient()

SCIP_RETCODE evalFunctionGradient ( SCIP * scip,
SCIP_NLPIORACLE * oracle,
SCIP_NLPIORACLECONS * cons,
const SCIP_Real * x,
SCIP_Bool isnewx,
SCIP_Real *RESTRICT val,
SCIP_Real *RESTRICT grad )
static

computes the value and gradient of a function

Returns
SCIP_INVALIDDATA, if the function or its gradient could not be evaluated (domain error, etc.)
Parameters
scipSCIP data structure
oraclepointer to NLPIORACLE data structure
consoracle constraint
xthe point where to evaluate
isnewxhas the point x changed since the last call to some evaluation function?
valpointer to store function value
gradpointer to store function gradient

Definition at line 733 of file nlpioracle.c.

References ABS, assert(), BMSclearMemoryArray, SCIP_NlpiOracleCons::expr, SCIP_NlpiOracleCons::exprintdata, SCIP_NlpiOracle::exprinterpreter, i, SCIP_NlpiOracleCons::lincoefs, SCIP_NlpiOracleCons::linidxs, SCIP_NlpiOracleCons::nlinidxs, NULL, SCIP_NlpiOracle::nvars, RESTRICT, SCIP_Bool, SCIP_CALL, SCIP_INVALIDDATA, SCIP_OKAY, SCIP_Real, SCIPdebug, SCIPdebugMessage, SCIPdebugMsg, SCIPexprintGrad(), SCIPisFinite, SCIPisInfinity(), and x.

Referenced by SCIPnlpiOracleEvalConstraintGradient(), and SCIPnlpiOracleEvalObjectiveGradient().

◆ computeRowJacobianSparsity()

◆ hessLagSparsitySetNzFlagForExpr()

SCIP_RETCODE hessLagSparsitySetNzFlagForExpr ( SCIP * scip,
SCIP_NLPIORACLE * oracle,
int ** nz,
int * len,
int * nnz,
int * nzcount,
SCIP_EXPR * expr,
SCIP_EXPRINTDATA * exprintdata,
int dim,
SCIP_Bool colwise )
static

collects indices of nonzero entries in the lower-left part of the hessian matrix of an expression adds the indices to a given set of indices, avoiding duplicates

Parameters
scipSCIP data structure
oracleNLPI oracle
nzindices of nonzero entries for each column (if col) or row
lenspace allocated to store indices of nonzeros for each column (if col) or row
nnznumber of nonzero entries for each column (if col) or row
nzcountcounter for total number of nonzeros; should be increased when nzflag is set to 1 the first time
exprexpression
exprintdataexpression interpreter data for expression
dimdimension of matrix
colwisetells the function whether a column-wise (TRUE) or row-wise representation is needed

Definition at line 919 of file nlpioracle.c.

References assert(), ensureIntArraySize(), SCIP_NlpiOracle::exprinterpreter, i, NULL, nvars, SCIP_NlpiOracle::nvars, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPdebugMessage, SCIPexprintHessianSparsity(), SCIPfreeBufferArray, SCIPsortedvecFindInt(), SCIPsortedvecInsertInt(), and x.

Referenced by SCIPnlpiOracleGetHessianLagSparsity().

◆ hessLagAddExpr()

SCIP_RETCODE hessLagAddExpr ( SCIP * scip,
SCIP_NLPIORACLE * oracle,
SCIP_Real weight,
const SCIP_Real * x,
SCIP_Bool new_x,
SCIP_EXPR * expr,
SCIP_EXPRINTDATA * exprintdata,
int * hesoffset,
int * hesnzidcs,
SCIP_Real * values,
SCIP_Bool colwise )
static

adds hessian of an expression into hessian structure

Parameters
scipSCIP data structure
oracleoracle
weightweight of quadratic part
xpoint for which hessian should be returned
new_xwhether point has been evaluated before
exprexpression
exprintdataexpression interpreter data for expression
hesoffsetcolumn (if colwise = TRUE) or row offsets in sparse matrix that is to be filled
hesnzidcsrow (if colwise = TRUE) or column indices in sparse matrix that is to be filled
valuesbuffer for values of sparse matrix that is to be filled
colwisewhether the entries should be first sorted column-wise (TRUE) or row-wise

Definition at line 992 of file nlpioracle.c.

References assert(), SCIP_NlpiOracle::exprinterpreter, FALSE, h, i, NULL, SCIP_Bool, SCIP_CALL, SCIP_ERROR, SCIP_INVALIDDATA, SCIP_OKAY, SCIP_Real, SCIPdebugMessage, SCIPerrorMessage, SCIPexprintHessian(), SCIPisFinite, SCIPsortedvecFindInt(), and x.

Referenced by SCIPnlpiOracleEvalHessianLag().

◆ printName()

void printName ( char * buffer,
char * name,
int idx,
char prefix,
const char * suffix,
SCIP_Bool longnames )
static

prints a name, if available, makes sure it has not more than 64 characters, and adds a unique prefix if the longnames flag is set

Parameters
bufferbuffer to print to, has to be not NULL and should be at least 65 bytes
namename, or NULL
idxindex of var or cons which the name corresponds to
prefixa letter (typically 'x' or 'e') to distinguish variable and equation names, if names[idx] is not available
suffixa suffer to add to the name, or NULL
longnameswhether prefixes for long names should be added

Definition at line 1075 of file nlpioracle.c.

References assert(), NULL, SCIP_Bool, and SCIPsnprintf().

Referenced by printFunction(), and SCIPnlpiOraclePrintProblemGams().

◆ printFunction()

SCIP_RETCODE printFunction ( SCIP * scip,
SCIP_NLPIORACLE * oracle,
FILE * file,
SCIP_NLPIORACLECONS * cons,
SCIP_Bool longvarnames )
static

prints a function

Parameters
scipSCIP data structure
oraclepointer to NLPIORACLE data structure
filefile to print to, has to be not NULL
consconstraint which function to print
longvarnameswhether variable names need to be shorten to 64 characters

Definition at line 1110 of file nlpioracle.c.

References assert(), SCIP_NlpiOracleCons::expr, i, SCIP_NlpiOracleCons::lincoefs, SCIP_NlpiOracleCons::linidxs, SCIP_NlpiOracleCons::nlinidxs, NULL, printName(), SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIPdebugMessage, SCIPinfoMessage(), SCIPprintExpr(), and SCIP_NlpiOracle::varnames.

Referenced by SCIPnlpiOraclePrintProblem(), and SCIPnlpiOraclePrintProblemGams().

◆ exprIsNonSmooth()

SCIP_RETCODE exprIsNonSmooth ( SCIP * scip,
SCIP_EXPR * expr,
SCIP_Bool * nonsmooth )
static

returns whether an expression contains nonsmooth operands (min, max, abs, ...)

Parameters
scipSCIP data structure
exprexpression
nonsmoothbuffer to store whether expression seems nonsmooth

Definition at line 1147 of file nlpioracle.c.

References assert(), FALSE, NULL, SCIP_Bool, SCIP_CALL, SCIP_EXPRITER_DFS, SCIP_OKAY, SCIPcreateExpriter(), SCIPexprGetHdlr(), SCIPexprhdlrGetName(), SCIPexpriterGetNext(), SCIPexpriterInit(), SCIPexpriterIsEnd(), SCIPfreeExpriter(), SCIPisExprSignpower(), and TRUE.

Referenced by SCIPnlpiOraclePrintProblemGams().