methods to interpret (evaluate) an expression "fast" using CppAD
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) |
#define NO_CPPAD_USER_ATOMIC |
Definition at line 67 of file exprinterpret_cppad.cpp.
#define CPPAD_MAX_NUM_THREADS 1 |
Definition at line 81 of file exprinterpret_cppad.cpp.
void posintpower | ( | const vector< Type > & | in, |
vector< Type > & | out, | ||
size_t | exponent ) |
power function with natural exponents
in | vector which first argument is base |
out | vector where to store result in first argument |
exponent | exponent |
Definition at line 556 of file exprinterpret_cppad.cpp.
Referenced by evalIntPower().
|
static |
specialization of signpower evaluation for real numbers
resultant | resultant |
arg | operand |
expr | expression that holds the exponent |
Definition at line 840 of file exprinterpret_cppad.cpp.
References assert(), EPSISINT, SCIP_Real, and SCIPgetExponentExprPow().
Referenced by eval().
|
static |
integer power operation for arbitrary integer exponents
resultant | resultant |
arg | operand |
exponent | exponent |
Definition at line 1287 of file exprinterpret_cppad.cpp.
References assert(), and posintpower().
Referenced by eval().
|
static |
CppAD compatible evaluation of an expression for given arguments
scip | SCIP data structure |
expr | expression |
exprintdata | interpreter data for root expression |
x | values of variables |
val | buffer to store expression value |
Definition at line 1334 of file exprinterpret_cppad.cpp.
References assert(), EPSISINT, eval(), evalIntPower(), evalSignPower(), i, NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPexprGetChildren(), SCIPexprGetHdlr(), SCIPexprGetNChildren(), SCIPexprhdlrGetName(), SCIPfreeBufferArray, SCIPgetCoefExprProduct(), SCIPgetCoefsExprSum(), SCIPgetConstantExprSum(), SCIPgetExponentExprPow(), SCIPgetIndexExprVaridx(), SCIPgetValueExprValue(), SCIPisExprExp(), SCIPisExprLog(), SCIPisExprPower(), SCIPisExprProduct(), SCIPisExprSignpower(), SCIPisExprSum(), SCIPisExprValue(), SCIPisExprVaridx(), and x.
Referenced by eval(), SCIP_Exprhdlr::SCIP_DECL_EXPREVAL(), SCIPexprhdlrCreate(), SCIPexprintEval(), and SCIPincludeExprhdlr().
|
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.
known | is the error from a known source? |
line | line where error occured |
file | file where error occured |
cond | error condition |
msg | error message |
Definition at line 1463 of file exprinterpret_cppad.cpp.
References SCIPdebugMessage.
Referenced by errorhandler().
|
static |
References cppaderrorcallback().