Scippy

SCIP

Solving Constraint Integer Programs

Detailed Description

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

Author
Stefan Vigerske

Definition in file exprinterpret_cppad.cpp.

#include "scip/exprinterpret.h"
#include "scip/def.h"
#include "scip/intervalarith.h"
#include "scip/pub_expr.h"
#include "scip/scip_expr.h"
#include "scip/expr_pow.h"
#include "scip/expr_exp.h"
#include "scip/expr_log.h"
#include "scip/expr_varidx.h"
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cppad/cppad.hpp>
#include <cppad/utility/error_handler.hpp>

Go to the source code of this file.

Data Structures

class  atomic_userexpr
 

Macros

#define NO_CPPAD_USER_ATOMIC
 
#define CPPAD_MAX_NUM_THREADS   1
 

Functions

template<class Type >
void posintpower (const vector< Type > &in, vector< Type > &out, size_t exponent)
 
template<class Type >
static void evalSignPower (CppAD::AD< Type > &resultant, const CppAD::AD< Type > &arg, SCIP_EXPR *expr)
 
template<class Type >
static void evalIntPower (Type &resultant, const Type &arg, const int exponent)
 
template<class Type >
static SCIP_RETCODE eval (SCIP *scip, SCIP_EXPR *expr, SCIP_EXPRINTDATA *exprintdata, const vector< Type > &x, Type &val)
 
static void cppaderrorcallback (bool known, int line, const char *file, const char *cond, const char *msg)
 
static CppAD::ErrorHandler errorhandler (cppaderrorcallback)
 
const char * SCIPexprintGetName (void)
 
const char * SCIPexprintGetDesc (void)
 
SCIP_EXPRINTCAPABILITY SCIPexprintGetCapability (void)
 
SCIP_RETCODE SCIPexprintCreate (SCIP *scip, SCIP_EXPRINT **exprint)
 
SCIP_RETCODE SCIPexprintFree (SCIP *scip, SCIP_EXPRINT **exprint)
 
SCIP_RETCODE SCIPexprintCompile (SCIP *scip, SCIP_EXPRINT *exprint, SCIP_EXPR *rootexpr, SCIP_EXPRINTDATA **exprintdata)
 
SCIP_RETCODE SCIPexprintFreeData (SCIP *scip, SCIP_EXPRINT *exprint, SCIP_EXPR *expr, SCIP_EXPRINTDATA **exprintdata)
 
SCIP_EXPRINTCAPABILITY SCIPexprintGetExprCapability (SCIP *scip, SCIP_EXPRINT *exprint, SCIP_EXPR *expr, SCIP_EXPRINTDATA *exprintdata)
 
SCIP_RETCODE SCIPexprintEval (SCIP *scip, SCIP_EXPRINT *exprint, SCIP_EXPR *expr, SCIP_EXPRINTDATA *exprintdata, SCIP_Real *varvals, SCIP_Real *val)
 
SCIP_RETCODE SCIPexprintGrad (SCIP *scip, SCIP_EXPRINT *exprint, SCIP_EXPR *expr, SCIP_EXPRINTDATA *exprintdata, SCIP_Real *varvals, SCIP_Bool new_varvals, SCIP_Real *val, SCIP_Real *gradient)
 
SCIP_RETCODE SCIPexprintHessianSparsity (SCIP *scip, SCIP_EXPRINT *exprint, SCIP_EXPR *expr, SCIP_EXPRINTDATA *exprintdata, SCIP_Real *varvals, int **rowidxs, int **colidxs, int *nnz)
 
SCIP_RETCODE SCIPexprintHessian (SCIP *scip, SCIP_EXPRINT *exprint, SCIP_EXPR *expr, SCIP_EXPRINTDATA *exprintdata, SCIP_Real *varvals, SCIP_Bool new_varvals, SCIP_Real *val, int **rowidxs, int **colidxs, SCIP_Real **hessianvals, int *nnz)
 

Macro Definition Documentation

◆ NO_CPPAD_USER_ATOMIC

#define NO_CPPAD_USER_ATOMIC

Definition at line 67 of file exprinterpret_cppad.cpp.

◆ CPPAD_MAX_NUM_THREADS

#define CPPAD_MAX_NUM_THREADS   1

Definition at line 81 of file exprinterpret_cppad.cpp.

Function Documentation

◆ posintpower()

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

power function with natural exponents

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

Definition at line 556 of file exprinterpret_cppad.cpp.

Referenced by evalIntPower().

◆ evalSignPower()

template<class Type >
static void evalSignPower ( CppAD::AD< Type > &  resultant,
const CppAD::AD< Type > &  arg,
SCIP_EXPR expr 
)
static

specialization of signpower evaluation for real numbers

Parameters
resultantresultant
argoperand
exprexpression that holds the exponent

Definition at line 840 of file exprinterpret_cppad.cpp.

References EPSISINT, SCIP_Real, and SCIPgetExponentExprPow().

Referenced by eval().

◆ evalIntPower()

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

integer power operation for arbitrary integer exponents

Parameters
resultantresultant
argoperand
exponentexponent

Definition at line 1287 of file exprinterpret_cppad.cpp.

References posintpower().

Referenced by eval().

◆ eval()

template<class Type >
static SCIP_RETCODE eval ( SCIP scip,
SCIP_EXPR expr,
SCIP_EXPRINTDATA exprintdata,
const vector< Type > &  x,
Type val 
)
static

◆ cppaderrorcallback()

static void cppaderrorcallback ( bool  known,
int  line,
const char *  file,
const char *  cond,
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
conderror condition
msgerror message

Definition at line 1463 of file exprinterpret_cppad.cpp.

References SCIPdebugMessage.

◆ errorhandler()

static CppAD::ErrorHandler errorhandler ( cppaderrorcallback  )
static