Detailed Description
sum expression handler
Definition in file expr_sum.c.
#include <string.h>
#include <stddef.h>
#include "scip/expr_sum.h"
#include "scip/expr_value.h"
#include "scip/expr_product.h"
#include "scip/expr_exp.h"
Go to the source code of this file.
Data Structures | |
struct | SORTEXPRDATA |
Macros | |
#define | EXPRHDLR_NAME "sum" |
#define | EXPRHDLR_DESC "summation with coefficients and a constant" |
#define | EXPRHDLR_PRECEDENCE 40000 |
#define | EXPRHDLR_HASHKEY SCIPcalcFibHash(47161.0) |
#define | debugSimplify while( FALSE ) printf |
Macro Definition Documentation
◆ EXPRHDLR_NAME
#define EXPRHDLR_NAME "sum" |
Definition at line 34 of file expr_sum.c.
Referenced by SCIP_DECL_EXPRESTIMATE(), SCIP_DECL_EXPRINITESTIMATES(), and SCIPincludeExprhdlrSum().
◆ EXPRHDLR_DESC
#define EXPRHDLR_DESC "summation with coefficients and a constant" |
Definition at line 35 of file expr_sum.c.
Referenced by SCIPincludeExprhdlrSum().
◆ EXPRHDLR_PRECEDENCE
#define EXPRHDLR_PRECEDENCE 40000 |
Definition at line 36 of file expr_sum.c.
Referenced by SCIP_DECL_EXPRPRINT(), and SCIPincludeExprhdlrSum().
◆ EXPRHDLR_HASHKEY
#define EXPRHDLR_HASHKEY SCIPcalcFibHash(47161.0) |
Definition at line 37 of file expr_sum.c.
Referenced by SCIP_DECL_EXPRHASH().
◆ debugSimplify
#define debugSimplify while( FALSE ) printf |
macro to activate/deactivate debugging information of simplify method
Definition at line 44 of file expr_sum.c.
Referenced by SCIP_DECL_EXPRSIMPLIFY().
Function Documentation
◆ createData()
|
static |
creates expression data
- Parameters
-
scip SCIP data structure exprdata pointer where to store expression data ncoefficients number of coefficients (i.e., number of children) coefficients array with coefficients for all children (or NULL if all 1.0) constant constant term of sum
Definition at line 65 of file expr_sum.c.
References NULL, SCIP_CALL, SCIP_OKAY, SCIPallocBlockMemory(), SCIPallocBlockMemoryArray, and SCIPduplicateBlockMemoryArray.
Referenced by SCIP_DECL_EXPRCOPYDATA(), and SCIPcreateExprSum().
◆ simplifyTerm()
|
static |
simplifies the idx
-th child of the sum expression duplicate
in order for it to be able to be a child of a simplified sum
for example, this means that the idx
-th child cannot be itself a sum if it is, we have to flatten it, i.e., take all its children and make them children of duplicate
- Parameters
-
scip SCIP data structure duplicate expression to be simplified idx idx of children to be simplified changed pointer to store if some term actually got simplified ownercreatedata data to pass to ownercreate
Definition at line 103 of file expr_sum.c.
References NULL, REALABS, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPappendExprChild(), SCIPappendExprSumExpr(), SCIPcreateExprExp(), SCIPcreateExprProduct(), SCIPcreateExprSum(), SCIPexprGetChildren(), SCIPexprGetNChildren(), SCIPgetCoefsExprSum(), SCIPgetConstantExprSum(), SCIPgetValueExprValue(), SCIPisExprExp(), SCIPisExprProduct(), SCIPisExprSum(), SCIPisExprValue(), SCIPreleaseExpr(), SCIPreplaceExprChild(), SCIPsetConstantExprSum(), and TRUE.
Referenced by SCIP_DECL_EXPRSIMPLIFY().
◆ SCIP_DECL_SORTINDCOMP()
|
static |
Definition at line 335 of file expr_sum.c.
References SORTEXPRDATA::exprs, SORTEXPRDATA::scip, and SCIPcompareExpr().
◆ SCIP_DECL_EXPRSIMPLIFY()
|
static |
simplifies a sum expression
goes through each child and simplifies it; then sorts the simplified children; then sum the children that are equal; finally creates a sum expression with all the children that do not have a 0 coefficient and post-process so that SS6 and SS7 are satisfied
Definition at line 353 of file expr_sum.c.
References debugSimplify, SORTEXPRDATA::exprs, FALSE, NULL, REALABS, SORTEXPRDATA::scip, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBufferArray, SCIPcaptureExpr(), SCIPcompareExpr(), SCIPcreateExprSum(), SCIPcreateExprValue(), SCIPduplicateExpr(), SCIPexprGetChildren(), SCIPexprGetHdlr(), SCIPexprGetNChildren(), SCIPfreeBufferArrayNull, SCIPgetCoefsExprSum(), SCIPgetConstantExprSum(), SCIPgetExprhdlrSum(), SCIPisEQ(), SCIPreleaseExpr(), SCIPsortInd(), simplifyTerm(), and TRUE.
◆ SCIP_DECL_EXPRCOMPARE()
|
static |
compares two sum expressions
The order of two sum expressions is a lexicographical order on the terms.
Starting from the last, we find the first child where they differ, say, the i-th. Then u < v <=> u_i < v_i. If there are no such children and they have different number of children, then u < v <=> nchildren(u) < nchildren(v). If there are no such children and they have the same number of children, then u < v <=> const(u) < const(v). Otherwise, they are the same.
Note: we are assuming expression are simplified, so within u, we have u_1 < u_2, etc
Example: y + z < x + y + z, 2*x + 3*y < 3*x + 3*y
Definition at line 544 of file expr_sum.c.
References SCIP_Real, SCIPcompareExpr(), SCIPexprGetChildren(), SCIPexprGetNChildren(), SCIPgetCoefsExprSum(), and SCIPgetConstantExprSum().
◆ SCIP_DECL_EXPRCOPYHDLR()
|
static |
expression handler copy callback
Definition at line 611 of file expr_sum.c.
References SCIP_CALL, SCIP_OKAY, and SCIPincludeExprhdlrSum().
◆ SCIP_DECL_EXPRCOPYDATA()
|
static |
expression data copy callback
Definition at line 620 of file expr_sum.c.
References createData(), NULL, SCIP_CALL, SCIP_OKAY, SCIPexprGetData(), and SCIPexprGetNChildren().
◆ SCIP_DECL_EXPRFREEDATA()
|
static |
expression data free callback
Definition at line 638 of file expr_sum.c.
References NULL, SCIP_OKAY, SCIPexprGetData(), SCIPexprSetData(), SCIPfreeBlockMemory, and SCIPfreeBlockMemoryArray.
◆ SCIP_DECL_EXPRPRINT()
|
static |
expression print callback
! [SnippetExprPrintSum]
! [SnippetExprPrintSum]
Definition at line 657 of file expr_sum.c.
References EXPRHDLR_PRECEDENCE, NULL, SCIP_EXPRITER_ENTEREXPR, SCIP_EXPRITER_LEAVEEXPR, SCIP_EXPRITER_VISITEDCHILD, SCIP_EXPRITER_VISITINGCHILD, SCIP_OKAY, SCIP_Real, SCIPexprGetData(), and SCIPinfoMessage().
◆ SCIP_DECL_EXPREVAL()
|
static |
expression point evaluation callback
! [SnippetExprEvalSum]
! [SnippetExprEvalSum]
Definition at line 734 of file expr_sum.c.
References NULL, SCIP_INVALID, SCIP_OKAY, SCIPexprGetChildren(), SCIPexprGetData(), SCIPexprGetEvalValue(), and SCIPexprGetNChildren().
◆ SCIP_DECL_EXPRFWDIFF()
|
static |
expression forward derivative evaluation callback
Definition at line 759 of file expr_sum.c.
References NULL, SCIP_INVALID, SCIP_OKAY, SCIPexprGetChildren(), SCIPexprGetData(), SCIPexprGetDot(), and SCIPexprGetNChildren().
◆ SCIP_DECL_EXPRBWDIFF()
|
static |
expression derivative evaluation callback
Definition at line 783 of file expr_sum.c.
References NULL, SCIP_OKAY, SCIPexprGetChildren(), SCIPexprGetData(), SCIPexprGetNChildren(), SCIPgetCoefsExprSum(), and SCIPisExprValue().
◆ SCIP_DECL_EXPRBWFWDIFF()
|
static |
expression backward forward derivative evaluation callback
Definition at line 798 of file expr_sum.c.
◆ SCIP_DECL_EXPRINTEVAL()
|
static |
expression interval evaluation callback
Definition at line 809 of file expr_sum.c.
References SCIP_Interval::inf, NULL, SCIP_INTERVAL_INFINITY, SCIP_OKAY, SCIPdebugMsg, SCIPdebugMsgPrint, SCIPexprGetActivity(), SCIPexprGetChildren(), SCIPexprGetData(), SCIPexprGetNChildren(), SCIPintervalAdd(), SCIPintervalIsEmpty(), SCIPintervalMulScalar(), SCIPintervalSet(), SCIPintervalSetEmpty(), and SCIP_Interval::sup.
◆ SCIP_DECL_EXPRINITESTIMATES()
|
static |
initial estimators callback
Definition at line 855 of file expr_sum.c.
References BMScopyMemoryArray, EXPRHDLR_NAME, NULL, SCIP_OKAY, SCIPexprGetData(), SCIPexprGetHdlr(), SCIPexprGetNChildren(), SCIPexprhdlrGetName(), SCIPinfoMessage(), and SCIPprintExpr().
◆ SCIP_DECL_EXPRESTIMATE()
|
static |
expression estimate callback
Definition at line 884 of file expr_sum.c.
References BMSclearMemoryArray, BMScopyMemoryArray, EXPRHDLR_NAME, FALSE, NULL, SCIP_OKAY, SCIPexprGetData(), SCIPexprGetHdlr(), SCIPexprGetNChildren(), SCIPexprhdlrGetName(), and TRUE.
◆ SCIP_DECL_EXPRREVERSEPROP()
|
static |
expression reverse propagation callback
Definition at line 915 of file expr_sum.c.
References BMScopyMemoryArray, NULL, SCIP_CALL, SCIP_INTERVAL_INFINITY, SCIP_OKAY, SCIPallocBufferArray, SCIPexprGetData(), SCIPexprGetNChildren(), SCIPfreeBufferArray, and SCIPintervalPropagateWeightedSum().
◆ SCIP_DECL_EXPRHASH()
|
static |
sum hash callback
! [SnippetExprHashSum]
! [SnippetExprHashSum]
Definition at line 947 of file expr_sum.c.
References EXPRHDLR_HASHKEY, NULL, SCIP_OKAY, SCIPcalcFibHash(), SCIPexprGetData(), and SCIPexprGetNChildren().
◆ SCIP_DECL_EXPRCURVATURE()
|
static |
expression curvature detection callback
Definition at line 973 of file expr_sum.c.
References NULL, SCIP_OKAY, SCIPexprcurvMultiply(), SCIPexprGetData(), SCIPexprGetNChildren(), and TRUE.
◆ SCIP_DECL_EXPRMONOTONICITY()
|
static |
expression monotonicity detection callback
Definition at line 996 of file expr_sum.c.
References NULL, SCIP_MONOTONE_DEC, SCIP_MONOTONE_INC, SCIP_OKAY, SCIPexprGetData(), and SCIPexprGetNChildren().
◆ SCIP_DECL_EXPRINTEGRALITY()
|
static |
expression integrality detection callback
! [SnippetExprIntegralitySum]
! [SnippetExprIntegralitySum]
Definition at line 1015 of file expr_sum.c.
References EPSISINT, NULL, SCIP_OKAY, SCIPexprGetChildren(), SCIPexprGetData(), SCIPexprGetNChildren(), and SCIPexprIsIntegral().