51#define _USE_MATH_DEFINES
59#define SINEXPRHDLR_NAME "sin"
60#define SINEXPRHDLR_DESC "sine expression"
61#define SINEXPRHDLR_PRECEDENCE 91000
62#define SINEXPRHDLR_HASHKEY SCIPcalcFibHash(82457.0)
64#define COSEXPRHDLR_NAME "cos"
65#define COSEXPRHDLR_DESC "cosine expression"
66#define COSEXPRHDLR_PRECEDENCE 92000
67#define COSEXPRHDLR_HASHKEY SCIPcalcFibHash(82463.0)
69#define MAXCHILDABSVAL 1e+6
70#define NEWTON_NITERATIONS 100
71#define NEWTON_PRECISION 1e-12
87 return params[0]*point + params[1] - sin(point);
100 return params[0] - cos(point);
113 return sin(point) + (params[0] - point) * cos(point) - sin(params[0]);
126 return (point - params[0]) * sin(point);
148 if( ub - lb >=
M_PI )
152 if( sin(lb) < 0.0 || sin(ub) < 0.0 || (sin(lb) == 0.0 && cos(lb) < 0.0) )
155 *lincoef = (sin(ub) - sin(lb)) / (ub - lb);
156 *linconst = sin(ub) - (*lincoef) * ub;
181 if( sin(lb) > 0.0 || cos(lb) >= 0.0 )
185 *linconst = sin(lb) - (*lincoef) * lb;
214 if( sin(ub) > 0.0 || cos(ub) <= 0.0 )
218 *linconst = sin(ub) - (*lincoef) * ub;
238 SCIP_Real startingpoints[3];
239 SCIP_Real solpointmodpi;
240 SCIP_Real intersection;
248 if( sin(solpoint) > 0.0 )
252 solpointmodpi = fmod(solpoint,
M_PI);
254 solpointmodpi +=
M_PI;
261 params[0] = cos(solpoint);
262 params[1] = sin(solpoint) - params[0] * solpoint;
267 startingpoints[0] = solpoint + (
M_PI - solpointmodpi) + M_PI_2;
268 startingpoints[1] = startingpoints[0] + M_PI_2;
269 startingpoints[2] = startingpoints[1] + M_PI_2;
273 startingpoints[0] = solpoint - solpointmodpi - M_PI_2;
274 startingpoints[1] = startingpoints[0] - M_PI_2;
275 startingpoints[2] = startingpoints[1] - M_PI_2;
279 for(
i = 0;
i < 3; ++
i )
289 if( intersection ==
SCIP_INVALID || (intersection >= lb && intersection <= ub) )
292 *lincoef = params[0];
293 *linconst = params[1];
312 SCIP_Real tangentpoint;
313 SCIP_Real startingpoint;
324 lbmodpi = fmod(lb,
M_PI);
335 startingpoint = lb + 1.25*
M_PI - lbmodpi;
344 startingpoint = lb + 1.25*
M_PI;
345 else if( sin(lb) < 0.0 )
346 startingpoint = lb + 2.25*
M_PI - lbmodpi;
348 startingpoint = lb + 1.25*
M_PI - lbmodpi;
365 if(
SCIPisLE(
scip, sin(0.5 * (ub + lb)), sin(lb) + 0.5*(sin(ub) - sin(lb))) )
373 *lincoef = (sin(tangentpoint) - sin(lb)) / (tangentpoint - lb);
374 *linconst = sin(lb) - (*lincoef) * lb;
377 if( *lincoef >= cos(lb) )
380 SCIPdebugMsg(
scip,
"left secant: %g + %g*x <= sin(x) on [%g,%g]\n", *linconst, *lincoef, lb, ub);
399 SCIP_Real tangentpoint;
400 SCIP_Real startingpoint;
411 ubmodpi = fmod(ub,
M_PI);
422 startingpoint = ub - M_PI_4 - ubmodpi;
431 startingpoint = ub - 1.25*
M_PI;
432 else if( sin(ub) < 0.0 )
433 startingpoint = ub - 1.25*
M_PI - ubmodpi;
435 startingpoint = ub - M_PI_4 - ubmodpi;
452 if(
SCIPisLE(
scip, sin(0.5 * (ub + lb)), sin(lb) + 0.5*(sin(ub) - sin(lb))) )
460 *lincoef = (sin(tangentpoint) - sin(ub)) / (tangentpoint - ub);
461 *linconst = sin(ub) - (*lincoef) * ub;
464 if( *lincoef <= cos(lb) )
479 SCIP_Real newinf = childbounds.
inf;
480 SCIP_Real newsup = childbounds.
sup;
500 SCIP_Real
a = asin(parentbounds.
inf);
501 int k = (int) ceil((newinf -
a) / (2.0*
M_PI));
502 newinf =
a + 2.0*
M_PI * k;
510 SCIP_Real
a = asin(parentbounds.
sup);
511 int k = (int) ceil((newinf +
a) / (2.0*
M_PI) - 0.5);
512 newinf =
M_PI * (2.0*k + 1.0) -
a;
527 SCIP_Real
a = asin(parentbounds.
sup);
528 int k = (int) ceil((newsup -
a ) / (2.0*
M_PI)) - 1;
529 newsup =
a + 2.0*
M_PI * k;
537 SCIP_Real
a = asin(parentbounds.
inf);
538 int k = (int) ceil((newsup +
a) / (2.0*
M_PI) - 0.5) - 1;
539 newsup =
M_PI * (2.0*k + 1.0) -
a;
548 if( newinf <= newsup )
576 SCIP_Bool underestimate
605 SCIP_Real tmp = childlb;
635 (*linconst) += (*lincoef) * M_PI_2;
653 SCIP_Bool underestimate,
690 if( ! underestimate )
717 for(
i = 0;
i < *nreturned; ++
i )
719 if( ! underestimate )
724 constant[
i] += coefs[
i][0] * M_PI_2;
739 SCIP_Real lbsin = sin(lb);
740 SCIP_Real ubsin = sin(ub);
741 SCIP_Real lbcos = cos(lb);
742 SCIP_Real ubcos = cos(ub);
745 if( (ub - lb <=
M_PI) && (lbsin * ubsin >= 0.0) )
748 if( lbsin == 0.0 && ubsin == 0.0 )
755 else if( lbcos * ubcos >= 0.0 )
822 *simplifiedexpr = expr;
958 childlb = bounds[0].inf;
959 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;
1252 localbounds[0].sup, ! overestimate);
1272 newbounds = childrenbounds[0];
1303 *hashkey ^= childrenhashes[0];
1368 k = (int)floor(inf/
M_PI);
1435 void* ownercreatedata
1455 void* ownercreatedata
#define SCIP_INTERVAL_INFINITY
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)
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))
#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)
#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