Detailed Description
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 *expr, 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()
| void posintpower | ( | const vector< Type > & | in, |
| vector< Type > & | out, | ||
| size_t | exponent | ||
| ) |
power function with natural exponents
- Parameters
-
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().
◆ evalSignPower()
|
static |
specialization of signpower evaluation for real numbers
- Parameters
-
resultant resultant arg operand expr expression that holds the exponent
Definition at line 839 of file exprinterpret_cppad.cpp.
References EPSISINT, SCIP_Real, and SCIPgetExponentExprPow().
Referenced by eval().
◆ evalIntPower()
|
static |
integer power operation for arbitrary integer exponents
- Parameters
-
resultant resultant arg operand exponent exponent
Definition at line 1286 of file exprinterpret_cppad.cpp.
References posintpower().
Referenced by eval().
◆ eval()
|
static |
CppAD compatible evaluation of an expression for given arguments
- Parameters
-
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 1333 of file exprinterpret_cppad.cpp.
References scip::abs(), EPSISINT, eval(), evalIntPower(), evalSignPower(), 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(), SCIPexprhdlrCreate(), SCIPexprintEval(), and SCIPincludeExprhdlr().
◆ cppaderrorcallback()
|
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
-
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 1462 of file exprinterpret_cppad.cpp.
References SCIPdebugMessage.
◆ errorhandler()
|
static |