Detailed Description
handler for sine and cosine expressions
The estimator/separator code always computes underestimators for sin(x). For overestimators of cos(x), we first reduce to underestimators of sin(x).
Overestimator for sin(x): Assume that a*y+b <= sin(y) for y in [-ub,-lb]. Then we have a*(-y)-b >= -sin(y) = sin(-y) for y in [-ub,-lb]. Thus, a*x-b >= sin(x) for x in [lb,ub].
Underestimator for cos(x): Assume that a*y+b <= sin(y) for y in [lb+pi/2,ub+pi/2]. Then we have a*(x+pi/2) + b <= sin(x+pi/2) = cos(x) for x in [lb,ub]. Thus, a*x + (b+a*pi/2) <= cos(x) for x in [lb,ub].
Overestimator for cos(x): Assume that a*z+b <= sin(z) for z in [-(ub+pi/2),-(lb+pi/2)]. Then, a*y-b >= sin(y) for y in [lb+pi/2,ub+pi/2]. Then, a*x-b+a*pi/2 >= cos(x) for x in [lb,ub].
Definition in file expr_trig.c.
Go to the source code of this file.
Macros | |
#define | SINEXPRHDLR_NAME "sin" |
#define | SINEXPRHDLR_DESC "sine expression" |
#define | SINEXPRHDLR_PRECEDENCE 91000 |
#define | SINEXPRHDLR_HASHKEY SCIPcalcFibHash(82457.0) |
#define | COSEXPRHDLR_NAME "cos" |
#define | COSEXPRHDLR_DESC "cosine expression" |
#define | COSEXPRHDLR_PRECEDENCE 92000 |
#define | COSEXPRHDLR_HASHKEY SCIPcalcFibHash(82463.0) |
#define | MAXCHILDABSVAL 1e+6 |
#define | NEWTON_NITERATIONS 100 |
#define | NEWTON_PRECISION 1e-12 |
Macro Definition Documentation
◆ SINEXPRHDLR_NAME
#define SINEXPRHDLR_NAME "sin" |
Definition at line 50 of file expr_trig.c.
Referenced by SCIP_DECL_EXPRESTIMATE(), SCIPcreateExprSin(), SCIPincludeExprhdlrSin(), and SCIPisExprSin().
◆ SINEXPRHDLR_DESC
#define SINEXPRHDLR_DESC "sine expression" |
Definition at line 51 of file expr_trig.c.
Referenced by SCIPincludeExprhdlrSin().
◆ SINEXPRHDLR_PRECEDENCE
#define SINEXPRHDLR_PRECEDENCE 91000 |
Definition at line 52 of file expr_trig.c.
Referenced by SCIPincludeExprhdlrSin().
◆ SINEXPRHDLR_HASHKEY
#define SINEXPRHDLR_HASHKEY SCIPcalcFibHash(82457.0) |
Definition at line 53 of file expr_trig.c.
Referenced by SCIP_DECL_EXPRHASH().
◆ COSEXPRHDLR_NAME
#define COSEXPRHDLR_NAME "cos" |
Definition at line 55 of file expr_trig.c.
Referenced by SCIP_DECL_EXPRESTIMATE(), SCIPcreateExprCos(), SCIPincludeExprhdlrCos(), and SCIPisExprCos().
◆ COSEXPRHDLR_DESC
#define COSEXPRHDLR_DESC "cosine expression" |
Definition at line 56 of file expr_trig.c.
Referenced by SCIPincludeExprhdlrCos().
◆ COSEXPRHDLR_PRECEDENCE
#define COSEXPRHDLR_PRECEDENCE 92000 |
Definition at line 57 of file expr_trig.c.
Referenced by SCIPincludeExprhdlrCos().
◆ COSEXPRHDLR_HASHKEY
#define COSEXPRHDLR_HASHKEY SCIPcalcFibHash(82463.0) |
Definition at line 58 of file expr_trig.c.
Referenced by SCIP_DECL_EXPRHASH().
◆ MAXCHILDABSVAL
#define MAXCHILDABSVAL 1e+6 |
maximum absolute value that is accepted for propagation
Definition at line 60 of file expr_trig.c.
Referenced by computeRevPropIntervalSin().
◆ NEWTON_NITERATIONS
#define NEWTON_NITERATIONS 100 |
Definition at line 61 of file expr_trig.c.
Referenced by computeLeftSecantSin(), computeRightSecantSin(), and computeSolTangentSin().
◆ NEWTON_PRECISION
#define NEWTON_PRECISION 1e-12 |
Definition at line 62 of file expr_trig.c.
Referenced by computeLeftSecantSin(), computeRightSecantSin(), and computeSolTangentSin().
Function Documentation
◆ SCIP_DECL_NEWTONEVAL() [1/4]
|
static |
evaluates the function a*x + b - sin(x) for some coefficient a and constant b at a given point p
the constants a and b are expected to be stored in that order in params
Definition at line 73 of file expr_trig.c.
References NULL.
◆ SCIP_DECL_NEWTONEVAL() [2/4]
|
static |
evaluates the derivative of a*x + b - sin(x) for some coefficient a and constant b at a given point p
the constants a and b are expected to be stored in that order in params
Definition at line 86 of file expr_trig.c.
References NULL.
◆ SCIP_DECL_NEWTONEVAL() [3/4]
|
static |
evaluates the function sin(x) + (alpha - x)*cos(x) - sin(alpha) for some constant alpha at a given point p
the constant alpha is expected to be stored in params
Definition at line 99 of file expr_trig.c.
References NULL.
◆ SCIP_DECL_NEWTONEVAL() [4/4]
|
static |
evaluates the derivative of sin(x) + (alpha - x)*cos(x) - sin(alpha) for some constant alpha at a given point p
the constant alpha is expected to be stored in params
Definition at line 112 of file expr_trig.c.
References NULL.
◆ computeSecantSin()
|
static |
helper function to compute the secant if it is a valid underestimator
returns true if the estimator was computed successfully
- Parameters
-
scip SCIP data structure lincoef buffer to store linear coefficient of secant linconst buffer to store linear constant of secant lb lower bound of argument variable ub upper bound of argument variable
Definition at line 125 of file expr_trig.c.
References FALSE, M_PI, NULL, and TRUE.
Referenced by computeEstimatorsTrig(), and computeInitialCutsTrig().
◆ computeLeftTangentSin()
|
static |
helper function to compute the tangent at lower bound if it is underestimating
returns true if the underestimator was computed successfully
- Parameters
-
scip SCIP data structure lincoef buffer to store linear coefficient of tangent linconst buffer to store linear constant of tangent lb lower bound of argument variable
Definition at line 157 of file expr_trig.c.
References FALSE, NULL, SCIPisInfinity(), and TRUE.
Referenced by computeInitialCutsTrig().
◆ computeRightTangentSin()
|
static |
helper function to compute the tangent at upper bound if it is an underestimator
returns true if the underestimator was computed successfully
- Parameters
-
scip SCIP data structure lincoef buffer to store linear coefficient of tangent linconst buffer to store linear constant of tangent ub upper bound of argument variable
Definition at line 190 of file expr_trig.c.
References FALSE, NULL, SCIPisInfinity(), and TRUE.
Referenced by computeInitialCutsTrig().
◆ computeSolTangentSin()
|
static |
helper function to compute the tangent at solution point if it is an underestimator
returns true if the underestimator was computed successfully
- Parameters
-
scip SCIP data structure lincoef buffer to store linear coefficient of tangent linconst buffer to store linear constant of tangent lb lower bound of argument variable ub upper bound of argument variable solpoint solution point to be separated
Definition at line 219 of file expr_trig.c.
References FALSE, M_PI, NEWTON_NITERATIONS, NEWTON_PRECISION, NULL, SCIP_INVALID, SCIP_Real, SCIPcalcRootNewton(), SCIPisEQ(), SCIPisGE(), SCIPisGT(), SCIPisZero(), and TRUE.
Referenced by computeEstimatorsTrig().
◆ computeLeftSecantSin()
|
static |
helper function to compute the secant between lower bound and some point of the graph such that it underestimates
returns true if the underestimator was computed successfully
- Parameters
-
scip SCIP data structure lincoef buffer to store linear coefficient of tangent linconst buffer to store linear constant of tangent lb lower bound of argument variable ub upper bound of argument variable
Definition at line 294 of file expr_trig.c.
References FALSE, M_PI, NEWTON_NITERATIONS, NEWTON_PRECISION, NULL, SCIP_INVALID, SCIP_Real, SCIPcalcRootNewton(), SCIPdebugMsg, SCIPisEQ(), SCIPisGE(), SCIPisInfinity(), SCIPisLE(), SCIPisZero(), and TRUE.
Referenced by computeEstimatorsTrig(), and computeInitialCutsTrig().
◆ computeRightSecantSin()
|
static |
helper function to compute the secant between upper bound and some point of the graph such that it underestimates
returns true if the underestimator was computed successfully
- Parameters
-
scip SCIP data structure lincoef buffer to store linear coefficient of tangent linconst buffer to store linear constant of tangent lb lower bound of argument variable ub upper bound of argument variable
Definition at line 381 of file expr_trig.c.
References FALSE, M_PI, NEWTON_NITERATIONS, NEWTON_PRECISION, NULL, SCIP_INVALID, SCIP_Real, SCIPcalcRootNewton(), SCIPisEQ(), SCIPisInfinity(), SCIPisLE(), SCIPisZero(), and TRUE.
Referenced by computeEstimatorsTrig(), and computeInitialCutsTrig().
◆ computeRevPropIntervalSin()
|
static |
helper function to compute the new interval for child in reverse propagation
- Parameters
-
scip SCIP data structure parentbounds bounds for sine expression childbounds bounds for child expression newbounds buffer to store new child bounds
Definition at line 463 of file expr_trig.c.
References a, SCIP_Interval::inf, M_PI, MAXCHILDABSVAL, SCIP_OKAY, SCIP_Real, SCIPintervalSetBounds(), SCIPintervalSetEmpty(), SCIPisFeasGE(), SCIPisFeasLE(), SCIPisGT(), SCIPisInfinity(), SCIPisLT(), and SCIP_Interval::sup.
Referenced by SCIP_DECL_EXPRREVERSEPROP().
◆ computeEstimatorsTrig()
|
static |
helper function to compute coefficients and constant term of a linear estimator at a given point
The function will try to compute the following estimators in that order:
- soltangent: tangent at specified refpoint
- secant: secant between the points (lb,sin(lb)) and (ub,sin(ub))
- left secant: secant between lower bound and some point of the graph
- right secant: secant between upper bound and some point of the graph
They are ordered such that a successful computation for one of them cannot be improved by following ones in terms of value at the reference point.
- Parameters
-
scip SCIP data structure expr sin or cos expression lincoef buffer to store the linear coefficient linconst buffer to store the constant term refpoint point at which to underestimate (can be SCIP_INVALID) childlb lower bound of child variable childub upper bound of child variable underestimate whether the estimator should be underestimating
Definition at line 559 of file expr_trig.c.
References computeLeftSecantSin(), computeRightSecantSin(), computeSecantSin(), computeSolTangentSin(), FALSE, NULL, SCIP_Bool, SCIP_Real, SCIPexprGetHdlr(), SCIPexprGetNChildren(), SCIPexprhdlrGetName(), SCIPisEQ(), SCIPisLE(), and TRUE.
Referenced by SCIP_DECL_EXPRESTIMATE().
◆ computeInitialCutsTrig()
|
static |
helper function to create initial cuts for sine and cosine separation
The following 5 cuts can be generated:
- secant: secant between the bounds (lb,sin(lb)) and (ub,sin(ub))
- left/right secant: secant between lower/upper bound and some point of the graph
- left/right tangent: tangents at the lower/upper bounds
- Parameters
-
scip SCIP data structure expr sin or cos expression childlb lower bound of child variable childub upper bound of child variable underestimate whether the cuts should be underestimating coefs buffer to store coefficients of computed estimators constant buffer to store constant of computed estimators nreturned buffer to store number of estimators that have been computed
Definition at line 639 of file expr_trig.c.
References computeLeftSecantSin(), computeLeftTangentSin(), computeRightSecantSin(), computeRightTangentSin(), computeSecantSin(), NULL, SCIP_Bool, SCIP_OKAY, SCIP_Real, SCIPexprGetHdlr(), SCIPexprGetNChildren(), SCIPexprhdlrGetName(), SCIPisEQ(), and SCIPisLE().
Referenced by SCIP_DECL_EXPRINITESTIMATES().
◆ computeCurvatureSin()
|
static |
- Parameters
-
childcurvature curvature of child lb lower bound of child ub upper bound of child
Definition at line 724 of file expr_trig.c.
References M_PI, SCIP_EXPRCURV_CONCAVE, SCIP_EXPRCURV_CONVEX, SCIP_EXPRCURV_LINEAR, SCIP_EXPRCURV_UNKNOWN, and SCIP_Real.
Referenced by SCIP_DECL_EXPRCURVATURE().
◆ SCIP_DECL_EXPRCOPYHDLR() [1/2]
|
static |
expression handler copy callback
Definition at line 779 of file expr_trig.c.
References SCIP_CALL, SCIP_OKAY, and SCIPincludeExprhdlrSin().
◆ SCIP_DECL_EXPRSIMPLIFY() [1/2]
|
static |
simplifies a sine expression
Evaluates the sine value function when its child is a value expression.
TODO: add further simplifications
Definition at line 793 of file expr_trig.c.
References NULL, SCIP_CALL, SCIP_OKAY, SCIPcaptureExpr(), SCIPcreateExprValue(), SCIPexprGetChildren(), SCIPexprGetNChildren(), SCIPgetValueExprValue(), and SCIPisExprValue().
◆ SCIP_DECL_EXPRPARSE() [1/2]
|
static |
expression parse callback
Definition at line 824 of file expr_trig.c.
References NULL, SCIP_CALL, SCIP_OKAY, SCIPcreateExprSin(), SCIPparseExpr(), SCIPreleaseExpr(), and TRUE.
◆ SCIP_DECL_EXPREVAL() [1/2]
|
static |
expression (point-) evaluation callback
Definition at line 848 of file expr_trig.c.
References NULL, SCIP_INVALID, SCIP_OKAY, SCIPexprGetChildren(), SCIPexprGetEvalValue(), and SCIPexprGetNChildren().
◆ SCIP_DECL_EXPRBWDIFF() [1/2]
|
static |
expression derivative evaluation callback
Definition at line 861 of file expr_trig.c.
References NULL, SCIP_INVALID, SCIP_OKAY, SCIPexprGetChildren(), SCIPexprGetEvalValue(), SCIPexprGetHdlr(), and SCIPexprhdlrGetName().
◆ SCIP_DECL_EXPRFWDIFF()
|
static |
derivative evaluation callback
Computes <gradient, children.dot>, that is, cos(child) dot(child).
Definition at line 883 of file expr_trig.c.
References NULL, SCIP_INVALID, SCIP_OKAY, SCIPexprGetChildren(), SCIPexprGetDot(), SCIPexprGetEvalValue(), SCIPexprGetHdlr(), and SCIPexprhdlrGetName().
◆ SCIP_DECL_EXPRBWFWDIFF()
|
static |
expression backward forward derivative evaluation callback
Computes partial/partial child ( <gradient, children.dot> ), that is, -sin(child) dot(child).
Definition at line 905 of file expr_trig.c.
References NULL, SCIP_INVALID, SCIP_OKAY, SCIPexprGetChildren(), SCIPexprGetDot(), SCIPexprGetEvalValue(), SCIPexprGetHdlr(), and SCIPexprhdlrGetName().
◆ SCIP_DECL_EXPRINTEVAL() [1/2]
|
static |
expression interval evaluation callback
Definition at line 925 of file expr_trig.c.
References NULL, SCIP_INTERVAL_INFINITY, SCIP_OKAY, SCIPexprGetActivity(), SCIPexprGetChildren(), SCIPexprGetNChildren(), SCIPintervalIsEmpty(), SCIPintervalSetEmpty(), and SCIPintervalSin().
◆ SCIP_DECL_EXPRINITESTIMATES() [1/2]
|
static |
separation initialization callback
Definition at line 944 of file expr_trig.c.
References computeInitialCutsTrig(), SCIP_CALL, SCIP_OKAY, SCIP_Real, and SCIPisRelEQ().
◆ SCIP_DECL_EXPRESTIMATE() [1/2]
|
static |
expression estimator callback
Definition at line 964 of file expr_trig.c.
References computeEstimatorsTrig(), NULL, SCIP_OKAY, SCIPexprGetHdlr(), SCIPexprGetNChildren(), SCIPexprhdlrGetName(), SINEXPRHDLR_NAME, and TRUE.
◆ SCIP_DECL_EXPRREVERSEPROP() [1/2]
|
static |
expression reverse propagation callback
Definition at line 986 of file expr_trig.c.
References computeRevPropIntervalSin(), NULL, SCIP_CALL, SCIP_OKAY, SCIPexprGetNChildren(), SCIPintervalGetInf(), and SCIPintervalGetSup().
◆ SCIP_DECL_EXPRHASH() [1/2]
|
static |
sine hash callback
Definition at line 1002 of file expr_trig.c.
References NULL, SCIP_OKAY, SCIPexprGetNChildren(), and SINEXPRHDLR_HASHKEY.
◆ SCIP_DECL_EXPRCURVATURE() [1/2]
|
static |
expression curvature detection callback
Definition at line 1018 of file expr_trig.c.
References computeCurvatureSin(), FALSE, SCIP_Interval::inf, NULL, SCIP_CALL, SCIP_EXPRCURV_CONCAVE, SCIP_EXPRCURV_CONVEX, SCIP_EXPRCURV_LINEAR, SCIP_OKAY, SCIPevalExprActivity(), SCIPexprGetActivity(), SCIPexprGetChildren(), SCIPexprGetNChildren(), SCIP_Interval::sup, and TRUE.
◆ SCIP_DECL_EXPRMONOTONICITY() [1/2]
|
static |
expression monotonicity detection callback
Definition at line 1050 of file expr_trig.c.
References M_PI, NULL, SCIP_CALL, SCIP_MONOTONE_DEC, SCIP_MONOTONE_INC, SCIP_MONOTONE_UNKNOWN, SCIP_OKAY, SCIP_Real, SCIPevalExprActivity(), SCIPexprGetActivity(), SCIPexprGetChildren(), SCIPintervalGetInf(), and SCIPintervalGetSup().
◆ SCIP_DECL_EXPRCOPYHDLR() [2/2]
|
static |
expression handler copy callback
Definition at line 1089 of file expr_trig.c.
References SCIP_CALL, SCIP_OKAY, and SCIPincludeExprhdlrCos().
◆ SCIP_DECL_EXPRSIMPLIFY() [2/2]
|
static |
simplifies a cosine expression
Evaluates the cosine value function when its child is a value expression.
TODO: add further simplifications
Definition at line 1103 of file expr_trig.c.
References NULL, SCIP_CALL, SCIP_OKAY, SCIPcaptureExpr(), SCIPcreateExprValue(), SCIPexprGetChildren(), SCIPexprGetNChildren(), SCIPgetValueExprValue(), and SCIPisExprValue().
◆ SCIP_DECL_EXPRPARSE() [2/2]
|
static |
expression parse callback
Definition at line 1134 of file expr_trig.c.
References NULL, SCIP_CALL, SCIP_OKAY, SCIPcreateExprCos(), SCIPparseExpr(), SCIPreleaseExpr(), and TRUE.
◆ SCIP_DECL_EXPREVAL() [2/2]
|
static |
expression (point-) evaluation callback
Definition at line 1158 of file expr_trig.c.
References NULL, SCIP_INVALID, SCIP_OKAY, SCIPexprGetChildren(), SCIPexprGetEvalValue(), and SCIPexprGetNChildren().
◆ SCIP_DECL_EXPRBWDIFF() [2/2]
|
static |
expression derivative evaluation callback
Definition at line 1171 of file expr_trig.c.
References NULL, SCIP_INVALID, SCIP_OKAY, SCIPexprGetChildren(), SCIPexprGetEvalValue(), SCIPexprGetHdlr(), and SCIPexprhdlrGetName().
◆ SCIP_DECL_EXPRINTEVAL() [2/2]
|
static |
expression interval evaluation callback
Definition at line 1190 of file expr_trig.c.
References NULL, SCIP_INTERVAL_INFINITY, SCIP_OKAY, SCIPexprGetActivity(), SCIPexprGetChildren(), SCIPexprGetNChildren(), SCIPintervalCos(), SCIPintervalIsEmpty(), and SCIPintervalSetEmpty().
◆ SCIP_DECL_EXPRINITESTIMATES() [2/2]
|
static |
separation initialization callback
Definition at line 1209 of file expr_trig.c.
References computeInitialCutsTrig(), SCIP_CALL, SCIP_OKAY, SCIP_Real, and SCIPisRelEQ().
◆ SCIP_DECL_EXPRESTIMATE() [2/2]
|
static |
expression estimator callback
Definition at line 1229 of file expr_trig.c.
References computeEstimatorsTrig(), COSEXPRHDLR_NAME, NULL, SCIP_OKAY, SCIPexprGetHdlr(), SCIPexprGetNChildren(), SCIPexprhdlrGetName(), and TRUE.
◆ SCIP_DECL_EXPRREVERSEPROP() [2/2]
|
static |
expression reverse propagation callback
Definition at line 1251 of file expr_trig.c.
References computeRevPropIntervalSin(), NULL, SCIP_CALL, SCIP_INTERVAL_INFINITY, SCIP_OKAY, SCIPexprGetNChildren(), SCIPintervalAddScalar(), SCIPintervalGetInf(), SCIPintervalGetSup(), SCIPintervalIsEmpty(), and TRUE.
◆ SCIP_DECL_EXPRHASH() [2/2]
|
static |
cosine hash callback
Definition at line 1285 of file expr_trig.c.
References COSEXPRHDLR_HASHKEY, NULL, SCIP_OKAY, and SCIPexprGetNChildren().
◆ SCIP_DECL_EXPRCURVATURE() [2/2]
|
static |
expression curvature detection callback
Definition at line 1301 of file expr_trig.c.
References computeCurvatureSin(), FALSE, SCIP_Interval::inf, NULL, SCIP_CALL, SCIP_EXPRCURV_CONCAVE, SCIP_EXPRCURV_CONVEX, SCIP_EXPRCURV_LINEAR, SCIP_EXPRCURV_UNKNOWN, SCIP_OKAY, SCIPevalExprActivity(), SCIPexprGetActivity(), SCIPexprGetChildren(), SCIPexprGetNChildren(), SCIP_Interval::sup, and TRUE.
◆ SCIP_DECL_EXPRMONOTONICITY() [2/2]
|
static |
expression monotonicity detection callback
Definition at line 1334 of file expr_trig.c.
References M_PI, NULL, SCIP_CALL, SCIP_MONOTONE_DEC, SCIP_MONOTONE_INC, SCIP_MONOTONE_UNKNOWN, SCIP_OKAY, SCIP_Real, SCIPevalExprActivity(), SCIPexprGetActivity(), SCIPexprGetChildren(), SCIPintervalGetInf(), and SCIPintervalGetSup().