Scippy

SCIP

Solving Constraint Integer Programs

exprinterpret_cppad.cpp File Reference

Detailed Description

methods to interpret (evaluate) an expression tree "fast" using CppAD

Author
Stefan Vigerske

Definition in file exprinterpret_cppad.cpp.

#include "scip/def.h"
#include "blockmemshell/memory.h"
#include "nlpi/pub_expr.h"
#include "nlpi/exprinterpret.h"
#include <cmath>
#include <vector>
#include "nlpi/intervalarithext.h"
#include <cppad/cppad.hpp>
#include <cppad/error_handler.hpp>
#include <pthread.h>

Go to the source code of this file.

Macros

#define SIGN(x)   ((x) >= 0.0 ? 1.0 : -1.0)
 
#define SCIPInterval_NAMESPACE   CppAD
 
#define CPPAD_MAX_NUM_THREADS   64
 

Functions

static bool in_parallel (void)
 
static size_t thread_num (void)
 
static char init_parallel (void)
 
SCIPInterval CondExpOp (enum CppAD::CompareOp cop, const SCIPInterval &left, const SCIPInterval &right, const SCIPInterval &trueCase, const SCIPInterval &falseCase)
 
bool EqualOpSeq (const SCIPInterval &x, const SCIPInterval &y)
 
bool IdenticalPar (const SCIPInterval &x)
 
bool IdenticalZero (const SCIPInterval &x)
 
bool IdenticalOne (const SCIPInterval &x)
 
bool IdenticalEqualPar (const SCIPInterval &x, const SCIPInterval &y)
 
bool GreaterThanZero (const SCIPInterval &x)
 
bool GreaterThanOrZero (const SCIPInterval &x)
 
bool LessThanZero (const SCIPInterval &x)
 
bool LessThanOrZero (const SCIPInterval &x)
 
int Integer (const SCIPInterval &x)
 
std::ostream & operator<< (std::ostream &out, const SCIP_INTERVAL &x)
 
static bool univariate_for_sparse_jac (size_t q, const CppAD::vector< bool > &r, CppAD::vector< bool > &s)
 
static bool univariate_rev_sparse_jac (size_t q, CppAD::vector< bool > &r, const CppAD::vector< bool > &s)
 
static bool univariate_rev_sparse_hes (const CppAD::vector< bool > &vx, const CppAD::vector< bool > &s, CppAD::vector< bool > &t, size_t q, const CppAD::vector< bool > &r, const CppAD::vector< bool > &u, CppAD::vector< bool > &v)
 
template<class Type >
static void posintpower (vector< Type > &in, vector< Type > &out, size_t exponent)
 
template<class Type >
static void evalSignPower (Type &resultant, Type &arg, SCIP_EXPR *expr)
 
template<class Type >
static void evalMin (Type &resultant, Type &arg1, Type &arg2)
 
template<>
void evalMin (CppAD::AD< double > &resultant, CppAD::AD< double > &arg1, CppAD::AD< double > &arg2)
 
template<class Type >
static void evalMax (Type &resultant, Type &arg1, Type &arg2)
 
template<>
void evalMax (CppAD::AD< double > &resultant, CppAD::AD< double > &arg1, CppAD::AD< double > &arg2)
 
template<class Type >
static void evalSqrt (Type &resultant, Type &arg)
 
template<>
void evalSqrt (CppAD::AD< double > &resultant, CppAD::AD< double > &arg)
 
template<class Type >
static void evalAbs (Type &resultant, Type &arg)
 
template<>
void evalAbs (CppAD::AD< SCIPInterval > &resultant, CppAD::AD< SCIPInterval > &arg)
 
template<class Type >
static void evalIntPower (Type &resultant, Type &arg, int exponent)
 
template<class Type >
static SCIP_RETCODE eval (SCIP_EXPR *expr, const vector< Type > &x, SCIP_Real *param, Type &val)
 
static bool needAlwaysRetape (SCIP_EXPR *expr)
 
static void cppaderrorcallback (bool known, int line, const char *file, const char *exp, const char *msg)
 
static CppAD::ErrorHandler errorhandler (cppaderrorcallback)
 
const char * SCIPexprintGetName (void)
 
const char * SCIPexprintGetDesc (void)
 
SCIP_EXPRINTCAPABILITY SCIPexprintGetCapability (void)
 
SCIP_RETCODE SCIPexprintCreate (BMS_BLKMEM *blkmem, SCIP_EXPRINT **exprint)
 
SCIP_RETCODE SCIPexprintFree (SCIP_EXPRINT **exprint)
 
SCIP_RETCODE SCIPexprintCompile (SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree)
 
SCIP_RETCODE SCIPexprintFreeData (SCIP_EXPRINTDATA **interpreterdata)
 
SCIP_RETCODE SCIPexprintNewParametrization (SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree)
 
SCIP_RETCODE SCIPexprintEval (SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree, SCIP_Real *varvals, SCIP_Real *val)
 
SCIP_RETCODE SCIPexprintEvalInt (SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree, SCIP_Real infinity, SCIP_INTERVAL *varvals, SCIP_INTERVAL *val)
 
SCIP_RETCODE SCIPexprintGrad (SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree, SCIP_Real *varvals, SCIP_Bool new_varvals, SCIP_Real *val, SCIP_Real *gradient)
 
SCIP_RETCODE SCIPexprintGradInt (SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree, SCIP_Real infinity, SCIP_INTERVAL *varvals, SCIP_Bool new_varvals, SCIP_INTERVAL *val, SCIP_INTERVAL *gradient)
 
SCIP_RETCODE SCIPexprintHessianSparsityDense (SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree, SCIP_Real *varvals, SCIP_Bool *sparsity)
 
SCIP_RETCODE SCIPexprintHessianDense (SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree, SCIP_Real *varvals, SCIP_Bool new_varvals, SCIP_Real *val, SCIP_Real *hessian)
 

Variables

static pthread_mutex_t cppadmutex = PTHREAD_MUTEX_INITIALIZER
 
static pthread_key_t thread_specific_key
 
static size_t ncurthreads = 0
 
static char init_parallel_return = init_parallel()
 

Macro Definition Documentation

#define SIGN (   x)    ((x) >= 0.0 ? 1.0 : -1.0)

sign of a value (-1 or +1)

0.0 has sign +1

Definition at line 43 of file exprinterpret_cppad.cpp.

#define SCIPInterval_NAMESPACE   CppAD

Definition at line 47 of file exprinterpret_cppad.cpp.

#define CPPAD_MAX_NUM_THREADS   64

CppAD needs to know a fixed upper bound on the number of threads at compile time. It is wise to set it to a power of 2, so that if the tape id overflows, it is likely to start at 0 again, which avoids difficult to debug errors.

Definition at line 58 of file exprinterpret_cppad.cpp.

Referenced by init_parallel().

Function Documentation

static bool in_parallel ( void  )
static

CppAD callback function that indicates whether we are running in parallel mode

Definition at line 105 of file exprinterpret_cppad.cpp.

References ncurthreads.

Referenced by init_parallel().

static size_t thread_num ( void  )
static

CppAD callback function that returns the number of the current thread assigns a new number to the thread if new

Definition at line 114 of file exprinterpret_cppad.cpp.

References cppadmutex, ncurthreads, NULL, SCIPdebugMessage, and thread_specific_key.

Referenced by init_parallel().

static char init_parallel ( void  )
static

sets up CppAD's datastructures for running in multithreading mode it must be called once before multithreading is started

Definition at line 155 of file exprinterpret_cppad.cpp.

References CPPAD_MAX_NUM_THREADS, in_parallel(), NULL, thread_num(), and thread_specific_key.

SCIPInterval CondExpOp ( enum CppAD::CompareOp  cop,
const SCIPInterval &  left,
const SCIPInterval &  right,
const SCIPInterval &  trueCase,
const SCIPInterval &  falseCase 
)
inline

definition of CondExpOp for SCIPInterval (required by CppAD)

Definition at line 175 of file exprinterpret_cppad.cpp.

bool EqualOpSeq ( const SCIPInterval &  x,
const SCIPInterval &  y 
)
inline

another function that returns whether two intervals are the same (required by CppAD)

Parameters
xfirst operand
ysecond operand

Definition at line 192 of file exprinterpret_cppad.cpp.

bool IdenticalPar ( const SCIPInterval &  x)
inline

another function required by CppAD

Parameters
xoperand

Definition at line 202 of file exprinterpret_cppad.cpp.

bool IdenticalZero ( const SCIPInterval &  x)
inline

returns whether the interval equals [0,0]

Parameters
xoperand

Definition at line 211 of file exprinterpret_cppad.cpp.

bool IdenticalOne ( const SCIPInterval &  x)
inline

returns whether the interval equals [1,1]

Parameters
xoperand

Definition at line 220 of file exprinterpret_cppad.cpp.

bool IdenticalEqualPar ( const SCIPInterval &  x,
const SCIPInterval &  y 
)
inline

yet another function that checks whether two intervals are equal

Parameters
xfirst operand
ysecond operand

Definition at line 229 of file exprinterpret_cppad.cpp.

bool GreaterThanZero ( const SCIPInterval &  x)
inline

greater than zero not defined for intervals

Parameters
xoperand

Definition at line 239 of file exprinterpret_cppad.cpp.

bool GreaterThanOrZero ( const SCIPInterval &  x)
inline

greater than or equal zero not defined for intervals

Parameters
xoperand

Definition at line 253 of file exprinterpret_cppad.cpp.

bool LessThanZero ( const SCIPInterval &  x)
inline

less than not defined for intervals

Parameters
xoperand

Definition at line 267 of file exprinterpret_cppad.cpp.

bool LessThanOrZero ( const SCIPInterval &  x)
inline

less than or equal not defined for intervals

Parameters
xoperand

Definition at line 281 of file exprinterpret_cppad.cpp.

int Integer ( const SCIPInterval &  x)
inline

conversion to integers not defined for intervals

Parameters
xoperand

Definition at line 295 of file exprinterpret_cppad.cpp.

std::ostream& operator<< ( std::ostream &  out,
const SCIP_INTERVAL x 
)
inline

printing of an interval (required by CppAD)

Definition at line 309 of file exprinterpret_cppad.cpp.

References SCIP_Interval::inf, and SCIP_Interval::sup.

static bool univariate_for_sparse_jac ( size_t  q,
const CppAD::vector< bool > &  r,
CppAD::vector< bool > &  s 
)
static

computes sparsity of jacobian for a univariate function during a forward sweep For a 1 x q matrix R, we have to return the sparsity pattern of the 1 x q matrix S(x) = f'(x) * R. Since f'(x) is dense, the sparsity of S will be the sparsity of R.

Parameters
qnumber of columns in R
rsparsity of R, columnwise
svector to store sparsity of S, columnwise

Definition at line 366 of file exprinterpret_cppad.cpp.

static bool univariate_rev_sparse_jac ( size_t  q,
CppAD::vector< bool > &  r,
const CppAD::vector< bool > &  s 
)
static

computes sparsity of jacobian during a reverse sweep For a q x 1 matrix S, we have to return the sparsity pattern of the q x 1 matrix R(x) = S * f'(x). Since f'(x) is dense, the sparsity of R will be the sparsity of S.

Parameters
qnumber of rows in R
rsparsity of R, rowwise
svector to store sparsity of S, rowwise

Definition at line 385 of file exprinterpret_cppad.cpp.

static bool univariate_rev_sparse_hes ( const CppAD::vector< bool > &  vx,
const CppAD::vector< bool > &  s,
CppAD::vector< bool > &  t,
size_t  q,
const CppAD::vector< bool > &  r,
const CppAD::vector< bool > &  u,
CppAD::vector< bool > &  v 
)
static

computes sparsity of hessian during a reverse sweep Assume V(x) = (g(f(x)))'' R with f(x) = x^p for a function g:R->R and a matrix R. we have to specify the sparsity pattern of V(x) and T(x) = (g(f(x)))'.

Parameters
vxindicates whether argument is a variable, or empty vector
ssparsity pattern of S = g'(y)
tvector to store sparsity pattern of T(x) = (g(f(x)))'
qnumber of columns in R, U, and V
rsparsity pattern of R
usparsity pattern of U(x) = g''(f(x)) f'(x) R
vvector to store sparsity pattern of V(x) = (g(f(x)))'' R

Definition at line 404 of file exprinterpret_cppad.cpp.

template<class Type >
static void posintpower ( vector< Type > &  in,
vector< Type > &  out,
size_t  exponent 
)
static

power function with natural exponents

Parameters
invector which first argument is base
outvector where to store result in first argument
exponentexponent

Definition at line 658 of file exprinterpret_cppad.cpp.

Referenced by eval(), evalAbs(), and evalIntPower().

template<class Type >
static void evalSignPower ( Type resultant,
Type arg,
SCIP_EXPR expr 
)
static
Parameters
resultantresultant
argoperand
exprexpression that holds the exponent

Definition at line 1118 of file exprinterpret_cppad.cpp.

Referenced by eval().

template<class Type >
static void evalMin ( Type resultant,
Type arg1,
Type arg2 
)
static

template for evaluation for minimum operator only implemented for real numbers, thus gives error by default

Parameters
resultantresultant
arg1first operand
arg2second operand

Definition at line 1182 of file exprinterpret_cppad.cpp.

Referenced by eval().

template<>
void evalMin ( CppAD::AD< double > &  resultant,
CppAD::AD< double > &  arg1,
CppAD::AD< double > &  arg2 
)

specialization of minimum evaluation for real numbers

Parameters
resultantresultant
arg1first operand
arg2second operand

Definition at line 1197 of file exprinterpret_cppad.cpp.

References MIN.

template<class Type >
static void evalMax ( Type resultant,
Type arg1,
Type arg2 
)
static

template for evaluation for maximum operator only implemented for real numbers, thus gives error by default

Parameters
resultantresultant
arg1first operand
arg2second operand

Definition at line 1212 of file exprinterpret_cppad.cpp.

Referenced by eval().

template<>
void evalMax ( CppAD::AD< double > &  resultant,
CppAD::AD< double > &  arg1,
CppAD::AD< double > &  arg2 
)

specialization of maximum evaluation for real numbers

Parameters
resultantresultant
arg1first operand
arg2second operand

Definition at line 1227 of file exprinterpret_cppad.cpp.

References MAX.

template<class Type >
static void evalSqrt ( Type resultant,
Type arg 
)
static

template for evaluation for square-root operator default is to use the standard sqrt-function

Parameters
resultantresultant
argoperand

Definition at line 1241 of file exprinterpret_cppad.cpp.

References sqrt().

Referenced by eval().

template<>
void evalSqrt ( CppAD::AD< double > &  resultant,
CppAD::AD< double > &  arg 
)

specialization of square-root operator for numbers we perturb the function a little bit so that it's derivatives are defined in 0.0

Parameters
resultantresultant
argoperand

Definition at line 1253 of file exprinterpret_cppad.cpp.

References sqrt().

template<class Type >
static void evalAbs ( Type resultant,
Type arg 
)
static

template for evaluation for absolute value operator

Parameters
resultantresultant
argoperand

Definition at line 1265 of file exprinterpret_cppad.cpp.

References abs().

Referenced by eval().

template<>
void evalAbs ( CppAD::AD< SCIPInterval > &  resultant,
CppAD::AD< SCIPInterval > &  arg 
)

specialization of absolute value evaluation for intervals use sqrt(x^2) for now

Parameters
resultantresultant
argoperand

Definition at line 1277 of file exprinterpret_cppad.cpp.

References posintpower(), and sqrt().

template<class Type >
static void evalIntPower ( Type resultant,
Type arg,
int  exponent 
)
static

integer power operation for arbitrary integer exponents

Parameters
resultantresultant
argoperand
exponentexponent

Definition at line 1293 of file exprinterpret_cppad.cpp.

References posintpower().

Referenced by eval().

template<class Type >
static SCIP_RETCODE eval ( SCIP_EXPR expr,
const vector< Type > &  x,
SCIP_Real param,
Type val 
)
static

CppAD compatible evaluation of an expression for given arguments and parameters

Parameters
exprexpression
xvalues of variables
paramvalues of parameters
valbuffer to store expression value

Definition at line 1340 of file exprinterpret_cppad.cpp.

References BMSallocMemoryArray, BMSfreeMemoryArrayNull, SCIP_QuadElement::coef, cos(), evalAbs(), evalIntPower(), evalMax(), evalMin(), evalSignPower(), evalSqrt(), exp(), SCIP_QuadElement::idx2, log(), NULL, posintpower(), pow(), SCIP_CALL, SCIP_ERROR, SCIP_EXPR_ABS, SCIP_EXPR_CONST, SCIP_EXPR_COS, SCIP_EXPR_DIV, SCIP_EXPR_EXP, SCIP_EXPR_INTPOWER, SCIP_EXPR_LINEAR, SCIP_EXPR_LOG, SCIP_EXPR_MAX, SCIP_EXPR_MIN, SCIP_EXPR_MINUS, SCIP_EXPR_MUL, SCIP_EXPR_PARAM, SCIP_EXPR_PLUS, SCIP_EXPR_POLYNOMIAL, SCIP_EXPR_PRODUCT, SCIP_EXPR_QUADRATIC, SCIP_EXPR_REALPOWER, SCIP_EXPR_SIGN, SCIP_EXPR_SIGNPOWER, SCIP_EXPR_SIN, SCIP_EXPR_SQRT, SCIP_EXPR_SQUARE, SCIP_EXPR_SUM, SCIP_EXPR_TAN, SCIP_EXPR_VARIDX, SCIP_NOMEMORY, SCIP_OKAY, SCIP_Real, SCIPexprGetChildren(), SCIPexprGetIntPowerExponent(), SCIPexprGetLinearCoefs(), SCIPexprGetLinearConstant(), SCIPexprGetMonomialChildIndices(), SCIPexprGetMonomialCoef(), SCIPexprGetMonomialExponents(), SCIPexprGetMonomialNFactors(), SCIPexprGetMonomials(), SCIPexprGetNChildren(), SCIPexprGetNMonomials(), SCIPexprGetNQuadElements(), SCIPexprGetOperator(), SCIPexprGetOpIndex(), SCIPexprGetOpReal(), SCIPexprGetPolynomialConstant(), SCIPexprGetQuadConstant(), SCIPexprGetQuadElements(), SCIPexprGetQuadLinearCoefs(), SCIPexprGetRealPowerExponent(), SCIPexprSortQuadElems(), sign(), and sin().

Referenced by SCIPexprintEval(), and SCIPexprintEvalInt().

static bool needAlwaysRetape ( SCIP_EXPR expr)
static

analysis an expression tree whether it requires retaping on every evaluation this may be the case if the evaluation sequence depends on values of operands (e.g., in case of abs, sign, signpower, ...)

Definition at line 1621 of file exprinterpret_cppad.cpp.

References NULL, SCIP_EXPR_ABS, SCIP_EXPR_MAX, SCIP_EXPR_MIN, SCIP_EXPR_SIGNPOWER, SCIPexprGetChildren(), SCIPexprGetNChildren(), and SCIPexprGetOperator().

Referenced by SCIPexprintCompile().

static void cppaderrorcallback ( bool  known,
int  line,
const char *  file,
const char *  exp,
const char *  msg 
)
static

replacement for CppAD's default error handler in debug mode, CppAD gives an error when an evaluation contains a nan we do not want to stop execution in such a case, since the calling routine should check for nan's and decide what to do since we cannot ignore this particular error, we ignore all

Parameters
knownis the error from a known source?
lineline where error occured
filefile where error occured
experror condition
msgerror message

Definition at line 1655 of file exprinterpret_cppad.cpp.

References SCIPdebugMessage.

static CppAD::ErrorHandler errorhandler ( cppaderrorcallback  )
static
const char* SCIPexprintGetName ( void  )

gets name and version of expression interpreter

Definition at line 1670 of file exprinterpret_cppad.cpp.

const char* SCIPexprintGetDesc ( void  )

gets descriptive text of expression interpreter

Definition at line 1676 of file exprinterpret_cppad.cpp.

SCIP_EXPRINTCAPABILITY SCIPexprintGetCapability ( void  )
SCIP_RETCODE SCIPexprintCreate ( BMS_BLKMEM blkmem,
SCIP_EXPRINT **  exprint 
)

creates an expression interpreter object

Parameters
blkmemblock memory data structure
exprintbuffer to store pointer to expression interpreter

Definition at line 1692 of file exprinterpret_cppad.cpp.

References BMSallocMemory, NULL, SCIP_NOMEMORY, and SCIP_OKAY.

SCIP_RETCODE SCIPexprintFree ( SCIP_EXPRINT **  exprint)

frees an expression interpreter object

Parameters
exprintexpression interpreter that should be freed

Definition at line 1709 of file exprinterpret_cppad.cpp.

References BMSfreeMemory, NULL, and SCIP_OKAY.

SCIP_RETCODE SCIPexprintCompile ( SCIP_EXPRINT exprint,
SCIP_EXPRTREE tree 
)

compiles an expression tree and stores compiled data in expression tree

Parameters
exprintinterpreter data structure
treeexpression tree

Definition at line 1722 of file exprinterpret_cppad.cpp.

References SCIP_ExprInt::blkmem, needAlwaysRetape(), NULL, SCIP_CALL, SCIP_OKAY, SCIPdebugMessage, SCIPexprCopyDeep(), SCIPexprFreeDeep(), SCIPexprtreeGetInterpreterData(), SCIPexprtreeGetNVars(), SCIPexprtreeGetRoot(), and SCIPexprtreeSetInterpreterData().

SCIP_RETCODE SCIPexprintFreeData ( SCIP_EXPRINTDATA **  interpreterdata)

frees interpreter data

Parameters
interpreterdatainterpreter data that should freed

Definition at line 1770 of file exprinterpret_cppad.cpp.

References NULL, SCIP_OKAY, and SCIPexprFreeDeep().

SCIP_RETCODE SCIPexprintNewParametrization ( SCIP_EXPRINT exprint,
SCIP_EXPRTREE tree 
)

notify expression interpreter that a new parameterization is used this probably causes retaping by AD algorithms

Parameters
exprintinterpreter data structure
treeexpression tree

Definition at line 1789 of file exprinterpret_cppad.cpp.

References NULL, SCIP_OKAY, and SCIPexprtreeGetInterpreterData().

SCIP_RETCODE SCIPexprintEval ( SCIP_EXPRINT exprint,
SCIP_EXPRTREE tree,
SCIP_Real varvals,
SCIP_Real val 
)

evaluates an expression tree

Parameters
exprintinterpreter data structure
treeexpression tree
varvalsvalues of variables
valbuffer to store value

Definition at line 1808 of file exprinterpret_cppad.cpp.

References eval(), NULL, SCIP_CALL, SCIP_OKAY, SCIPdebugMessage, SCIPexprtreeGetInterpreterData(), SCIPexprtreeGetNVars(), SCIPexprtreeGetParamVals(), and SCIPexprtreeGetRoot().

SCIP_RETCODE SCIPexprintEvalInt ( SCIP_EXPRINT exprint,
SCIP_EXPRTREE tree,
SCIP_Real  infinity,
SCIP_INTERVAL varvals,
SCIP_INTERVAL val 
)

evaluates an expression tree on intervals

Parameters
exprintinterpreter data structure
treeexpression tree
infinityvalue for infinity
varvalsinterval values of variables
valbuffer to store interval value of expression

Definition at line 1871 of file exprinterpret_cppad.cpp.

References eval(), NULL, SCIP_CALL, SCIP_OKAY, SCIPexprtreeGetInterpreterData(), SCIPexprtreeGetNVars(), SCIPexprtreeGetParamVals(), and SCIPexprtreeGetRoot().

SCIP_RETCODE SCIPexprintGrad ( SCIP_EXPRINT exprint,
SCIP_EXPRTREE tree,
SCIP_Real varvals,
SCIP_Bool  new_varvals,
SCIP_Real val,
SCIP_Real gradient 
)

computes value and gradient of an expression tree

Parameters
exprintinterpreter data structure
treeexpression tree
varvalsvalues of variables, can be NULL if new_varvals is FALSE
new_varvalshave variable values changed since last call to a point evaluation routine?
valbuffer to store expression value
gradientbuffer to store expression gradient, need to have length at least SCIPexprtreeGetNVars(tree)

Definition at line 1931 of file exprinterpret_cppad.cpp.

References FALSE, NULL, SCIP_CALL, SCIP_OKAY, SCIPexprintEval(), SCIPexprtreeGetInterpreterData(), and SCIPexprtreeGetNVars().

SCIP_RETCODE SCIPexprintGradInt ( SCIP_EXPRINT exprint,
SCIP_EXPRTREE tree,
SCIP_Real  infinity,
SCIP_INTERVAL varvals,
SCIP_Bool  new_varvals,
SCIP_INTERVAL val,
SCIP_INTERVAL gradient 
)

computes interval value and interval gradient of an expression tree

Parameters
exprintinterpreter data structure
treeexpression tree
infinityvalue for infinity
varvalsinterval values of variables, can be NULL if new_varvals is FALSE
new_varvalshave variable interval values changed since last call to an interval evaluation routine?
valbuffer to store expression interval value
gradientbuffer to store expression interval gradient, need to have length at least SCIPexprtreeGetNVars(tree)

Definition at line 1975 of file exprinterpret_cppad.cpp.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPexprintEvalInt(), SCIPexprtreeGetInterpreterData(), and SCIPexprtreeGetNVars().

SCIP_RETCODE SCIPexprintHessianSparsityDense ( SCIP_EXPRINT exprint,
SCIP_EXPRTREE tree,
SCIP_Real varvals,
SCIP_Bool sparsity 
)

gives sparsity pattern of hessian NOTE: this function might be replaced later by something nicer Since the AD code might need to do a forward sweep, you should pass variable values in here.

Parameters
exprintinterpreter data structure
treeexpression tree
varvalsvalues of variables
sparsitybuffer to store sparsity pattern of Hessian, sparsity[i+n*j] indicates whether entry (i,j) is nonzero in the hessian

Definition at line 2021 of file exprinterpret_cppad.cpp.

References NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPdebugMessage, SCIPexprintEval(), SCIPexprtreeGetInterpreterData(), SCIPexprtreeGetNVars(), and TRUE.

SCIP_RETCODE SCIPexprintHessianDense ( SCIP_EXPRINT exprint,
SCIP_EXPRTREE tree,
SCIP_Real varvals,
SCIP_Bool  new_varvals,
SCIP_Real val,
SCIP_Real hessian 
)

computes value and dense hessian of an expression tree the full hessian is computed (lower left and upper right triangle)

Parameters
exprintinterpreter data structure
treeexpression tree
varvalsvalues of variables, can be NULL if new_varvals is FALSE
new_varvalshave variable values changed since last call to an evaluation routine?
valbuffer to store function value
hessianbuffer to store hessian values, need to have size at least n*n

Definition at line 2090 of file exprinterpret_cppad.cpp.

References FALSE, NULL, SCIP_CALL, SCIP_OKAY, SCIPexprintEval(), SCIPexprtreeGetInterpreterData(), and SCIPexprtreeGetNVars().

Variable Documentation

pthread_mutex_t cppadmutex = PTHREAD_MUTEX_INITIALIZER
static

mutex for locking in pthread case

Definition at line 95 of file exprinterpret_cppad.cpp.

Referenced by thread_num().

pthread_key_t thread_specific_key
static

key for accessing thread specific information

Definition at line 98 of file exprinterpret_cppad.cpp.

Referenced by init_parallel(), and thread_num().

size_t ncurthreads = 0
static

currently registered number of threads

Definition at line 101 of file exprinterpret_cppad.cpp.

Referenced by in_parallel(), and thread_num().

char init_parallel_return = init_parallel()
static

a dummy variable that can is initialized to the result of init_parallel the purpose is to make sure that init_parallel() is called before any multithreading is started

Definition at line 169 of file exprinterpret_cppad.cpp.