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"
#include "scip/expr_pow.h"
#include "symmetry/struct_symmetry.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 |
#define EXPRHDLR_NAME "sum" |
Definition at line 45 of file expr_sum.c.
#define EXPRHDLR_DESC "summation with coefficients and a constant" |
Definition at line 46 of file expr_sum.c.
#define EXPRHDLR_PRECEDENCE 40000 |
Definition at line 47 of file expr_sum.c.
#define EXPRHDLR_HASHKEY SCIPcalcFibHash(47161.0) |
Definition at line 48 of file expr_sum.c.
macro to activate/deactivate debugging information of simplify method
Definition at line 55 of file expr_sum.c.
Referenced by SCIP_DECL_EXPRSIMPLIFY().
|
static |
creates expression data
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 76 of file expr_sum.c.
References assert(), i, NULL, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPallocBlockMemory, SCIPallocBlockMemoryArray, and SCIPduplicateBlockMemoryArray.
Referenced by SCIP_DECL_EXPRCOPYDATA(), and SCIPcreateExprSum().
|
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
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 114 of file expr_sum.c.
References assert(), i, NULL, REALABS, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_Real, SCIPappendExprChild(), SCIPappendExprSumExpr(), SCIPcreateExprExp(), SCIPcreateExprProduct(), SCIPcreateExprSum(), SCIPexprGetChildren(), SCIPexprGetNChildren(), SCIPgetCoefsExprSum(), SCIPgetConstantExprSum(), SCIPgetValueExprValue(), SCIPisExprExp(), SCIPisExprProduct(), SCIPisExprSum(), SCIPisExprValue(), SCIPreleaseExpr(), SCIPreplaceExprChild(), SCIPsetConstantExprSum(), simplifyTerm(), and TRUE.
Referenced by SCIP_DECL_EXPRSIMPLIFY(), and simplifyTerm().
|
static |
Definition at line 346 of file expr_sum.c.
References SORTEXPRDATA::exprs, SORTEXPRDATA::scip, and SCIPcompareExpr().
|
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 364 of file expr_sum.c.
References assert(), debugSimplify, SORTEXPRDATA::exprs, FALSE, i, 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.
|
static |
expression callback to get information for symmetry detection
Definition at line 542 of file expr_sum.c.
References assert(), i, NULL, SCIP_CALL, SCIP_OKAY, SCIPallocBlockMemory, SCIPallocBlockMemoryArray, SCIPexprGetChildren(), and SCIPexprGetData().
|
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 587 of file expr_sum.c.
References assert(), i, SCIP_Real, SCIPcompareExpr(), SCIPexprGetChildren(), SCIPexprGetNChildren(), SCIPgetCoefsExprSum(), and SCIPgetConstantExprSum().
|
static |
expression handler copy callback
Definition at line 654 of file expr_sum.c.
References SCIP_CALL, SCIP_OKAY, and SCIPincludeExprhdlrSum().
|
static |
expression data copy callback
Definition at line 663 of file expr_sum.c.
References assert(), createData(), NULL, SCIP_CALL, SCIP_OKAY, SCIPexprGetData(), and SCIPexprGetNChildren().
|
static |
expression data free callback
Definition at line 681 of file expr_sum.c.
References assert(), NULL, SCIP_OKAY, SCIPexprGetData(), SCIPexprSetData(), SCIPfreeBlockMemory, and SCIPfreeBlockMemoryArray.
|
static |
expression print callback
! [SnippetExprPrintSum]
! [SnippetExprPrintSum]
Definition at line 700 of file expr_sum.c.
References assert(), EXPRHDLR_PRECEDENCE, NULL, SCIP_EXPRITER_ENTEREXPR, SCIP_EXPRITER_LEAVEEXPR, SCIP_EXPRITER_VISITEDCHILD, SCIP_EXPRITER_VISITINGCHILD, SCIP_OKAY, SCIP_Real, SCIPexprGetData(), and SCIPinfoMessage().
|
static |
expression point evaluation callback
! [SnippetExprEvalSum]
! [SnippetExprEvalSum]
Definition at line 777 of file expr_sum.c.
References assert(), c, NULL, SCIP_INVALID, SCIP_OKAY, SCIPexprGetChildren(), SCIPexprGetData(), SCIPexprGetEvalValue(), and SCIPexprGetNChildren().
|
static |
expression forward derivative evaluation callback
Definition at line 802 of file expr_sum.c.
References assert(), c, NULL, SCIP_INVALID, SCIP_OKAY, SCIPexprGetChildren(), SCIPexprGetData(), SCIPexprGetDot(), and SCIPexprGetNChildren().
|
static |
expression derivative evaluation callback
Definition at line 826 of file expr_sum.c.
References assert(), NULL, SCIP_OKAY, SCIPexprGetChildren(), SCIPexprGetData(), SCIPexprGetNChildren(), SCIPgetCoefsExprSum(), and SCIPisExprValue().
|
static |
expression backward forward derivative evaluation callback
Definition at line 841 of file expr_sum.c.
|
static |
expression interval evaluation callback
Definition at line 852 of file expr_sum.c.
References assert(), c, SCIP_Interval::inf, NULL, SCIP_INTERVAL_INFINITY, SCIP_OKAY, SCIPdebugMsg, SCIPdebugMsgPrint, SCIPexprGetActivity(), SCIPexprGetChildren(), SCIPexprGetData(), SCIPexprGetNChildren(), SCIPintervalAdd(), SCIPintervalIsEmpty(), SCIPintervalMulScalar(), SCIPintervalSet(), SCIPintervalSetEmpty(), and SCIP_Interval::sup.
|
static |
initial estimators callback
Definition at line 898 of file expr_sum.c.
References assert(), BMScopyMemoryArray, EXPRHDLR_NAME, NULL, SCIP_OKAY, SCIPexprGetData(), SCIPexprGetHdlr(), SCIPexprGetNChildren(), SCIPexprhdlrGetName(), SCIPinfoMessage(), and SCIPprintExpr().
|
static |
expression estimate callback
Definition at line 927 of file expr_sum.c.
References assert(), BMSclearMemoryArray, BMScopyMemoryArray, EXPRHDLR_NAME, FALSE, NULL, SCIP_OKAY, SCIPexprGetData(), SCIPexprGetHdlr(), SCIPexprGetNChildren(), SCIPexprhdlrGetName(), and TRUE.
|
static |
expression reverse propagation callback
Definition at line 958 of file expr_sum.c.
References assert(), BMScopyMemoryArray, NULL, SCIP_CALL, SCIP_INTERVAL_INFINITY, SCIP_OKAY, SCIPallocBufferArray, SCIPexprGetData(), SCIPexprGetNChildren(), SCIPfreeBufferArray, and SCIPintervalPropagateWeightedSum().
|
static |
sum hash callback
! [SnippetExprHashSum]
! [SnippetExprHashSum]
Definition at line 990 of file expr_sum.c.
References assert(), c, EXPRHDLR_HASHKEY, NULL, SCIP_OKAY, SCIPcalcFibHash(), SCIPexprGetData(), and SCIPexprGetNChildren().
|
static |
expression curvature detection callback
Definition at line 1016 of file expr_sum.c.
References assert(), i, NULL, SCIP_OKAY, SCIPexprcurvMultiply(), SCIPexprGetData(), SCIPexprGetNChildren(), and TRUE.
|
static |
expression monotonicity detection callback
Definition at line 1039 of file expr_sum.c.
References assert(), NULL, result, SCIP_MONOTONE_DEC, SCIP_MONOTONE_INC, SCIP_OKAY, SCIPexprGetData(), and SCIPexprGetNChildren().
|
static |
expression integrality detection callback
! [SnippetExprIntegralitySum]
! [SnippetExprIntegralitySum]
Definition at line 1058 of file expr_sum.c.
References assert(), EPSISINT, i, NULL, SCIP_OKAY, SCIPexprGetChildren(), SCIPexprGetData(), SCIPexprGetNChildren(), and SCIPexprIsIntegral().