51#define _USE_MATH_DEFINES
58#define SINEXPRHDLR_NAME "sin"
59#define SINEXPRHDLR_DESC "sine expression"
60#define SINEXPRHDLR_PRECEDENCE 91000
61#define SINEXPRHDLR_HASHKEY SCIPcalcFibHash(82457.0)
63#define COSEXPRHDLR_NAME "cos"
64#define COSEXPRHDLR_DESC "cosine expression"
65#define COSEXPRHDLR_PRECEDENCE 92000
66#define COSEXPRHDLR_HASHKEY SCIPcalcFibHash(82463.0)
68#define MAXCHILDABSVAL 1e+6
69#define NEWTON_NITERATIONS 100
70#define NEWTON_PRECISION 1e-12
86 return params[0]*point + params[1] - sin(point);
99 return params[0] - cos(point);
112 return sin(point) + (params[0] - point) * cos(point) - sin(params[0]);
125 return (point - params[0]) * sin(point);
147 if( ub - lb >=
M_PI )
151 if( sin(lb) < 0.0 || sin(ub) < 0.0 || (sin(lb) == 0.0 && cos(lb) < 0.0) )
154 *lincoef = (sin(ub) - sin(lb)) / (ub - lb);
155 *linconst = sin(ub) - (*lincoef) * ub;
180 if( sin(lb) > 0.0 || cos(lb) >= 0.0 )
184 *linconst = sin(lb) - (*lincoef) * lb;
213 if( sin(ub) > 0.0 || cos(ub) <= 0.0 )
217 *linconst = sin(ub) - (*lincoef) * ub;
247 if( sin(solpoint) > 0.0 )
251 solpointmodpi = fmod(solpoint,
M_PI);
253 solpointmodpi +=
M_PI;
260 params[0] = cos(solpoint);
261 params[1] = sin(solpoint) - params[0] * solpoint;
266 startingpoints[0] = solpoint + (
M_PI - solpointmodpi) + M_PI_2;
267 startingpoints[1] = startingpoints[0] + M_PI_2;
268 startingpoints[2] = startingpoints[1] + M_PI_2;
272 startingpoints[0] = solpoint - solpointmodpi - M_PI_2;
273 startingpoints[1] = startingpoints[0] - M_PI_2;
274 startingpoints[2] = startingpoints[1] - M_PI_2;
278 for(
i = 0;
i < 3; ++
i )
288 if( intersection ==
SCIP_INVALID || (intersection >= lb && intersection <= ub) )
291 *lincoef = params[0];
292 *linconst = params[1];
323 lbmodpi = fmod(lb,
M_PI);
334 startingpoint = lb + 1.25*
M_PI - lbmodpi;
343 startingpoint = lb + 1.25*
M_PI;
344 else if( sin(lb) < 0.0 )
345 startingpoint = lb + 2.25*
M_PI - lbmodpi;
347 startingpoint = lb + 1.25*
M_PI - lbmodpi;
364 if(
SCIPisLE(
scip, sin(0.5 * (ub + lb)), sin(lb) + 0.5*(sin(ub) - sin(lb))) )
372 *lincoef = (sin(tangentpoint) - sin(lb)) / (tangentpoint - lb);
373 *linconst = sin(lb) - (*lincoef) * lb;
376 if( *lincoef >= cos(lb) )
379 SCIPdebugMsg(
scip,
"left secant: %g + %g*x <= sin(x) on [%g,%g]\n", *linconst, *lincoef, lb, ub);
410 ubmodpi = fmod(ub,
M_PI);
421 startingpoint = ub - M_PI_4 - ubmodpi;
430 startingpoint = ub - 1.25*
M_PI;
431 else if( sin(ub) < 0.0 )
432 startingpoint = ub - 1.25*
M_PI - ubmodpi;
434 startingpoint = ub - M_PI_4 - ubmodpi;
451 if(
SCIPisLE(
scip, sin(0.5 * (ub + lb)), sin(lb) + 0.5*(sin(ub) - sin(lb))) )
459 *lincoef = (sin(tangentpoint) - sin(ub)) / (tangentpoint - ub);
460 *linconst = sin(ub) - (*lincoef) * ub;
463 if( *lincoef <= cos(lb) )
500 int k = (int) ceil((newinf -
a) / (2.0*
M_PI));
501 newinf =
a + 2.0*
M_PI * k;
510 int k = (int) ceil((newinf +
a) / (2.0*
M_PI) - 0.5);
511 newinf =
M_PI * (2.0*k + 1.0) -
a;
527 int k = (int) ceil((newsup -
a ) / (2.0*
M_PI)) - 1;
528 newsup =
a + 2.0*
M_PI * k;
537 int k = (int) ceil((newsup +
a) / (2.0*
M_PI) - 0.5) - 1;
538 newsup =
M_PI * (2.0*k + 1.0) -
a;
547 if( newinf <= newsup )
634 (*linconst) += (*lincoef) * M_PI_2;
689 if( ! underestimate )
716 for(
i = 0;
i < *nreturned; ++
i )
718 if( ! underestimate )
723 constant[
i] += coefs[
i][0] * M_PI_2;
744 if( (ub - lb <=
M_PI) && (lbsin * ubsin >= 0.0) )
747 if( lbsin == 0.0 && ubsin == 0.0 )
754 else if( lbcos * ubcos >= 0.0 )
821 *simplifiedexpr = expr;
957 childlb = bounds[0].inf;
958 childub = bounds[0].sup;
987 localbounds[0].sup, ! overestimate);
1020 *hashkey ^= childrenhashes[0];
1084 k = (int)floor(inf/
M_PI - 0.5);
1132 *simplifiedexpr = expr;
1223 childlb = bounds[0].inf;
1224 childub = bounds[0].sup;
1253 localbounds[0].sup, ! overestimate);
1273 newbounds = childrenbounds[0];
1304 *hashkey ^= childrenhashes[0];
1369 k = (int)floor(inf/
M_PI);
1436 void* ownercreatedata
1456 void* ownercreatedata
#define SCIP_INTERVAL_INFINITY
#define SCIP_STRINGEQ(name, reference, retcode)
static SCIP_Bool computeEstimatorsTrig(SCIP *scip, SCIP_EXPR *expr, SCIP_Real *lincoef, SCIP_Real *linconst, SCIP_Real refpoint, SCIP_Real childlb, SCIP_Real childub, SCIP_Bool underestimate)
static SCIP_Bool computeRightSecantSin(SCIP *scip, SCIP_Real *lincoef, SCIP_Real *linconst, SCIP_Real lb, SCIP_Real ub)
#define SINEXPRHDLR_PRECEDENCE
static SCIP_RETCODE computeRevPropIntervalSin(SCIP *scip, SCIP_INTERVAL parentbounds, SCIP_INTERVAL childbounds, SCIP_INTERVAL *newbounds)
#define SINEXPRHDLR_HASHKEY
static SCIP_EXPRCURV computeCurvatureSin(SCIP_EXPRCURV childcurvature, SCIP_Real lb, SCIP_Real ub)
#define COSEXPRHDLR_HASHKEY
#define NEWTON_NITERATIONS
static SCIP_Bool computeLeftSecantSin(SCIP *scip, SCIP_Real *lincoef, SCIP_Real *linconst, SCIP_Real lb, SCIP_Real ub)
static SCIP_RETCODE computeInitialCutsTrig(SCIP *scip, SCIP_EXPR *expr, SCIP_Real childlb, SCIP_Real childub, SCIP_Bool underestimate, SCIP_Real **coefs, SCIP_Real *constant, int *nreturned)
static SCIP_Bool computeSecantSin(SCIP *scip, SCIP_Real *lincoef, SCIP_Real *linconst, SCIP_Real lb, SCIP_Real ub)
#define COSEXPRHDLR_PRECEDENCE
static SCIP_Bool computeRightTangentSin(SCIP *scip, SCIP_Real *lincoef, SCIP_Real *linconst, SCIP_Real ub)
static SCIP_Bool computeLeftTangentSin(SCIP *scip, SCIP_Real *lincoef, SCIP_Real *linconst, SCIP_Real lb)
static SCIP_Bool computeSolTangentSin(SCIP *scip, SCIP_Real *lincoef, SCIP_Real *linconst, SCIP_Real lb, SCIP_Real ub, SCIP_Real solpoint)
handler for sin expressions
constant value expression handler
SCIP_RETCODE SCIPcreateExprSin(SCIP *scip, SCIP_EXPR **expr, SCIP_EXPR *child, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
SCIP_RETCODE SCIPcreateExprCos(SCIP *scip, SCIP_EXPR **expr, SCIP_EXPR *child, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
SCIP_Bool SCIPisExprCos(SCIP *scip, SCIP_EXPR *expr)
SCIP_Bool SCIPisExprSin(SCIP *scip, SCIP_EXPR *expr)
SCIP_RETCODE SCIPcreateExprValue(SCIP *scip, SCIP_EXPR **expr, SCIP_Real value, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
SCIP_RETCODE SCIPincludeExprhdlrCos(SCIP *scip)
SCIP_RETCODE SCIPincludeExprhdlrSin(SCIP *scip)
SCIP_Real SCIPcalcRootNewton(SCIP_DECL_NEWTONEVAL((*function)), SCIP_DECL_NEWTONEVAL((*derivative)), SCIP_Real *params, int nparams, SCIP_Real x, SCIP_Real eps, int k)
const char * SCIPexprhdlrGetName(SCIP_EXPRHDLR *exprhdlr)
void SCIPexprhdlrSetCurvature(SCIP_EXPRHDLR *exprhdlr,)
void SCIPexprhdlrSetParse(SCIP_EXPRHDLR *exprhdlr,)
void SCIPexprhdlrSetIntEval(SCIP_EXPRHDLR *exprhdlr,)
void SCIPexprhdlrSetMonotonicity(SCIP_EXPRHDLR *exprhdlr,)
void SCIPexprhdlrSetReverseProp(SCIP_EXPRHDLR *exprhdlr,)
void SCIPexprhdlrSetHash(SCIP_EXPRHDLR *exprhdlr,)
SCIP_RETCODE SCIPincludeExprhdlr(SCIP *scip, SCIP_EXPRHDLR **exprhdlr, const char *name, const char *desc, unsigned int precedence, SCIP_DECL_EXPREVAL((*eval)), SCIP_EXPRHDLRDATA *data)
void SCIPexprhdlrSetSimplify(SCIP_EXPRHDLR *exprhdlr,)
void SCIPexprhdlrSetDiff(SCIP_EXPRHDLR *exprhdlr, SCIP_DECL_EXPRBWDIFF((*bwdiff)), SCIP_DECL_EXPRFWDIFF((*fwdiff)),)
void SCIPexprhdlrSetCopyFreeHdlr(SCIP_EXPRHDLR *exprhdlr, SCIP_DECL_EXPRCOPYHDLR((*copyhdlr)),)
SCIP_EXPRHDLR * SCIPfindExprhdlr(SCIP *scip, const char *name)
void SCIPexprhdlrSetEstimate(SCIP_EXPRHDLR *exprhdlr, SCIP_DECL_EXPRINITESTIMATES((*initestimates)),)
SCIP_RETCODE SCIPcreateExpr(SCIP *scip, SCIP_EXPR **expr, SCIP_EXPRHDLR *exprhdlr, SCIP_EXPRDATA *exprdata, int nchildren, SCIP_EXPR **children, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
int SCIPexprGetNChildren(SCIP_EXPR *expr)
SCIP_Bool SCIPisExprValue(SCIP *scip, SCIP_EXPR *expr)
SCIP_RETCODE SCIPreleaseExpr(SCIP *scip, SCIP_EXPR **expr)
SCIP_Real SCIPexprGetDot(SCIP_EXPR *expr)
SCIP_RETCODE SCIPparseExpr(SCIP *scip, SCIP_EXPR **expr, const char *exprstr, const char **finalpos, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
SCIP_Real SCIPgetValueExprValue(SCIP_EXPR *expr)
SCIP_Real SCIPexprGetEvalValue(SCIP_EXPR *expr)
SCIP_EXPR ** SCIPexprGetChildren(SCIP_EXPR *expr)
SCIP_INTERVAL SCIPexprGetActivity(SCIP_EXPR *expr)
void SCIPcaptureExpr(SCIP_EXPR *expr)
SCIP_RETCODE SCIPevalExprActivity(SCIP *scip, SCIP_EXPR *expr)
SCIP_EXPRHDLR * SCIPexprGetHdlr(SCIP_EXPR *expr)
SCIP_Real SCIPintervalGetInf(SCIP_INTERVAL interval)
void SCIPintervalCos(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand)
SCIP_Bool SCIPintervalIsEmpty(SCIP_Real infinity, SCIP_INTERVAL operand)
void SCIPintervalSin(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand)
void SCIPintervalSetBounds(SCIP_INTERVAL *resultant, SCIP_Real inf, SCIP_Real sup)
struct SCIP_Interval SCIP_INTERVAL
void SCIPintervalAddScalar(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_INTERVAL operand1, SCIP_Real operand2)
SCIP_Real SCIPintervalGetSup(SCIP_INTERVAL interval)
void SCIPintervalSetEmpty(SCIP_INTERVAL *resultant)
SCIP_Bool SCIPisRelEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisFeasGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
assert(minobj< SCIPgetCutoffbound(scip))
struct SCIP_Expr SCIP_EXPR
#define SCIP_DECL_EXPR_OWNERCREATE(x)
#define SCIP_DECL_EXPRREVERSEPROP(x)
#define SCIP_DECL_EXPRINITESTIMATES(x)
#define SCIP_DECL_EXPRBWFWDIFF(x)
#define SCIP_DECL_EXPRCURVATURE(x)
#define SCIP_DECL_EXPRPARSE(x)
#define SCIP_DECL_EXPRBWDIFF(x)
#define SCIP_DECL_EXPRINTEVAL(x)
#define SCIP_DECL_EXPRMONOTONICITY(x)
struct SCIP_Exprhdlr SCIP_EXPRHDLR
#define SCIP_DECL_EXPRSIMPLIFY(x)
#define SCIP_DECL_EXPREVAL(x)
#define SCIP_DECL_EXPRFWDIFF(x)
#define SCIP_DECL_EXPRHASH(x)
#define SCIP_DECL_EXPRCOPYHDLR(x)
#define SCIP_DECL_EXPRESTIMATE(x)
#define SCIP_DECL_NEWTONEVAL(x)
enum SCIP_Retcode SCIP_RETCODE