|
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
exprinterpret_cppad.cpp File Reference Detailed Descriptionmethods to interpret (evaluate) an expression tree "fast" using CppAD 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.
Macro Definition Documentation
Definition at line 60 of file exprinterpret_cppad.cpp.
Definition at line 71 of file exprinterpret_cppad.cpp. Referenced by init_parallel(). Function Documentation
CppAD callback function that indicates whether we are running in parallel mode Definition at line 118 of file exprinterpret_cppad.cpp. References ncurthreads. Referenced by init_parallel().
CppAD callback function that returns the number of the current thread assigns a new number to the thread if new Definition at line 128 of file exprinterpret_cppad.cpp. References cppadmutex, ncurthreads, NULL, SCIPdebugMessage, and thread_specific_key. Referenced by init_parallel().
sets up CppAD's datastructures for running in multithreading mode It must be called once before multithreading is started. Definition at line 170 of file exprinterpret_cppad.cpp. References CPPAD_MAX_NUM_THREADS, in_parallel(), NULL, thread_num(), and thread_specific_key.
definition of CondExpOp for SCIPInterval (required by CppAD) Definition at line 191 of file exprinterpret_cppad.cpp.
another function that returns whether two intervals are the same (required by CppAD)
Definition at line 208 of file exprinterpret_cppad.cpp.
another function required by CppAD
Definition at line 218 of file exprinterpret_cppad.cpp.
returns whether the interval equals [0,0]
Definition at line 227 of file exprinterpret_cppad.cpp.
returns whether the interval equals [1,1]
Definition at line 236 of file exprinterpret_cppad.cpp.
yet another function that checks whether two intervals are equal
Definition at line 245 of file exprinterpret_cppad.cpp.
greater than zero not defined for intervals
Definition at line 255 of file exprinterpret_cppad.cpp.
greater than or equal zero not defined for intervals
Definition at line 269 of file exprinterpret_cppad.cpp.
less than not defined for intervals
Definition at line 283 of file exprinterpret_cppad.cpp.
less than or equal not defined for intervals
Definition at line 297 of file exprinterpret_cppad.cpp.
conversion to integers not defined for intervals
Definition at line 311 of file exprinterpret_cppad.cpp.
printing of an interval (required by CppAD) Definition at line 325 of file exprinterpret_cppad.cpp. References SCIP_Interval::inf, and SCIP_Interval::sup.
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.
Definition at line 383 of file exprinterpret_cppad.cpp.
Computes sparsity of jacobian during a reverse sweep For a q x 1 matrix R, we have to return the sparsity pattern of the q x 1 matrix S(x) = R * f'(x). Since f'(x) is dense, the sparsity of S will be the sparsity of R.
Definition at line 403 of file exprinterpret_cppad.cpp.
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)))'.
Definition at line 423 of file exprinterpret_cppad.cpp.
template<class Type >
power function with natural exponents
Definition at line 682 of file exprinterpret_cppad.cpp. Referenced by eval(), evalAbs(), and evalIntPower().
template<class Type >
template for evaluation for signpower operator
Definition at line 1149 of file exprinterpret_cppad.cpp. Referenced by eval().
template<class Type >
template for evaluation for minimum operator Only implemented for real numbers, thus gives error by default.
Definition at line 1214 of file exprinterpret_cppad.cpp. Referenced by eval().
template<>
specialization of minimum evaluation for real numbers
Definition at line 1228 of file exprinterpret_cppad.cpp. References MIN.
template<class Type >
template for evaluation for maximum operator Only implemented for real numbers, thus gives error by default.
Definition at line 1244 of file exprinterpret_cppad.cpp. Referenced by eval().
template<>
specialization of maximum evaluation for real numbers
Definition at line 1258 of file exprinterpret_cppad.cpp. References MAX. template for evaluation for square-root operator Default is to use the standard sqrt-function.
Definition at line 1273 of file exprinterpret_cppad.cpp. References sqrt(). Referenced by eval().
template<>
specialization of square-root operator for numbers We perturb the function a little bit so that it's derivatives are defined in 0.0.
Definition at line 1286 of file exprinterpret_cppad.cpp. References sqrt(). template for evaluation for absolute value operator
Definition at line 1297 of file exprinterpret_cppad.cpp. References abs(). Referenced by eval().
template<>
specialization of absolute value evaluation for intervals Use sqrt(x^2) for now
Definition at line 1310 of file exprinterpret_cppad.cpp. References posintpower(), and sqrt().
template<class Type >
integer power operation for arbitrary integer exponents
Definition at line 1326 of file exprinterpret_cppad.cpp. References posintpower(). Referenced by eval().
template<class Type >
CppAD compatible evaluation of an expression for given arguments and parameters
Definition at line 1373 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().
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 1682 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().
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.
Definition at line 1717 of file exprinterpret_cppad.cpp. References SCIPdebugMessage.
gets name and version of expression interpreter Definition at line 1732 of file exprinterpret_cppad.cpp.
gets descriptive text of expression interpreter Definition at line 1738 of file exprinterpret_cppad.cpp.
gets capabilities of expression interpreter (using bitflags) Definition at line 1744 of file exprinterpret_cppad.cpp. References SCIP_EXPRINTCAPABILITY_FUNCVALUE, SCIP_EXPRINTCAPABILITY_GRADIENT, SCIP_EXPRINTCAPABILITY_HESSIAN, SCIP_EXPRINTCAPABILITY_INTFUNCVALUE, and SCIP_EXPRINTCAPABILITY_INTGRADIENT.
creates an expression interpreter object
Definition at line 1754 of file exprinterpret_cppad.cpp. References BMSallocMemory, NULL, SCIP_NOMEMORY, and SCIP_OKAY.
frees an expression interpreter object
Definition at line 1771 of file exprinterpret_cppad.cpp. References BMSfreeMemory, NULL, and SCIP_OKAY.
compiles an expression tree and stores compiled data in expression tree
Definition at line 1784 of file exprinterpret_cppad.cpp. References SCIP_ExprInt::blkmem, needAlwaysRetape(), NULL, SCIP_CALL, SCIP_OKAY, SCIPdebugMessage, SCIPexprCopyDeep(), SCIPexprFreeDeep(), SCIPexprtreeGetInterpreterData(), SCIPexprtreeGetNVars(), SCIPexprtreeGetRoot(), and SCIPexprtreeSetInterpreterData().
frees interpreter data
Definition at line 1832 of file exprinterpret_cppad.cpp. References NULL, SCIP_OKAY, and SCIPexprFreeDeep().
notify expression interpreter that a new parameterization is used This probably causes retaping by AD algorithms.
Definition at line 1852 of file exprinterpret_cppad.cpp. References NULL, SCIP_OKAY, and SCIPexprtreeGetInterpreterData().
evaluates an expression tree
Definition at line 1871 of file exprinterpret_cppad.cpp. References eval(), NULL, SCIP_CALL, SCIP_OKAY, SCIPdebugMessage, SCIPexprtreeGetInterpreterData(), SCIPexprtreeGetNVars(), SCIPexprtreeGetParamVals(), and SCIPexprtreeGetRoot(). Referenced by SCIPexprintGrad(), SCIPexprintHessianDense(), and SCIPexprintHessianSparsityDense().
evaluates an expression tree on intervals
Definition at line 1933 of file exprinterpret_cppad.cpp. References eval(), NULL, SCIP_CALL, SCIP_OKAY, SCIPexprtreeGetInterpreterData(), SCIPexprtreeGetNVars(), SCIPexprtreeGetParamVals(), and SCIPexprtreeGetRoot(). Referenced by SCIPexprintGradInt().
computes value and gradient of an expression tree
Definition at line 1993 of file exprinterpret_cppad.cpp. References FALSE, NULL, SCIP_CALL, SCIP_OKAY, SCIPexprintEval(), SCIPexprtreeGetInterpreterData(), and SCIPexprtreeGetNVars().
computes interval value and interval gradient of an expression tree
Definition at line 2037 of file exprinterpret_cppad.cpp. References NULL, SCIP_CALL, SCIP_OKAY, SCIPexprintEvalInt(), SCIPexprtreeGetInterpreterData(), and SCIPexprtreeGetNVars().
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.
Definition at line 2084 of file exprinterpret_cppad.cpp. References NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPdebugMessage, SCIPexprintEval(), SCIPexprtreeGetInterpreterData(), SCIPexprtreeGetNVars(), and TRUE.
computes value and dense hessian of an expression tree The full hessian is computed (lower left and upper right triangle).
Definition at line 2154 of file exprinterpret_cppad.cpp. References FALSE, NULL, SCIP_CALL, SCIP_OKAY, SCIPexprintEval(), SCIPexprtreeGetInterpreterData(), and SCIPexprtreeGetNVars(). Variable Documentation
mutex for locking in pthread case Definition at line 108 of file exprinterpret_cppad.cpp. Referenced by thread_num().
key for accessing thread specific information Definition at line 111 of file exprinterpret_cppad.cpp. Referenced by init_parallel(), and thread_num().
currently registered number of threads Definition at line 114 of file exprinterpret_cppad.cpp. Referenced by in_parallel(), and thread_num().
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 185 of file exprinterpret_cppad.cpp. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||