Scippy

SCIP

Solving Constraint Integer Programs

pub_expr.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2020 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file nlpi/pub_expr.h
17  * @brief public methods for expressions, expression trees, expression graphs, and related stuff
18  * @author Stefan Vigerske
19  * @author Thorsten Gellermann
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #ifndef __NLPI_PUB_EXPR_H__
25 #define __NLPI_PUB_EXPR_H__
26 
27 #include "scip/def.h"
28 #include "scip/pub_message.h"
29 #include "scip/intervalarith.h"
30 #include "blockmemshell/memory.h"
31 #include "nlpi/type_expr.h"
33 
34 #ifdef NDEBUG
35 #include "nlpi/struct_expr.h"
36 #endif
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 /**@name Expression curvature methods */
43 /**@{ */
44 
45 /** gives curvature for a sum of two functions with given curvature */
48  SCIP_EXPRCURV curv1, /**< curvature of first summand */
49  SCIP_EXPRCURV curv2 /**< curvature of second summand */
50  );
51 
52 #ifdef NDEBUG
53 #define SCIPexprcurvAdd(curv1, curv2) ((SCIP_EXPRCURV) ((curv1) & (curv2)))
54 #endif
55 
56 /** gives the curvature for the negation of a function with given curvature */
59  SCIP_EXPRCURV curvature /**< curvature of function */
60  );
61 
62 /** gives curvature for a functions with given curvature multiplied by a constant factor */
65  SCIP_Real factor, /**< constant factor */
66  SCIP_EXPRCURV curvature /**< curvature of other factor */
67  );
68 
69 /** gives curvature for base^exponent for given bounds and curvature of base-function and constant exponent */
72  SCIP_INTERVAL basebounds, /**< bounds on base function */
73  SCIP_EXPRCURV basecurv, /**< curvature of base function */
74  SCIP_Real exponent /**< exponent */
75  );
76 
77 /** gives curvature for a monomial with given curvatures and bounds for each factor */
80  int nfactors, /**< number of factors in monomial */
81  SCIP_Real* exponents, /**< exponents in monomial, or NULL if all 1.0 */
82  int* factoridxs, /**< indices of factors, or NULL if identity mapping */
83  SCIP_EXPRCURV* factorcurv, /**< curvature of each factor */
84  SCIP_INTERVAL* factorbounds /**< bounds of each factor */
85  );
86 
87 /** gives name as string for a curvature */
89 const char* SCIPexprcurvGetName(
90  SCIP_EXPRCURV curv /**< curvature */
91  );
92 
93 /**@} */
94 
95 /**@name Expression operand methods */
96 /**@{ */
97 
98 /** gives the name of an operand */
100 const char* SCIPexpropGetName(
101  SCIP_EXPROP op /**< expression operand */
102  );
103 
104 /** gives the number of children of a simple operand
105  * @return -1 for invalid operands and -2 for complex operands (those where the number of children depends on the expression)
106  */
109  SCIP_EXPROP op /**< expression operand */
110  );
111 
112 /**@} */
113 
114 /**@name Expression methods */
115 /**@{ */
116 
117 /** gives operator of expression */
120  SCIP_EXPR* expr /**< expression */
121  );
122 
123 /** gives number of children of an expression */
126  SCIP_EXPR* expr /**< expression */
127  );
128 
129 /** gives pointer to array with children of an expression */
132  SCIP_EXPR* expr /**< expression */
133  );
134 
135 /** gives index belonging to a SCIP_EXPR_VARIDX or SCIP_EXPR_PARAM operand */
138  SCIP_EXPR* expr /**< expression */
139  );
140 
141 /** gives real belonging to a SCIP_EXPR_CONST operand */
144  SCIP_EXPR* expr /**< expression */
145  );
146 
147 /** gives void* belonging to a complex operand */
149 void* SCIPexprGetOpData(
150  SCIP_EXPR* expr /**< expression */
151  );
152 
153 /** gives exponent belonging to a SCIP_EXPR_REALPOWER expression */
156  SCIP_EXPR* expr /**< expression */
157  );
158 
159 /** gives exponent belonging to a SCIP_EXPR_INTPOWER expression */
162  SCIP_EXPR* expr /**< expression */
163  );
164 
165 /** gives exponent belonging to a SCIP_EXPR_SIGNPOWER expression */
168  SCIP_EXPR* expr /**< expression */
169  );
170 
171 /** gives linear coefficients belonging to a SCIP_EXPR_LINEAR expression */
174  SCIP_EXPR* expr /**< expression */
175  );
176 
177 /** gives constant belonging to a SCIP_EXPR_LINEAR expression */
180  SCIP_EXPR* expr /**< expression */
181  );
182 
183 /** gives quadratic elements belonging to a SCIP_EXPR_QUADRATIC expression */
186  SCIP_EXPR* expr /**< quadratic expression */
187  );
188 
189 /** gives constant belonging to a SCIP_EXPR_QUADRATIC expression */
192  SCIP_EXPR* expr /**< quadratic expression */
193  );
194 
195 /** gives linear coefficients belonging to a SCIP_EXPR_QUADRATIC expression
196  * can be NULL if all coefficients are 0.0 */
199  SCIP_EXPR* expr /**< quadratic expression */
200  );
201 
202 /** gives number of quadratic elements belonging to a SCIP_EXPR_QUADRATIC expression */
205  SCIP_EXPR* expr /**< quadratic expression */
206  );
207 
208 /** gives the monomials belonging to a SCIP_EXPR_POLYNOMIAL expression */
211  SCIP_EXPR* expr /**< expression */
212  );
213 
214 /** gives the number of monomials belonging to a SCIP_EXPR_POLYNOMIAL expression */
217  SCIP_EXPR* expr /**< expression */
218  );
219 
220 /** gives the constant belonging to a SCIP_EXPR_POLYNOMIAL expression */
223  SCIP_EXPR* expr /**< expression */
224  );
225 
226 /** gets coefficient of a monomial */
229  SCIP_EXPRDATA_MONOMIAL* monomial /**< monomial */
230  );
231 
232 /** gets number of factors of a monomial */
235  SCIP_EXPRDATA_MONOMIAL* monomial /**< monomial */
236  );
237 
238 /** gets indices of children corresponding to factors of a monomial */
241  SCIP_EXPRDATA_MONOMIAL* monomial /**< monomial */
242  );
243 
244 /** gets exponents in factors of a monomial */
247  SCIP_EXPRDATA_MONOMIAL* monomial /**< monomial */
248  );
249 
250 /** gets user data of a user expression */
253  SCIP_EXPR* expr
254  );
255 
256 /** indicates whether a user expression has the estimator callback defined */
259  SCIP_EXPR* expr
260  );
261 
262 /** gives the evaluation capability of a user expression */
265  SCIP_EXPR* expr
266  );
267 
268 #ifdef NDEBUG
269 
270 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
271  * speed up the algorithms.
272  */
273 
274 #define SCIPexprGetOperator(expr) (expr)->op
275 #define SCIPexprGetNChildren(expr) (expr)->nchildren
276 #define SCIPexprGetChildren(expr) (expr)->children
277 #define SCIPexprGetOpIndex(expr) (expr)->data.intval
278 #define SCIPexprGetOpReal(expr) (expr)->data.dbl
279 #define SCIPexprGetOpData(expr) (expr)->data.data
280 #define SCIPexprGetRealPowerExponent(expr) (expr)->data.dbl
281 #define SCIPexprGetIntPowerExponent(expr) (expr)->data.intval
282 #define SCIPexprGetSignPowerExponent(expr) (expr)->data.dbl
283 #define SCIPexprGetLinearCoefs(expr) ((SCIP_Real*)(expr)->data.data)
284 #define SCIPexprGetLinearConstant(expr) (((SCIP_Real*)(expr)->data.data)[(expr)->nchildren])
285 #define SCIPexprGetQuadElements(expr) ((SCIP_EXPRDATA_QUADRATIC*)(expr)->data.data)->quadelems
286 #define SCIPexprGetQuadConstant(expr) ((SCIP_EXPRDATA_QUADRATIC*)(expr)->data.data)->constant
287 #define SCIPexprGetQuadLinearCoefs(expr) ((SCIP_EXPRDATA_QUADRATIC*)(expr)->data.data)->lincoefs
288 #define SCIPexprGetNQuadElements(expr) ((SCIP_EXPRDATA_QUADRATIC*)(expr)->data.data)->nquadelems
289 #define SCIPexprGetMonomials(expr) ((SCIP_EXPRDATA_POLYNOMIAL*)(expr)->data.data)->monomials
290 #define SCIPexprGetNMonomials(expr) ((SCIP_EXPRDATA_POLYNOMIAL*)(expr)->data.data)->nmonomials
291 #define SCIPexprGetPolynomialConstant(expr) ((SCIP_EXPRDATA_POLYNOMIAL*)(expr)->data.data)->constant
292 #define SCIPexprGetMonomialCoef(monomial) (monomial)->coef
293 #define SCIPexprGetMonomialNFactors(monomial) (monomial)->nfactors
294 #define SCIPexprGetMonomialChildIndices(monomial) (monomial)->childidxs
295 #define SCIPexprGetMonomialExponents(monomial) (monomial)->exponents
296 #define SCIPexprGetUserData(expr) ((SCIP_EXPRDATA_USER*)(expr)->data.data)->userdata
297 #define SCIPexprHasUserEstimator(expr) (((SCIP_EXPRDATA_USER*)expr->data.data)->estimate != NULL)
298 #define SCIPexprGetUserEvalCapability(expr) (((SCIP_EXPRDATA_USER*)expr->data.data)->evalcapability)
299 
300 #endif
301 
302 /** creates a simple expression */
305  BMS_BLKMEM* blkmem, /**< block memory data structure */
306  SCIP_EXPR** expr, /**< pointer to buffer for expression address */
307  SCIP_EXPROP op, /**< operand of expression */
308  ... /**< arguments of operand */
309  );
310 
311 /** copies an expression including its children */
314  BMS_BLKMEM* blkmem, /**< block memory data structure */
315  SCIP_EXPR** targetexpr, /**< buffer to store pointer to copied expression */
316  SCIP_EXPR* sourceexpr /**< expression to copy */
317  );
318 
319 /** frees an expression including its children */
321 void SCIPexprFreeDeep(
322  BMS_BLKMEM* blkmem, /**< block memory data structure */
323  SCIP_EXPR** expr /**< pointer to expression to free */
324  );
325 
326 /** frees an expression but not its children */
329  BMS_BLKMEM* blkmem, /**< block memory data structure */
330  SCIP_EXPR** expr /**< pointer to expression to free */
331  );
332 
333 /** creates an expression from the addition of two given expression, with coefficients, and a constant
334  *
335  * the given expressions may be modified or freed, otherwise it will be used a child expression
336  * favors creation and maintaining of SCIP_EXPR_LINEAR over SCIP_EXPR_PLUS or SCIP_EXPR_SUM
337  */
340  BMS_BLKMEM* blkmem, /**< block memory data structure */
341  SCIP_EXPR** expr, /**< pointer to store pointer to created expression */
342  SCIP_Real coef1, /**< coefficient of first term */
343  SCIP_EXPR* term1, /**< expression of first term, or NULL */
344  SCIP_Real coef2, /**< coefficient of second term */
345  SCIP_EXPR* term2, /**< expression of second term, or NULL */
346  SCIP_Real constant /**< constant term to add */
347  );
348 
349 /** creates an expression from the multiplication of an expression with a constant
350  *
351  * the given expressions may be modified or freed, otherwise it will be used a child expression
352  * favors creation of SCIP_EXPR_LINEAR over SCIP_EXPR_MUP or SCIP_EXPR_PROD
353  */
356  BMS_BLKMEM* blkmem, /**< block memory data structure */
357  SCIP_EXPR** expr, /**< buffer to store pointer to created expression */
358  SCIP_EXPR* term, /**< term to multiply by factor */
359  SCIP_Real factor /**< factor */
360  );
361 
362 /** creates a SCIP_EXPR_LINEAR expression that is (affine) linear in its children: constant + sum_i coef_i child_i */
365  BMS_BLKMEM* blkmem, /**< block memory data structure */
366  SCIP_EXPR** expr, /**< pointer to buffer for expression address */
367  int nchildren, /**< number of children */
368  SCIP_EXPR** children, /**< children of expression */
369  SCIP_Real* coefs, /**< coefficients of children */
370  SCIP_Real constant /**< constant part */
371  );
372 
373 /** adds new terms to a linear expression */
376  BMS_BLKMEM* blkmem, /**< block memory */
377  SCIP_EXPR* expr, /**< linear expression */
378  int nchildren, /**< number of children to add */
379  SCIP_Real* coefs, /**< coefficients of additional children */
380  SCIP_EXPR** children, /**< additional children expressions */
381  SCIP_Real constant /**< constant to add */
382  );
383 
384 /** creates a SCIP_EXPR_QUADRATIC expression: constant + sum_i coef_i child_i + sum_i coef_i child1_i child2_i */
386  BMS_BLKMEM* blkmem, /**< block memory data structure */
387  SCIP_EXPR** expr, /**< pointer to buffer for expression address */
388  int nchildren, /**< number of children */
389  SCIP_EXPR** children, /**< children of expression */
390  SCIP_Real constant, /**< constant */
391  SCIP_Real* lincoefs, /**< linear coefficients of children, or NULL if all 0.0 */
392  int nquadelems, /**< number of quadratic elements */
393  SCIP_QUADELEM* quadelems /**< quadratic elements specifying coefficients and child indices */
394  );
395 
396 /** ensures that quadratic elements of a quadratic expression are sorted */
399  SCIP_EXPR* expr /**< quadratic expression */
400  );
401 
402 /** creates a SCIP_EXPR_POLYNOMIAL expression from an array of monomials: constant + sum_i monomial_i */
405  BMS_BLKMEM* blkmem, /**< block memory data structure */
406  SCIP_EXPR** expr, /**< pointer to buffer for expression address */
407  int nchildren, /**< number of children */
408  SCIP_EXPR** children, /**< children of expression */
409  int nmonomials, /**< number of monomials */
410  SCIP_EXPRDATA_MONOMIAL** monomials, /**< monomials */
411  SCIP_Real constant, /**< constant part */
412  SCIP_Bool copymonomials /**< should monomials by copied or ownership be assumed? */
413  );
414 
415 /** adds an array of monomials to a SCIP_EXPR_POLYNOMIAL expression */
418  BMS_BLKMEM* blkmem, /**< block memory of expression */
419  SCIP_EXPR* expr, /**< expression */
420  int nmonomials, /**< number of monomials to add */
421  SCIP_EXPRDATA_MONOMIAL** monomials, /**< the monomials to add */
422  SCIP_Bool copymonomials /**< should monomials by copied or ownership be assumed? */
423  );
424 
425 /** changes the constant in a SCIP_EXPR_POLYNOMIAL expression */
428  SCIP_EXPR* expr, /**< expression */
429  SCIP_Real constant /**< new value for constant */
430  );
431 
432 /** multiplies each summand of a polynomial by a given constant */
435  BMS_BLKMEM* blkmem, /**< block memory */
436  SCIP_EXPR* expr, /**< polynomial expression */
437  SCIP_Real factor /**< constant factor */
438  );
439 
440 /** multiplies each summand of a polynomial by a given monomial */
443  BMS_BLKMEM* blkmem, /**< block memory */
444  SCIP_EXPR* expr, /**< polynomial expression */
445  SCIP_EXPRDATA_MONOMIAL* factor, /**< monomial factor */
446  int* childmap /**< map children in factor to children in expr, or NULL for 1:1 */
447  );
448 
449 /** multiplies this polynomial by a polynomial
450  * factor needs to be different from expr */
453  BMS_BLKMEM* blkmem, /**< block memory */
454  SCIP_EXPR* expr, /**< polynomial expression */
455  SCIP_EXPR* factor, /**< polynomial factor */
456  int* childmap /**< map children in factor to children in expr, or NULL for 1:1 */
457  );
458 
459 /** takes a power of the polynomial
460  * exponent need to be an integer
461  * polynomial need to be a monomial, if exponent is negative
462  */
465  BMS_BLKMEM* blkmem, /**< block memory */
466  SCIP_EXPR* expr, /**< polynomial expression */
467  int exponent /**< exponent of power operation */
468  );
469 
470 /** merges monomials in a polynomial expression that differ only in coefficient into a single monomial
471  * eliminates monomials with coefficient between -eps and eps
472  */
475  BMS_BLKMEM* blkmem, /**< block memory */
476  SCIP_EXPR* expr, /**< polynomial expression */
477  SCIP_Real eps, /**< threshold under which numbers are treat as zero */
478  SCIP_Bool mergefactors /**< whether to merge factors in monomials too */
479  );
480 
481 /** creates a monomial */
484  BMS_BLKMEM* blkmem, /**< block memory */
485  SCIP_EXPRDATA_MONOMIAL** monomial, /**< buffer where to store pointer to new monomial */
486  SCIP_Real coef, /**< coefficient of monomial */
487  int nfactors, /**< number of factors in monomial */
488  int* childidxs, /**< indices of children corresponding to factors, or NULL if identity */
489  SCIP_Real* exponents /**< exponent in each factor, or NULL if all 1.0 */
490  );
491 
492 /** frees a monomial */
495  BMS_BLKMEM* blkmem, /**< block memory */
496  SCIP_EXPRDATA_MONOMIAL** monomial /**< pointer to monomial that should be freed */
497  );
498 
499 /** ensures that factors in a monomial are sorted */
502  SCIP_EXPRDATA_MONOMIAL* monomial /**< monomial */
503  );
504 
505 /** finds a factor corresponding to a given child index in a monomial
506  * note that if the factors have not been merged, the position of some factor corresponding to a given child is given
507  * returns TRUE if a factor is found, FALSE if not
508  */
511  SCIP_EXPRDATA_MONOMIAL* monomial, /**< monomial */
512  int childidx, /**< index of the child which factor to search for */
513  int* pos /**< buffer to store position of factor */
514  );
515 
516 /** checks if two monomials are equal */
519  SCIP_EXPRDATA_MONOMIAL* monomial1, /**< first monomial */
520  SCIP_EXPRDATA_MONOMIAL* monomial2, /**< second monomial */
521  SCIP_Real eps /**< threshold under which numbers are treated as 0.0 */
522  );
523 
524 /** adds factors to a monomial */
527  BMS_BLKMEM* blkmem, /**< block memory */
528  SCIP_EXPRDATA_MONOMIAL* monomial, /**< monomial */
529  int nfactors, /**< number of factors to add */
530  int* childidxs, /**< indices of children corresponding to factors */
531  SCIP_Real* exponents /**< exponent in each factor */
532  );
533 
534 /** changes coefficient of monomial */
537  SCIP_EXPRDATA_MONOMIAL* monomial, /**< monomial */
538  SCIP_Real newcoef /**< new coefficient */
539  );
540 
541 /** multiplies a monomial with a monomial */
544  BMS_BLKMEM* blkmem, /**< block memory */
545  SCIP_EXPRDATA_MONOMIAL* monomial, /**< monomial */
546  SCIP_EXPRDATA_MONOMIAL* factor, /**< factor monomial */
547  int* childmap /**< map to apply to children in factor, or NULL for 1:1 */
548  );
549 
550 /** replaces the monomial by a power of the monomial
551  * allows only integers as exponent
552  */
555  SCIP_EXPRDATA_MONOMIAL* monomial, /**< monomial */
556  int exponent /**< integer exponent of power operation */
557  );
558 
559 /** merges factors that correspond to the same child by adding exponents
560  * eliminates factors with exponent between -eps and eps
561  */
564  SCIP_EXPRDATA_MONOMIAL* monomial, /**< monomial */
565  SCIP_Real eps /**< threshold under which numbers are treated as 0.0 */
566  );
567 
568 /** ensures that monomials of a polynomial are sorted */
571  SCIP_EXPR* expr /**< polynomial expression */
572  );
573 
574 /** creates a user expression */
577  BMS_BLKMEM* blkmem, /**< block memory data structure */
578  SCIP_EXPR** expr, /**< pointer to buffer for expression address */
579  int nchildren, /**< number of children */
580  SCIP_EXPR** children, /**< children of expression */
581  SCIP_USEREXPRDATA* data, /**< user data for expression, expression assumes ownership */
582  SCIP_EXPRINTCAPABILITY evalcapability, /**< capability of evaluation functions (partially redundant, currently) */
583  SCIP_DECL_USEREXPREVAL ((*eval)), /**< evaluation function */
584  SCIP_DECL_USEREXPRINTEVAL ((*inteval)), /**< interval evaluation function, or NULL if not implemented */
585  SCIP_DECL_USEREXPRCURV ((*curv)), /**< curvature check function */
586  SCIP_DECL_USEREXPRPROP ((*prop)), /**< interval propagation function, or NULL if not implemented */
587  SCIP_DECL_USEREXPRESTIMATE ((*estimate)), /**< estimation function, or NULL if convex, concave, or not implemented */
588  SCIP_DECL_USEREXPRCOPYDATA ((*copydata)), /**< expression data copy function, or NULL if nothing to copy */
589  SCIP_DECL_USEREXPRFREEDATA ((*freedata)), /**< expression data free function, or NULL if nothing to free */
590  SCIP_DECL_USEREXPRPRINT ((*print)) /**< expression print function, or NULL for default string "user" */
591  );
592 
593 /** indicates whether the expression contains a SCIP_EXPR_PARAM */
596  SCIP_EXPR* expr /**< expression */
597  );
598 
599 /** gets maximal degree of expression, or SCIP_EXPR_DEGREEINFINITY if not a polynomial */
602  SCIP_EXPR* expr, /**< expression */
603  int* maxdegree /**< buffer to store maximal degree */
604  );
605 
606 /** counts usage of variables in expression */
609  SCIP_EXPR* expr, /**< expression to update */
610  int* varsusage /**< array with counters of variable usage */
611  );
612 
613 /** compares whether two expressions are the same
614  * inconclusive, i.e., may give FALSE even if expressions are equivalent (x*y != y*x)
615  */
618  SCIP_EXPR* expr1, /**< first expression */
619  SCIP_EXPR* expr2, /**< second expression */
620  SCIP_Real eps /**< threshold under which numbers are assumed to be zero */
621  );
622 
623 /** aims at simplifying an expression and splitting of a linear expression
624  * if linear variables are split off, expression interpreter data, if stored in the tree, is freed
625  */
628  BMS_BLKMEM* blkmem, /**< block memory data structure */
629  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
630  SCIP_EXPR* expr, /**< expression */
631  SCIP_Real eps, /**< threshold, under which positive values are treat as 0 */
632  int maxexpansionexponent,/**< maximal exponent for which we still expand non-monomial polynomials */
633  int nvars, /**< number of variables in expression */
634  int* nlinvars, /**< buffer to store number of linear variables in linear part, or NULL if linear part should not be separated */
635  int* linidxs, /**< array to store indices of variables in expression tree which belong to linear part, or NULL */
636  SCIP_Real* lincoefs /**< array to store coefficients of linear part, or NULL */
637  );
638 
639 /** evaluates an expression w.r.t. given values for children expressions */
642  SCIP_EXPR* expr, /**< expression */
643  SCIP_Real* argvals, /**< values for children, can be NULL if the expression has no children */
644  SCIP_Real* varvals, /**< values for variables, can be NULL if the expression operand is not a variable */
645  SCIP_Real* param, /**< values for parameters, can be NULL if the expression operand is not a parameter */
646  SCIP_Real* val /**< buffer to store value */
647  );
648 
649 /** evaluates an expression w.r.t. a point */
652  SCIP_EXPR* expr, /**< expression */
653  SCIP_Real* varvals, /**< values for variables, can be NULL if the expression is constant */
654  SCIP_Real* param, /**< values for parameters, can be NULL if the expression is not parameterized */
655  SCIP_Real* val /**< buffer to store value */
656  );
657 
658 /** evaluates an expression w.r.t. given interval values for children expressions */
661  SCIP_EXPR* expr, /**< expression */
662  SCIP_Real infinity, /**< value to use for infinity */
663  SCIP_INTERVAL* argvals, /**< interval values for children, can be NULL if the expression has no children */
664  SCIP_INTERVAL* varvals, /**< interval values for variables, can be NULL if the expression is constant */
665  SCIP_Real* param, /**< values for parameters, can be NULL if the expression is not parameterized */
666  SCIP_INTERVAL* val /**< buffer to store value */
667  );
668 
669 /** evaluates an expression w.r.t. an interval */
672  SCIP_EXPR* expr, /**< expression */
673  SCIP_Real infinity, /**< value to use for infinity */
674  SCIP_INTERVAL* varvals, /**< interval values for variables, can be NULL if the expression is constant */
675  SCIP_Real* param, /**< values for parameters, can be NULL if the expression is not parameterized */
676  SCIP_INTERVAL* val /**< buffer to store value */
677  );
678 
679 /** evaluates a user expression w.r.t. given values for children expressions */
682  SCIP_EXPR* expr, /**< expression */
683  SCIP_Real* argvals, /**< values for children */
684  SCIP_Real* val, /**< buffer to store function value */
685  SCIP_Real* gradient, /**< buffer to store gradient values, or NULL if not requested */
686  SCIP_Real* hessian /**< buffer to store values of full Hessian, or NULL if not requested */
687  );
688 
689 /** evaluates a user expression w.r.t. an interval */
692  SCIP_EXPR* expr, /**< expression */
693  SCIP_Real infinity, /**< value to use for infinity */
694  SCIP_INTERVAL* argvals, /**< values for children */
695  SCIP_INTERVAL* val, /**< buffer to store value */
696  SCIP_INTERVAL* gradient, /**< buffer to store gradient values, or NULL if not requested */
697  SCIP_INTERVAL* hessian /**< buffer to store values of full Hessian, or NULL if not requested */
698  );
699 
700 /** tries to determine the curvature type of an expression w.r.t. given variable domains */
703  SCIP_EXPR* expr, /**< expression to check */
704  SCIP_Real infinity, /**< value to use for infinity */
705  SCIP_INTERVAL* varbounds, /**< domains of variables */
706  SCIP_Real* param, /**< values for parameters, can be NULL if the expression is not parameterized */
707  SCIP_EXPRCURV* curv, /**< buffer to store curvature of expression */
708  SCIP_INTERVAL* bounds /**< buffer to store bounds on expression */
709  );
710 
711 /** under-/overestimates a user expression w.r.t. to given values and bounds for children expressions */
714  SCIP_EXPR* expr, /**< expression */
715  SCIP_Real infinity, /**< value to use for infinity */
716  SCIP_Real* argvals, /**< values for children */
717  SCIP_INTERVAL* argbounds, /**< bounds for children */
718  SCIP_Bool overestimate, /**< whether to overestimate the expression */
719  SCIP_Real* coeffs, /**< buffer to store the linear coefficients for each child expression that gives a valid under-/overestimator */
720  SCIP_Real* constant, /**< buffer to store the constant value of the linear under-/overestimator */
721  SCIP_Bool* success /**< buffer to store whether an estimator was successfully computed */
722 );
723 
724 
725 /** substitutes variables (SCIP_EXPR_VARIDX) by expressions
726  * Note that only the children of the given expr are checked!
727  * A variable with index i is replaced by a copy of substexprs[i], if that latter is not NULL
728  * if substexprs[i] == NULL, then the variable expression i is not touched
729  */
732  BMS_BLKMEM* blkmem, /**< block memory data structure */
733  SCIP_EXPR* expr, /**< expression, which of the children may be replaced */
734  SCIP_EXPR** substexprs /**< array of substitute expressions; single entries can be NULL */
735  );
736 
737 /** updates variable indices in expression tree */
740  SCIP_EXPR* expr, /**< expression to update */
741  int* newindices /**< new indices of variables */
742  );
743 
744 /** updates parameter indices in expression tree */
747  SCIP_EXPR* expr, /**< expression to update */
748  int* newindices /**< new indices of variables */
749  );
750 
751 /** prints an expression */
753 void SCIPexprPrint(
754  SCIP_EXPR* expr, /**< expression */
755  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
756  FILE* file, /**< file for printing, or NULL for stdout */
757  const char** varnames, /**< names of variables, or NULL for default names */
758  const char** paramnames, /**< names of parameters, or NULL for default names */
759  SCIP_Real* paramvals /**< values of parameters, or NULL for not printing */
760  );
761 
762 /** parses an expression from a string */
765  BMS_BLKMEM* blkmem, /**< block memory data structure */
766  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
767  SCIP_EXPR** expr, /**< buffer to store pointer to created expression */
768  const char* str, /**< pointer to the string to be parsed */
769  const char* lastchar, /**< pointer to the last char of str that should be parsed */
770  int* nvars, /**< buffer to store number of variables */
771  int* varnames, /**< buffer to store variable names, prefixed by index (as int) */
772  int varnameslength /**< length of the varnames buffer array */
773  );
774 
775 /**@} */
776 
777 /**@name Expression tree methods */
778 /**@{ */
779 
780 /** returns root expression of an expression tree */
783  SCIP_EXPRTREE* tree /**< expression tree */
784  );
785 
786 /** returns number of variables in expression tree */
789  SCIP_EXPRTREE* tree /**< expression tree */
790  );
791 
792 /** returns number of parameters in expression tree */
795  SCIP_EXPRTREE* tree /**< expression tree */
796  );
797 
798 /** returns values of parameters or NULL if none */
801  SCIP_EXPRTREE* tree /**< expression tree */
802  );
803 
804 /** sets value of a single parameter in expression tree */
807  SCIP_EXPRTREE* tree, /**< expression tree */
808  int paramidx, /**< index of parameter */
809  SCIP_Real paramval /**< new value of parameter */
810  );
811 
812 /** gets data of expression tree interpreter, or NULL if not set */
815  SCIP_EXPRTREE* tree /**< expression tree */
816  );
817 
818 /** sets data of expression tree interpreter */
821  SCIP_EXPRTREE* tree, /**< expression tree */
822  SCIP_EXPRINTDATA* interpreterdata /**< expression interpreter data */
823  );
824 
825 /** frees data of expression tree interpreter, if any */
828  SCIP_EXPRTREE* tree /**< expression tree */
829  );
830 
831 /** indicates whether there are parameterized constants (SCIP_EXPR_PARAM) in expression tree */
834  SCIP_EXPRTREE* tree /**< expression tree */
835  );
836 
837 /** Gives maximal degree of expression in expression tree.
838  * If constant expression, gives 0,
839  * if linear expression, gives 1,
840  * if polynomial expression, gives its maximal degree,
841  * otherwise (nonpolynomial nonconstant expressions) gives at least SCIP_EXPR_DEGREEINFINITY.
842  */
845  SCIP_EXPRTREE* tree, /**< expression tree */
846  int* maxdegree /**< buffer to store maximal degree */
847  );
848 
849 /** evaluates an expression tree w.r.t. a point */
852  SCIP_EXPRTREE* tree, /**< expression tree */
853  SCIP_Real* varvals, /**< values for variables */
854  SCIP_Real* val /**< buffer to store expression tree value */
855  );
856 
857 /** evaluates an expression tree w.r.t. an interval */
860  SCIP_EXPRTREE* tree, /**< expression tree */
861  SCIP_Real infinity, /**< value for infinity */
862  SCIP_INTERVAL* varvals, /**< intervals for variables */
863  SCIP_INTERVAL* val /**< buffer to store expression tree value */
864  );
865 
866 /** prints an expression tree */
868 void SCIPexprtreePrint(
869  SCIP_EXPRTREE* tree, /**< expression tree */
870  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
871  FILE* file, /**< file for printing, or NULL for stdout */
872  const char** varnames, /**< names of variables, or NULL for default names */
873  const char** paramnames /**< names of parameters, or NULL for default names */
874  );
875 
876 #ifdef NDEBUG
877 
878 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
879  * speed up the algorithms.
880  */
881 
882 #define SCIPexprtreeGetRoot(tree) (tree)->root
883 #define SCIPexprtreeGetNVars(tree) (tree)->nvars
884 #define SCIPexprtreeGetNParams(tree) (tree)->nparams
885 #define SCIPexprtreeGetParamVals(tree) (tree)->params
886 #define SCIPexprtreeSetParamVal(tree, paramidx, paramval) do { (tree)->params[(paramidx)] = paramval; } while (FALSE)
887 #define SCIPexprtreeGetInterpreterData(tree) (tree)->interpreterdata
888 #define SCIPexprtreeSetInterpreterData(tree, newinterpreterdata) do { (tree)->interpreterdata = newinterpreterdata; } while (FALSE)
889 #define SCIPexprtreeFreeInterpreterData(tree) ((tree)->interpreterdata != NULL ? SCIPexprintFreeData(&(tree)->interpreterdata) : SCIP_OKAY)
890 #define SCIPexprtreeHasParam(tree) SCIPexprHasParam((tree)->root)
891 #define SCIPexprtreeGetMaxDegree(tree, maxdegree) SCIPexprGetMaxDegree((tree)->root, maxdegree)
892 #define SCIPexprtreeEval(tree, varvals, val) SCIPexprEval((tree)->root, varvals, (tree)->params, val)
893 #define SCIPexprtreeEvalInt(tree, infinity, varvals, val) SCIPexprEvalInt((tree)->root, infinity, varvals, (tree)->params, val)
894 #define SCIPexprtreePrint(tree, messagehdlr, file, varnames, paramnames) SCIPexprPrint((tree)->root, messagehdlr, file, varnames, paramnames, (tree)->params)
895 
896 #endif
897 
898 /** creates an expression tree */
901  BMS_BLKMEM* blkmem, /**< block memory data structure */
902  SCIP_EXPRTREE** tree, /**< buffer to store address of created expression tree */
903  SCIP_EXPR* root, /**< pointer to root expression, not copied deep !, can be NULL */
904  int nvars, /**< number of variables in variable mapping */
905  int nparams, /**< number of parameters in expression */
906  SCIP_Real* params /**< values for parameters, or NULL (if NULL but nparams > 0, then params is initialized with zeros) */
907  );
908 
909 /** copies an expression tree */
912  BMS_BLKMEM* blkmem, /**< block memory that should be used in new expression tree */
913  SCIP_EXPRTREE** targettree, /**< buffer to store address of copied expression tree */
914  SCIP_EXPRTREE* sourcetree /**< expression tree to copy */
915  );
916 
917 /** frees an expression tree */
920  SCIP_EXPRTREE** tree /**< pointer to expression tree that is freed */
921  );
922 
923 /** sets number and values of all parameters in expression tree */
926  SCIP_EXPRTREE* tree, /**< expression tree */
927  int nparams, /**< number of parameters */
928  SCIP_Real* paramvals /**< values of parameters, can be NULL if nparams == 0 */
929  );
930 
931 /** gives the number of usages for each variable in the expression tree */
934  SCIP_EXPRTREE* tree, /**< expression tree */
935  int* varsusage /**< array where to store for each variable how often it is used in the tree */
936  );
937 
938 /** aims at simplifying an expression and splitting of a linear expression
939  * if linear variables are split off, expression interpreter data, if stored in the tree, is freed
940  */
943  SCIP_EXPRTREE* tree, /**< expression tree */
944  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
945  SCIP_Real eps, /**< threshold, under which positive values are treat as 0 */
946  int maxexpansionexponent,/**< maximal exponent for which we still expand non-monomial polynomials */
947  int* nlinvars, /**< buffer to store number of linear variables in linear part, or NULL if linear part should not be separated */
948  int* linidxs, /**< array to store indices of variables in expression tree which belong to linear part, or NULL */
949  SCIP_Real* lincoefs /**< array to store coefficients of linear part, or NULL */
950  );
951 
952 /** adds an expression to the root expression of the tree
953  *
954  * The root is replaced with an SCIP_EXPR_PLUS expression which has the previous root and the given expression as children
955  * If no root existed yet, then the root is set to the given expression (or a copy of it).
956  */
959  SCIP_EXPRTREE* tree, /**< expression tree */
960  SCIP_EXPR* expr, /**< expression to add to tree */
961  SCIP_Bool copyexpr /**< whether expression should be copied */
962  );
963 
964 /** tries to determine the curvature type of an expression tree w.r.t. given variable domains */
967  SCIP_EXPRTREE* tree, /**< expression tree */
968  SCIP_Real infinity, /**< value for infinity */
969  SCIP_INTERVAL* varbounds, /**< domains of variables */
970  SCIP_EXPRCURV* curv, /**< buffer to store curvature of expression */
971  SCIP_INTERVAL* bounds /**< buffer to store bounds on expression, or NULL if not needed */
972  );
973 
974 /** substitutes variables (SCIP_EXPR_VARIDX) in an expression tree by expressions
975  * A variable with index i is replaced by a copy of substexprs[i], if that latter is not NULL
976  * if substexprs[i] == NULL, then the variable expression i is not touched
977  */
980  SCIP_EXPRTREE* tree, /**< expression tree */
981  SCIP_EXPR** substexprs /**< array of substitute expressions; single entries can be NULL */
982  );
983 
984 /**@} */
985 
986 /**@name Quadratic element methods */
987 /**@{ */
988 
989 /** sorts an array of quadratic elements
990  * The elements are sorted such that the first index is increasing and
991  * such that among elements with the same first index, the second index is increasing.
992  * For elements with same first and second index, the order is not defined.
993  */
995 void SCIPquadelemSort(
996  SCIP_QUADELEM* quadelems, /**< array of quadratic elements */
997  int nquadelems /**< number of quadratic elements */
998  );
999 
1000 /** Finds an index pair in a sorted array of quadratic elements.
1001  * If (idx1,idx2) is found in quadelems, then returns TRUE and stores position of quadratic element in *pos.
1002  * If (idx1,idx2) is not found in quadelems, then returns FALSE and stores position where a quadratic element with these indices would be inserted in *pos.
1003  * Assumes that idx1 <= idx2.
1004  */
1007  SCIP_QUADELEM* quadelems, /**< array of quadratic elements */
1008  int idx1, /**< index of first variable in element to search for */
1009  int idx2, /**< index of second variable in element to search for */
1010  int nquadelems, /**< number of quadratic elements in array */
1011  int* pos /**< buffer to store position of found quadratic element, or position where it would be inserted */
1012  );
1013 
1014 /** Adds quadratic elements with same index and removes elements with coefficient 0.0.
1015  * Assumes that elements have been sorted before.
1016  */
1018 void SCIPquadelemSqueeze(
1019  SCIP_QUADELEM* quadelems, /**< array of quadratic elements */
1020  int nquadelems, /**< number of quadratic elements */
1021  int* nquadelemsnew /**< pointer to store new (reduced) number of quadratic elements */
1022  );
1023 
1024 /**@} */
1025 
1026 /**@name Expression graph node methods */
1027 /**@{ */
1028 
1029 /** captures node, i.e., increases number of uses */
1032  SCIP_EXPRGRAPHNODE* node /**< expression graph node to capture */
1033  );
1034 
1035 /** returns whether a node is currently enabled */
1038  SCIP_EXPRGRAPHNODE* node /**< expression graph node to enable */
1039  );
1040 
1041 /** gets number of children of a node in an expression graph */
1044  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1045  );
1046 
1047 /** gets children of a node in an expression graph */
1050  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1051  );
1052 
1053 /** gets number of parents of a node in an expression graph */
1056  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1057  );
1058 
1059 /** gets parents of a node in an expression graph */
1062  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1063  );
1064 
1065 /** gets depth of node in expression graph */
1068  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1069  );
1070 
1071 /** gets position of node in expression graph at its depth level */
1074  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1075  );
1076 
1077 /** gets operator of a node in an expression graph */
1080  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1081  );
1082 
1083 /** gives index belonging to a SCIP_EXPR_VARIDX or SCIP_EXPR_PARAM operand */
1086  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1087  );
1088 
1089 /** gives real belonging to a SCIP_EXPR_CONST operand */
1092  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1093  );
1094 
1095 /** gives variable belonging to a SCIP_EXPR_VARIDX expression */
1098  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1099  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1100  );
1101 
1102 /** gives exponent belonging to a SCIP_EXPR_REALPOWER expression */
1105  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1106  );
1107 
1108 /** gives exponent belonging to a SCIP_EXPR_INTPOWER expression */
1111  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1112  );
1113 
1114 /** gives exponent belonging to a SCIP_EXPR_SIGNPOWER expression */
1117  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1118  );
1119 
1120 /** gives linear coefficients belonging to a SCIP_EXPR_LINEAR expression */
1123  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1124  );
1125 
1126 /** gives constant belonging to a SCIP_EXPR_LINEAR expression */
1129  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1130  );
1131 
1132 /** gives constant belonging to a SCIP_EXPR_QUADRATIC expression */
1135  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1136  );
1137 
1138 /** gives linear coefficients belonging to a SCIP_EXPR_QUADRATIC expression, or NULL if all coefficients are 0.0 */
1141  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1142  );
1143 
1144 /** gives quadratic elements belonging to a SCIP_EXPR_QUADRATIC expression */
1147  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1148  );
1149 
1150 /** gives number of quadratic elements belonging to a SCIP_EXPR_QUADRATIC expression */
1153  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1154  );
1155 
1156 /** gives the monomials belonging to a SCIP_EXPR_POLYNOMIAL expression */
1159  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1160  );
1161 
1162 /** gives the number of monomials belonging to a SCIP_EXPR_POLYNOMIAL expression */
1165  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1166  );
1167 
1168 /** gives the constant belonging to a SCIP_EXPR_POLYNOMIAL expression */
1171  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1172  );
1173 
1174 /** gives the curvature of a single monomial belonging to a SCIP_EXPR_POLYNOMIAL expression */
1177  SCIP_EXPRGRAPHNODE* node, /**< expression graph node */
1178  int monomialidx, /**< index of monomial */
1179  SCIP_Real infinity, /**< value for infinity in interval arithmetics */
1180  SCIP_EXPRCURV* curv /**< buffer to store monomial curvature */
1181  );
1182 
1183 /** gives the user data belonging to a SCIP_EXPR_USER expression */
1186  SCIP_EXPRGRAPHNODE* node
1187  );
1188 
1189 /** indicates whether a user expression has the estimator callback defined */
1192  SCIP_EXPRGRAPHNODE* node
1193  );
1194 
1195 /** gets bounds of a node in an expression graph */
1198  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1199  );
1200 
1201 /** gets value of expression associated to node from last evaluation call */
1204  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1205  );
1206 
1207 /** gets curvature of expression associated to node from last curvature check call */
1210  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1211  );
1212 
1213 #ifdef NDEBUG
1214 
1215 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
1216  * speed up the algorithms.
1217  */
1218 
1219 #define SCIPexprgraphCaptureNode(node) do { ++(node)->nuses; } while( FALSE )
1220 #define SCIPexprgraphIsNodeEnabled(node) (node)->enabled
1221 #define SCIPexprgraphGetNodeNChildren(node) (node)->nchildren
1222 #define SCIPexprgraphGetNodeChildren(node) (node)->children
1223 #define SCIPexprgraphGetNodeNParents(node) (node)->nparents
1224 #define SCIPexprgraphGetNodeParents(node) (node)->parents
1225 #define SCIPexprgraphGetNodeDepth(node) (node)->depth
1226 #define SCIPexprgraphGetNodePosition(node) (node)->pos
1227 #define SCIPexprgraphGetNodeOperator(node) (node)->op
1228 #define SCIPexprgraphGetNodeOperatorIndex(node) (node)->data.intval
1229 #define SCIPexprgraphGetNodeOperatorReal(node) (node)->data.dbl
1230 #define SCIPexprgraphGetNodeVar(exprgraph, node) (exprgraph)->vars[(node)->data.intval]
1231 #define SCIPexprgraphGetNodeRealPowerExponent(node) (node)->data.dbl
1232 #define SCIPexprgraphGetNodeIntPowerExponent(node) (node)->data.intval
1233 #define SCIPexprgraphGetNodeSignPowerExponent(node) (node)->data.dbl
1234 #define SCIPexprgraphGetNodeLinearCoefs(node) ((SCIP_Real*)(node)->data.data)
1235 #define SCIPexprgraphGetNodeLinearConstant(node) (((SCIP_Real*)(node)->data.data)[(node)->nchildren])
1236 #define SCIPexprgraphGetNodeQuadraticConstant(node) ((SCIP_EXPRDATA_QUADRATIC*)(node)->data.data)->constant
1237 #define SCIPexprgraphGetNodeQuadraticLinearCoefs(node) ((SCIP_EXPRDATA_QUADRATIC*)(node)->data.data)->lincoefs
1238 #define SCIPexprgraphGetNodeQuadraticQuadElements(node) ((SCIP_EXPRDATA_QUADRATIC*)(node)->data.data)->quadelems
1239 #define SCIPexprgraphGetNodeQuadraticNQuadElements(node) ((SCIP_EXPRDATA_QUADRATIC*)(node)->data.data)->nquadelems
1240 #define SCIPexprgraphGetNodePolynomialMonomials(node) ((SCIP_EXPRDATA_POLYNOMIAL*)(node)->data.data)->monomials
1241 #define SCIPexprgraphGetNodePolynomialNMonomials(node) ((SCIP_EXPRDATA_POLYNOMIAL*)(node)->data.data)->nmonomials
1242 #define SCIPexprgraphGetNodePolynomialConstant(node) ((SCIP_EXPRDATA_POLYNOMIAL*)(node)->data.data)->constant
1243 #define SCIPexprgraphGetNodeUserData(node) ((SCIP_EXPRDATA_USER*)(node)->data.data)->userdata
1244 #define SCIPexprgraphHasNodeUserEstimator(node) (((SCIP_EXPRDATA_USER*)node->data.data)->estimate != NULL)
1245 #define SCIPexprgraphGetNodeBounds(node) (node)->bounds
1246 #define SCIPexprgraphGetNodeVal(node) (node)->value
1247 #define SCIPexprgraphGetNodeCurvature(node) (node)->curv
1248 
1249 #endif
1250 
1251 /** creates an expression graph node */
1254  BMS_BLKMEM* blkmem, /**< block memory */
1255  SCIP_EXPRGRAPHNODE** node, /**< buffer to store expression graph node */
1256  SCIP_EXPROP op, /**< operator type of expression */
1257  ...
1258  );
1259 
1260 /** creates an expression graph node for a linear expression */
1263  BMS_BLKMEM* blkmem, /**< block memory */
1264  SCIP_EXPRGRAPHNODE** node, /**< buffer to store expression graph node */
1265  int ncoefs, /**< number of coefficients */
1266  SCIP_Real* coefs, /**< coefficients of linear expression */
1267  SCIP_Real constant /**< constant of linear expression */
1268  );
1269 
1270 /** creates an expression graph node for a quadratic expression */
1273  BMS_BLKMEM* blkmem, /**< block memory */
1274  SCIP_EXPRGRAPHNODE** node, /**< buffer to store expression graph node */
1275  int nchildren, /**< number of children */
1276  SCIP_Real* lincoefs, /**< linear coefficients for children, or NULL */
1277  int nquadelems, /**< number of quadratic elements */
1278  SCIP_QUADELEM* quadelems, /**< quadratic elements, or NULL if nquadelems == 0 */
1279  SCIP_Real constant /**< constant */
1280  );
1281 
1282 /** creates an expression graph node for a polynomial expression */
1285  BMS_BLKMEM* blkmem, /**< block memory */
1286  SCIP_EXPRGRAPHNODE** node, /**< buffer to store expression graph node */
1287  int nmonomials, /**< number of monomials */
1288  SCIP_EXPRDATA_MONOMIAL** monomials, /**< monomials */
1289  SCIP_Real constant, /**< constant of polynomial */
1290  SCIP_Bool copymonomials /**< whether to copy monomials or to assume ownership */
1291  );
1292 
1293 /** adds monomials to an expression graph node that is a polynomial expression */
1296  BMS_BLKMEM* blkmem, /**< block memory */
1297  SCIP_EXPRGRAPHNODE* node, /**< store expression graph node with polynomial operator */
1298  int nmonomials, /**< number of monomials */
1299  SCIP_EXPRDATA_MONOMIAL** monomials, /**< monomials */
1300  SCIP_Bool copymonomials /**< whether to copy monomials or to assume ownership */
1301  );
1302 
1303 /** creates an expression graph node for a user expression */
1306  BMS_BLKMEM* blkmem, /**< block memory */
1307  SCIP_EXPRGRAPHNODE** node, /**< buffer to store expression graph node */
1308  SCIP_USEREXPRDATA* data, /**< user data for expression, node assumes ownership */
1309  SCIP_EXPRINTCAPABILITY evalcapability, /**< evaluation capability */
1310  SCIP_DECL_USEREXPREVAL ((*eval)), /**< evaluation function */
1311  SCIP_DECL_USEREXPRINTEVAL ((*inteval)), /**< interval evaluation function */
1312  SCIP_DECL_USEREXPRCURV ((*curv)), /**< curvature check function */
1313  SCIP_DECL_USEREXPRPROP ((*prop)), /**< interval propagation function */
1314  SCIP_DECL_USEREXPRESTIMATE ((*estimate)), /**< estimation function, or NULL if convex, concave, or not implemented */
1315  SCIP_DECL_USEREXPRCOPYDATA ((*copydata)), /**< expression data copy function, or NULL if nothing to copy */
1316  SCIP_DECL_USEREXPRFREEDATA ((*freedata)), /**< expression data free function, or NULL if nothing to free */
1317  SCIP_DECL_USEREXPRPRINT ((*print)) /**< expression print function, or NULL for default string "user" */
1318  );
1319 
1320 /** given a node of an expression graph, splitup a linear part which variables are not used somewhere else in the same expression
1321  * E.g., if the expression is 1 + x + y + y^2, one gets 1 + x and the node remains at y + y^2.
1322  * If the node is a linear expression, it may be freed.
1323  * If it is not linear, the node may change, i.e., the remaining nonlinear part may be stored in a new node.
1324  * It is assumed that the user had captured the node.
1325  * It is assumed that the expression graph has been simplified before.
1326  */
1329  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1330  SCIP_EXPRGRAPHNODE** node, /**< expression graph node where to splitup linear part */
1331  int linvarssize, /**< length of linvars and lincoefs arrays */
1332  int* nlinvars, /**< buffer to store length of linear term that have been splitup */
1333  void** linvars, /**< buffer to store variables of linear part */
1334  SCIP_Real* lincoefs, /**< buffer to store coefficients of linear part */
1335  SCIP_Real* constant /**< buffer to store constant part */
1336  );
1337 
1338 /** moves parents from a one node to another node
1339  * in other words, replaces the child srcnode by targetnode in all parents of srcnode
1340  * srcnode may be freed, if not captured
1341  * it is assumes that targetnode represents the same expression as srcnode
1342  */
1345  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1346  SCIP_EXPRGRAPHNODE** srcnode, /**< node which parents to move */
1347  SCIP_EXPRGRAPHNODE* targetnode /**< node where to move parents to */
1348  );
1349 
1350 /** releases node, i.e., decreases number of uses
1351  * node is freed if no parents and no other uses
1352  * children are recursively released if they have no other parents
1353  * nodes that are removed are also freed
1354  * if node correspond to a variable, then the variable is removed from the expression graph
1355  * similar for constants
1356  */
1359  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1360  SCIP_EXPRGRAPHNODE** node /**< expression graph node to release */
1361  );
1362 
1363 /** frees a node of an expression graph */
1366  BMS_BLKMEM* blkmem, /**< block memory */
1367  SCIP_EXPRGRAPHNODE** node /**< pointer to expression graph node that should be freed */
1368  );
1369 
1370 /** enables a node and recursively all its children in an expression graph */
1373  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1374  SCIP_EXPRGRAPHNODE* node /**< expression graph node to enable */
1375  );
1376 
1377 /** disables a node and recursively all children which have no enabled parents in an expression graph */
1380  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1381  SCIP_EXPRGRAPHNODE* node /**< expression graph node to enable */
1382  );
1383 
1384 /** returns whether the node has siblings in the expression graph */
1387  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1388  );
1389 
1390 /** returns whether all children of an expression graph node are variable nodes
1391  * gives TRUE for nodes without children
1392  */
1395  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1396  );
1397 
1398 /** returns whether the node has an ancestor which has a nonlinear expression operand */
1401  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1402  );
1403 
1404 /** prints an expression graph node */
1407  SCIP_EXPRGRAPHNODE* node, /**< expression graph node */
1408  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1409  FILE* file /**< file to print to, or NULL for stdout */
1410  );
1411 
1412 /** tightens the bounds in a node of the graph
1413  * preparation for reverse propagation
1414  * sets bound status to SCIP_EXPRBOUNDSTATUS_TIGHTENEDBYPARENTRECENT if tightening is strong enough and not cutoff
1415  */
1418  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1419  SCIP_EXPRGRAPHNODE* node, /**< node in expression graph with no parents */
1420  SCIP_INTERVAL nodebounds, /**< new bounds for node */
1421  SCIP_Real minstrength, /**< minimal required relative bound strengthening in a node to trigger a propagation into children nodes (set to negative value if propagation should always be triggered) */
1422  SCIP_Real infinity, /**< value for infinity in interval arithmetics */
1423  SCIP_Bool* cutoff /**< buffer to store whether a node's bounds were propagated to an empty interval */
1424  );
1425 
1426 /** ensures that bounds and curvature information in a node is uptodate
1427  * assumes that bounds and curvature in children are uptodate
1428  */
1431  SCIP_EXPRGRAPHNODE* node, /**< expression graph node */
1432  SCIP_Real infinity, /**< value for infinity in interval arithmetics */
1433  SCIP_Real minstrength, /**< minimal required relative bound strengthening to trigger a bound recalculation in parent nodes */
1434  SCIP_Bool clearreverseprop /**< whether to reset bound tightenings from reverse propagation */
1435  );
1436 
1437 /**@} */
1438 
1439 /**@name Expression graph methods */
1440 /**@{ */
1441 
1442 /** get current maximal depth of expression graph */
1445  SCIP_EXPRGRAPH* exprgraph /**< expression graph */
1446  );
1447 
1448 /** gets array with number of nodes at each depth of expression graph */
1451  SCIP_EXPRGRAPH* exprgraph /**< expression graph */
1452  );
1453 
1454 /** gets nodes of expression graph, one array per depth */
1457  SCIP_EXPRGRAPH* exprgraph /**< expression graph */
1458  );
1459 
1460 /** gets number of variables in expression graph */
1463  SCIP_EXPRGRAPH* exprgraph /**< pointer to expression graph that should be freed */
1464  );
1465 
1466 /** gets array of variables in expression graph */
1468 void** SCIPexprgraphGetVars(
1469  SCIP_EXPRGRAPH* exprgraph /**< pointer to expression graph that should be freed */
1470  );
1471 
1472 /** gets array of expression graph nodes corresponding to variables */
1475  SCIP_EXPRGRAPH* exprgraph /**< pointer to expression graph that should be freed */
1476  );
1477 
1478 /** sets value for a single variable given as expression graph node */
1481  SCIP_EXPRGRAPHNODE* varnode, /**< expression graph node corresponding to variable */
1482  SCIP_Real value /**< new value for variable */
1483  );
1484 
1485 /** sets bounds for variables */
1488  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1489  SCIP_INTERVAL* varbounds /**< new bounds for variables */
1490  );
1491 
1492 /** sets bounds for a single variable */
1495  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1496  void* var, /**< variable */
1497  SCIP_INTERVAL varbounds /**< new bounds of variable */
1498  );
1499 
1500 /** sets bounds for a single variable given as expression graph node */
1503  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1504  SCIP_EXPRGRAPHNODE* varnode, /**< expression graph node corresponding to variable */
1505  SCIP_INTERVAL varbounds /**< new bounds of variable */
1506  );
1507 
1508 /** sets lower bound for a single variable given as expression graph node */
1511  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1512  SCIP_EXPRGRAPHNODE* varnode, /**< expression graph node corresponding to variable */
1513  SCIP_Real lb /**< new lower bound for variable */
1514  );
1515 
1516 /** sets upper bound for a single variable given as expression graph node */
1519  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1520  SCIP_EXPRGRAPHNODE* varnode, /**< expression graph node corresponding to variable */
1521  SCIP_Real ub /**< new upper bound for variable */
1522  );
1523 
1524 /** gets bounds that are stored for all variables */
1527  SCIP_EXPRGRAPH* exprgraph /**< expression graph */
1528  );
1529 
1530 #ifdef NDEBUG
1531 
1532 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
1533  * speed up the algorithms.
1534  */
1535 
1536 #define SCIPexprgraphGetDepth(exprgraph) (exprgraph)->depth
1537 #define SCIPexprgraphGetNNodes(exprgraph) (exprgraph)->nnodes
1538 #define SCIPexprgraphGetNodes(exprgraph) (exprgraph)->nodes
1539 #define SCIPexprgraphGetNVars(exprgraph) (exprgraph)->nvars
1540 #define SCIPexprgraphGetVars(exprgraph) (exprgraph)->vars
1541 #define SCIPexprgraphGetVarNodes(exprgraph) (exprgraph)->varnodes
1542 #define SCIPexprgraphSetVarNodeValue(varnode, newvalue) do { (varnode)->value = newvalue; } while (FALSE)
1543 #define SCIPexprgraphSetVarsBounds(exprgraph, newvarbounds) BMScopyMemoryArray((exprgraph)->varbounds, newvarbounds, (exprgraph)->nvars)
1544 #define SCIPexprgraphSetVarBounds(exprgraph, var, newvarbounds) do { (exprgraph)->varbounds[(int)(size_t)SCIPhashmapGetImage((exprgraph)->varidxs, var)] = newvarbounds; } while (FALSE)
1545 #define SCIPexprgraphSetVarNodeBounds(exprgraph, varnode, newvarbounds) do { (exprgraph)->varbounds[(varnode)->data.intval] = newvarbounds; } while (FALSE)
1546 #define SCIPexprgraphSetVarNodeLb(exprgraph, varnode, lb) do { (exprgraph)->varbounds[(varnode)->data.intval].inf = lb; } while (FALSE)
1547 #define SCIPexprgraphSetVarNodeUb(exprgraph, varnode, ub) do { (exprgraph)->varbounds[(varnode)->data.intval].sup = ub; } while (FALSE)
1548 #define SCIPexprgraphGetVarsBounds(exprgraph) (exprgraph)->varbounds
1549 
1550 #endif
1551 
1552 /** creates an empty expression graph */
1555  BMS_BLKMEM* blkmem, /**< block memory */
1556  SCIP_EXPRGRAPH** exprgraph, /**< buffer to store pointer to expression graph */
1557  int varssizeinit, /**< minimal initial size for variables array, or -1 to choose automatically */
1558  int depthinit, /**< minimal initial depth of expression graph, or -1 to choose automatically */
1559  SCIP_DECL_EXPRGRAPHVARADDED((*exprgraphvaradded)), /**< callback method to invoke when a variable has been added to the expression graph, or NULL if not needed */
1560  SCIP_DECL_EXPRGRAPHVARREMOVE((*exprgraphvarremove)), /**< callback method to invoke when a variable will be removed from the expression graph, or NULL if not needed */
1561  SCIP_DECL_EXPRGRAPHVARCHGIDX((*exprgraphvarchgidx)), /**< callback method to invoke when a variable changes its index in the expression graph, or NULL if not needed */
1562  void* userdata /**< user data to pass to callback functions */
1563  );
1564 
1565 /** frees an expression graph */
1568  SCIP_EXPRGRAPH** exprgraph /**< pointer to expression graph that should be freed */
1569  );
1570 
1571 /** adds an expression graph node to an expression graph
1572  * expression graph assumes ownership of node
1573  * children are notified about new parent
1574  * depth will be chosen to be the maximum of mindepth and the depth of all children plus one
1575  */
1578  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1579  SCIP_EXPRGRAPHNODE* node, /**< expression graph node to add */
1580  int mindepth, /**< minimal depth in expression graph where to add node, e.g., 0 or smaller to choose automatically */
1581  int nchildren, /**< number of children */
1582  SCIP_EXPRGRAPHNODE** children /**< children nodes, or NULL if no children */
1583  );
1584 
1585 /** adds variables to an expression graph, if not existing yet
1586  * also already existing nodes are enabled
1587  */
1590  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1591  int nvars, /**< number of variables to add */
1592  void** vars, /**< variables to add */
1593  SCIP_EXPRGRAPHNODE** varnodes /**< array to store nodes corresponding to variables, or NULL if not of interest */
1594  );
1595 
1596 /** adds a constant to an expression graph, if not existing yet
1597  * also already existing nodes are enabled
1598  */
1600  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1601  SCIP_Real constant, /**< constant to add */
1602  SCIP_EXPRGRAPHNODE** constnode /**< buffer to store pointer to expression graph node corresponding to constant */
1603  );
1604 
1605 /** adds sum of expression trees into expression graph
1606  * node will also be captured
1607  */
1610  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1611  int nexprtrees, /**< number of expression trees to add */
1612  SCIP_EXPRTREE** exprtrees, /**< expression trees that should be added */
1613  SCIP_Real* coefs, /**< coefficients of expression trees, or NULL if all 1.0 */
1614  SCIP_EXPRGRAPHNODE** rootnode, /**< buffer to store expression graph node corresponding to root of expression tree */
1615  SCIP_Bool* rootnodeisnew /**< buffer to indicate whether the node in *rootnode has been newly created for this expression tree (otherwise, expression tree was already in graph) */
1616  );
1617 
1618 /** replaces variable in expression graph by a linear sum of variables
1619  * variables will be added if not in the graph yet
1620  */
1623  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1624  void* var, /**< variable to replace */
1625  int ncoefs, /**< number of coefficients in linear term */
1626  SCIP_Real* coefs, /**< coefficients in linear term, or NULL if ncoefs == 0 */
1627  void** vars, /**< variables in linear term */
1628  SCIP_Real constant /**< constant offset */
1629  );
1630 
1631 /** finds expression graph node corresponding to a variable */
1634  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1635  void* var, /**< variable to search for */
1636  SCIP_EXPRGRAPHNODE** varnode /**< buffer to store node corresponding to variable, if found, or NULL if not found */
1637  );
1638 
1639 /** finds expression graph node corresponding to a constant */
1642  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1643  SCIP_Real constant, /**< constant to search for */
1644  SCIP_EXPRGRAPHNODE** constnode /**< buffer to store node corresponding to constant, if found, or NULL if not found */
1645  );
1646 
1647 /** prints an expression graph in dot format */
1650  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1651  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1652  FILE* file, /**< file to print to, or NULL for stdout */
1653  const char** varnames /**< variable names, or NULL for generic names */
1654  );
1655 
1656 /** evaluates nodes of expression graph for given values of variables */
1659  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1660  SCIP_Real* varvals /**< values for variables */
1661  );
1662 
1663 /** propagates bound changes in variables forward through the expression graph */
1666  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1667  SCIP_Real infinity, /**< value for infinity in interval arithmetics */
1668  SCIP_Bool clearreverseprop, /**< whether to reset bound tightenings from reverse propagation */
1669  SCIP_Bool* domainerror /**< buffer to store whether a node with empty bounds has been found, propagation is interrupted in this case */
1670  );
1671 
1672 /** propagates bound changes in nodes backward through the graph
1673  * new bounds are not stored in varbounds, but only in nodes corresponding to variables
1674  * NOTE: it is assumed that SCIPexprgraphPropagateVarBounds was called before if variable bounds were relaxed
1675  */
1678  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1679  SCIP_Real infinity, /**< value for infinity in interval arithmetics */
1680  SCIP_Real minstrength, /**< minimal required relative bound strengthening in a node to trigger a propagation into children nodes */
1681  SCIP_Bool* cutoff /**< buffer to store whether a node's bounds were propagated to an empty interval */
1682  );
1683 
1684 /** updates curvature information in expression graph nodes w.r.t. currently stored variable bounds
1685  * implies update of bounds in expression graph
1686  */
1689  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1690  SCIP_Real infinity, /**< value for infinity in interval arithmetics */
1691  SCIP_Bool clearreverseprop /**< whether to reset bound tightenings from reverse propagation */
1692  );
1693 
1694 /** aims at simplifying an expression graph
1695  * a domain error can occur when variables were fixed to values for which a parent expression is not defined (e.g., 0^(-1) or log(-1))
1696  */
1699  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1700  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1701  SCIP_Real eps, /**< threshold, under which positive values are treat as 0 */
1702  int maxexpansionexponent,/**< maximal exponent for which we still expand non-monomial polynomials */
1703  SCIP_Bool* havechange, /**< buffer to indicate whether the graph has been modified */
1704  SCIP_Bool* domainerror /**< buffer to indicate whether a domain error has been encountered, i.e., some expressions turned into NaN */
1705  );
1706 
1707 /** creates an expression tree from a given node in an expression graph */
1710  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1711  SCIP_EXPRGRAPHNODE* rootnode, /**< expression graph node that should represent root of expression tree */
1712  SCIP_EXPRTREE** exprtree /**< buffer to store pointer to created expression tree */
1713  );
1714 
1715 /** creates a sum of expression trees with pairwise disjoint variables from a given node in an expression graph
1716  * Giving SCIPexprgraphGetNodeNChildren() for exprtreesize is always sufficient.
1717  */
1720  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1721  SCIP_EXPRGRAPHNODE* node, /**< expression graph node which represents expression to get */
1722  int exprtreessize, /**< length of exprtrees and exprtreecoefs arrays, need to be at least one */
1723  int* nexprtrees, /**< buffer to store number of expression trees */
1724  SCIP_EXPRTREE** exprtrees, /**< array where to store expression trees */
1725  SCIP_Real* exprtreecoefs /**< array where to store coefficients of expression trees */
1726  );
1727 
1728 /** returns how often expression graph variables are used in a subtree of the expression graph */
1731  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1732  SCIP_EXPRGRAPHNODE* node, /**< root node of expression graph subtree */
1733  int* varsusage /**< array where to count usage of variables, length must be at least the number of variables in the graph */
1734  );
1735 
1736 /** gives the number of summands which the expression of an expression graph node consists of */
1739  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1740  );
1741 
1742 /** creates a sum of expression trees, possibly sharing variables, from a given node in an expression graph */
1745  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1746  SCIP_EXPRGRAPHNODE* node, /**< expression graph node which represents expression to get */
1747  int exprtreessize, /**< length of exprtrees and exptreecoefs arrays, should be at least SCIPexprgraphGetSumTreesNSummands() */
1748  int* nexprtrees, /**< buffer to store number of expression trees */
1749  SCIP_EXPRTREE** exprtrees, /**< array where to store expression trees */
1750  SCIP_Real* exprtreecoefs /**< array where to store coefficients of expression trees */
1751  );
1752 
1753 /**@} */
1754 
1755 #ifdef __cplusplus
1756 }
1757 #endif
1758 
1759 #endif /* __NLPI_PUB_EXPR_H__ */
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphCreateNodeLinear(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE **node, int ncoefs, SCIP_Real *coefs, SCIP_Real constant)
Definition: expr.c:13458
SCIP_EXPORT SCIP_EXPRCURV SCIPexprcurvNegate(SCIP_EXPRCURV curvature)
Definition: expr.c:215
SCIP_EXPORT SCIP_EXPRGRAPHNODE ** SCIPexprgraphGetNodeParents(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13021
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphMoveNodeParents(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE **srcnode, SCIP_EXPRGRAPHNODE *targetnode)
Definition: expr.c:14420
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphReplaceVarByLinearSum(SCIP_EXPRGRAPH *exprgraph, void *var, int ncoefs, SCIP_Real *coefs, void **vars, SCIP_Real constant)
Definition: expr.c:15542
SCIP_RETCODE SCIPexprgraphAddConst(SCIP_EXPRGRAPH *exprgraph, SCIP_Real constant, SCIP_EXPRGRAPHNODE **constnode)
Definition: expr.c:15354
SCIP_EXPORT void * SCIPexprgraphGetNodeVar(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13083
SCIP_EXPORT void SCIPquadelemSort(SCIP_QUADELEM *quadelems, int nquadelems)
Definition: expr.c:9213
SCIP_EXPORT SCIP_RETCODE SCIPexprCopyDeep(BMS_BLKMEM *blkmem, SCIP_EXPR **targetexpr, SCIP_EXPR *sourceexpr)
Definition: expr.c:6143
static SCIP_RETCODE eval(SCIP_EXPR *expr, const vector< Type > &x, SCIP_Real *param, Type &val)
SCIP_EXPORT int SCIPexprGetNChildren(SCIP_EXPR *expr)
Definition: expr.c:5705
SCIP_EXPORT SCIP_RETCODE SCIPexprtreeSimplify(SCIP_EXPRTREE *tree, SCIP_MESSAGEHDLR *messagehdlr, SCIP_Real eps, int maxexpansionexponent, int *nlinvars, int *linidxs, SCIP_Real *lincoefs)
Definition: expr.c:8928
SCIP_EXPORT void SCIPexprChgPolynomialConstant(SCIP_EXPR *expr, SCIP_Real constant)
Definition: expr.c:6691
SCIP_EXPORT SCIP_RETCODE SCIPexprtreeEval(SCIP_EXPRTREE *tree, SCIP_Real *varvals, SCIP_Real *val)
Definition: expr.c:8725
SCIP_RETCODE SCIPexprCreateQuadratic(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, int nchildren, SCIP_EXPR **children, SCIP_Real constant, SCIP_Real *lincoefs, int nquadelems, SCIP_QUADELEM *quadelems)
Definition: expr.c:6586
SCIP_EXPORT SCIP_RETCODE SCIPexprSimplify(BMS_BLKMEM *blkmem, SCIP_MESSAGEHDLR *messagehdlr, SCIP_EXPR *expr, SCIP_Real eps, int maxexpansionexponent, int nvars, int *nlinvars, int *linidxs, SCIP_Real *lincoefs)
Definition: expr.c:7797
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphGetNodePolynomialMonomialCurvature(SCIP_EXPRGRAPHNODE *node, int monomialidx, SCIP_Real infinity, SCIP_EXPRCURV *curv)
Definition: expr.c:13241
SCIP_EXPORT void SCIPexprgraphDisableNode(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:14598
SCIP_EXPORT SCIP_RETCODE SCIPexprAddMonomialFactors(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_MONOMIAL *monomial, int nfactors, int *childidxs, SCIP_Real *exponents)
Definition: expr.c:6864
SCIP_EXPORT SCIP_RETCODE SCIPexprSubstituteVars(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, SCIP_EXPR **substexprs)
Definition: expr.c:8147
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphPropagateVarBounds(SCIP_EXPRGRAPH *exprgraph, SCIP_Real infinity, SCIP_Bool clearreverseprop, SCIP_Bool *domainerror)
Definition: expr.c:15861
#define infinity
Definition: gastrans.c:71
SCIP_EXPORT SCIP_Real SCIPexprgraphGetNodeQuadraticConstant(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13154
struct SCIP_UserExprData SCIP_USEREXPRDATA
Definition: type_expr.h:221
SCIP_EXPORT SCIP_EXPRCURV SCIPexprgraphGetNodeCurvature(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13365
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphCreateNodeUser(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE **node, SCIP_USEREXPRDATA *data, SCIP_EXPRINTCAPABILITY evalcapability, SCIP_DECL_USEREXPREVAL((*eval)), SCIP_DECL_USEREXPRINTEVAL((*inteval)), SCIP_DECL_USEREXPRCURV((*curv)), SCIP_DECL_USEREXPRPROP((*prop)), SCIP_DECL_USEREXPRESTIMATE((*estimate)), SCIP_DECL_USEREXPRCOPYDATA((*copydata)), SCIP_DECL_USEREXPRFREEDATA((*freedata)), SCIP_DECL_USEREXPRPRINT((*print)))
Definition: expr.c:13554
SCIP_EXPORT SCIP_Bool SCIPexprgraphIsNodeEnabled(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:12981
SCIP_EXPORT SCIP_Real SCIPexprgraphGetNodeVal(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13355
#define SCIP_DECL_USEREXPREVAL(x)
Definition: type_expr.h:248
#define SCIP_DECL_USEREXPRPRINT(x)
Definition: type_expr.h:310
type definitions for expression interpreter
SCIP_EXPORT void SCIPexprgraphGetSubtreeVarsUsage(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, int *varsusage)
Definition: expr.c:16741
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphGetSumTrees(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, int exprtreessize, int *nexprtrees, SCIP_EXPRTREE **exprtrees, SCIP_Real *exprtreecoefs)
Definition: expr.c:16793
#define SCIP_EXPORT
Definition: def.h:100
SCIP_EXPORT SCIP_EXPRCURV SCIPexprcurvMultiply(SCIP_Real factor, SCIP_EXPRCURV curvature)
Definition: expr.c:241
SCIP_EXPORT SCIP_RETCODE SCIPexprCreateMonomial(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_MONOMIAL **monomial, SCIP_Real coef, int nfactors, int *childidxs, SCIP_Real *exponents)
Definition: expr.c:7037
data definitions for expressions and expression trees
SCIP_EXPORT void SCIPexprGetVarsUsage(SCIP_EXPR *expr, int *varsusage)
Definition: expr.c:7559
SCIP_EXPORT SCIP_Real SCIPexprGetOpReal(SCIP_EXPR *expr)
Definition: expr.c:5736
SCIP_EXPORT void SCIPexprtreeGetVarsUsage(SCIP_EXPRTREE *tree, int *varsusage)
Definition: expr.c:8909
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphGetSeparableTrees(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, int exprtreessize, int *nexprtrees, SCIP_EXPRTREE **exprtrees, SCIP_Real *exprtreecoefs)
Definition: expr.c:16307
SCIP_EXPORT SCIP_RETCODE SCIPexprCreatePolynomial(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, int nchildren, SCIP_EXPR **children, int nmonomials, SCIP_EXPRDATA_MONOMIAL **monomials, SCIP_Real constant, SCIP_Bool copymonomials)
Definition: expr.c:6634
SCIP_EXPORT SCIP_Real SCIPexprGetRealPowerExponent(SCIP_EXPR *expr)
Definition: expr.c:5758
SCIP_EXPORT void SCIPexprgraphSetVarNodeLb(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *varnode, SCIP_Real lb)
Definition: expr.c:15061
#define SCIP_DECL_USEREXPRINTEVAL(x)
Definition: type_expr.h:261
SCIP_EXPORT SCIP_RETCODE SCIPexprtreeFree(SCIP_EXPRTREE **tree)
Definition: expr.c:8854
SCIP_EXPORT void SCIPexprMultiplyPolynomialByConstant(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, SCIP_Real factor)
Definition: expr.c:6704
SCIP_EXPORT const char * SCIPexprcurvGetName(SCIP_EXPRCURV curv)
Definition: expr.c:475
SCIP_EXPORT SCIP_Bool SCIPexprHasUserEstimator(SCIP_EXPR *expr)
Definition: expr.c:5953
SCIP_EXPORT SCIP_RETCODE SCIPexprAddMonomials(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, int nmonomials, SCIP_EXPRDATA_MONOMIAL **monomials, SCIP_Bool copymonomials)
Definition: expr.c:6669
SCIP_EXPORT SCIP_Real SCIPexprgraphGetNodeLinearConstant(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13142
SCIP_EXPORT void SCIPexprMergeMonomials(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, SCIP_Real eps, SCIP_Bool mergefactors)
Definition: expr.c:6807
SCIP_EXPORT int SCIPexpropGetNChildren(SCIP_EXPROP op)
Definition: expr.c:3275
SCIP_EXPORT SCIP_EXPRGRAPHNODE ** SCIPexprgraphGetVarNodes(SCIP_EXPRGRAPH *exprgraph)
Definition: expr.c:14987
SCIP_EXPORT int SCIPexprgraphGetNVars(SCIP_EXPRGRAPH *exprgraph)
Definition: expr.c:14967
SCIP_EXPORT SCIP_Real SCIPexprGetQuadConstant(SCIP_EXPR *expr)
Definition: expr.c:5829
SCIP_EXPORT int SCIPexprtreeGetNVars(SCIP_EXPRTREE *tree)
Definition: expr.c:8614
unsigned int SCIP_EXPRINTCAPABILITY
SCIP_EXPORT SCIP_RETCODE SCIPexprtreeCreate(BMS_BLKMEM *blkmem, SCIP_EXPRTREE **tree, SCIP_EXPR *root, int nvars, int nparams, SCIP_Real *params)
Definition: expr.c:8773
SCIP_EXPORT SCIP_Real SCIPexprgraphGetNodeSignPowerExponent(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13120
SCIP_EXPORT SCIP_RETCODE SCIPexprMulConstant(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, SCIP_EXPR *term, SCIP_Real factor)
Definition: expr.c:6406
SCIP_EXPORT int * SCIPexprgraphGetNNodes(SCIP_EXPRGRAPH *exprgraph)
Definition: expr.c:14947
SCIP_EXPORT void SCIPexprSortQuadElems(SCIP_EXPR *expr)
Definition: expr.c:6622
SCIP_EXPORT void SCIPexprgraphFreeNode(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE **node)
Definition: expr.c:14546
SCIP_EXPORT void SCIPexprgraphTightenNodeBounds(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, SCIP_INTERVAL nodebounds, SCIP_Real minstrength, SCIP_Real infinity, SCIP_Bool *cutoff)
Definition: expr.c:14724
real eps
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphCreateNode(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE **node, SCIP_EXPROP op,...)
Definition: expr.c:13375
SCIP_EXPORT void SCIPexprFreeDeep(BMS_BLKMEM *blkmem, SCIP_EXPR **expr)
Definition: expr.c:6185
SCIP_EXPORT int SCIPexprgraphGetNodePosition(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13041
SCIP_EXPORT SCIP_Bool SCIPexprgraphAreAllNodeChildrenVars(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:14655
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphSimplify(SCIP_EXPRGRAPH *exprgraph, SCIP_MESSAGEHDLR *messagehdlr, SCIP_Real eps, int maxexpansionexponent, SCIP_Bool *havechange, SCIP_Bool *domainerror)
Definition: expr.c:15990
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphCheckCurvature(SCIP_EXPRGRAPH *exprgraph, SCIP_Real infinity, SCIP_Bool clearreverseprop)
Definition: expr.c:15947
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphReleaseNode(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE **node)
Definition: expr.c:14452
SCIP_EXPORT SCIP_QUADELEM * SCIPexprGetQuadElements(SCIP_EXPR *expr)
Definition: expr.c:5817
SCIP_EXPORT SCIP_EXPRCURV SCIPexprcurvPower(SCIP_INTERVAL basebounds, SCIP_EXPRCURV basecurv, SCIP_Real exponent)
Definition: expr.c:254
SCIP_EXPORT SCIP_RETCODE SCIPexprtreeSubstituteVars(SCIP_EXPRTREE *tree, SCIP_EXPR **substexprs)
Definition: expr.c:9047
#define SCIP_DECL_EXPRGRAPHVARADDED(x)
Definition: type_expr.h:183
SCIP_EXPORT SCIP_RETCODE SCIPexprMultiplyMonomialByMonomial(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_MONOMIAL *monomial, SCIP_EXPRDATA_MONOMIAL *factor, int *childmap)
Definition: expr.c:6893
SCIP_EXPORT SCIP_RETCODE SCIPexprtreeFreeInterpreterData(SCIP_EXPRTREE *tree)
Definition: expr.c:8682
SCIP_EXPORT void SCIPexprReindexVars(SCIP_EXPR *expr, int *newindices)
Definition: expr.c:8185
SCIP_EXPORT void SCIPexprgraphSetVarsBounds(SCIP_EXPRGRAPH *exprgraph, SCIP_INTERVAL *varbounds)
Definition: expr.c:15009
SCIP_EXPORT SCIP_USEREXPRDATA * SCIPexprGetUserData(SCIP_EXPR *expr)
Definition: expr.c:5942
SCIP_EXPORT int SCIPexprgraphGetNodeQuadraticNQuadElements(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13190
SCIP_EXPORT SCIP_RETCODE SCIPexprMultiplyPolynomialByPolynomial(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, SCIP_EXPR *factor, int *childmap)
Definition: expr.c:6741
SCIP_EXPORT SCIP_EXPR ** SCIPexprGetChildren(SCIP_EXPR *expr)
Definition: expr.c:5715
SCIP_EXPORT void SCIPexprSortMonomialFactors(SCIP_EXPRDATA_MONOMIAL *monomial)
Definition: expr.c:7118
enum SCIP_ExprOp SCIP_EXPROP
Definition: type_expr.h:91
interval arithmetics for provable bounds
SCIP_EXPORT SCIP_Bool SCIPexprAreMonomialsEqual(SCIP_EXPRDATA_MONOMIAL *monomial1, SCIP_EXPRDATA_MONOMIAL *monomial2, SCIP_Real eps)
Definition: expr.c:6822
SCIP_EXPORT void SCIPexprgraphSetVarBounds(SCIP_EXPRGRAPH *exprgraph, void *var, SCIP_INTERVAL varbounds)
Definition: expr.c:15021
SCIP_EXPORT SCIP_Bool SCIPexprgraphHasNodeSibling(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:14636
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphUpdateNodeBoundsCurvature(SCIP_EXPRGRAPHNODE *node, SCIP_Real infinity, SCIP_Real minstrength, SCIP_Bool clearreverseprop)
Definition: expr.c:14786
SCIP_EXPORT const char * SCIPexpropGetName(SCIP_EXPROP op)
Definition: expr.c:3265
SCIP_EXPORT SCIP_RETCODE SCIPexprCreate(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, SCIP_EXPROP op,...)
Definition: expr.c:5975
SCIP_EXPORT void SCIPexprgraphSetVarNodeUb(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *varnode, SCIP_Real ub)
Definition: expr.c:15081
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphCreateNodePolynomial(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE **node, int nmonomials, SCIP_EXPRDATA_MONOMIAL **monomials, SCIP_Real constant, SCIP_Bool copymonomials)
Definition: expr.c:13510
SCIP_EXPORT SCIP_Real SCIPexprGetPolynomialConstant(SCIP_EXPR *expr)
Definition: expr.c:5890
SCIP_EXPORT void SCIPexprgraphPrintNode(SCIP_EXPRGRAPHNODE *node, SCIP_MESSAGEHDLR *messagehdlr, FILE *file)
Definition: expr.c:14708
SCIP_EXPORT void SCIPexprgraphCaptureNode(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:12969
void print(const Container &container, const std::string &prefix="", const std::string &suffix="", std::ostream &os=std::cout, bool negate=false, int prec=6)
SCIP_EXPORT SCIP_Real * SCIPexprgraphGetNodeLinearCoefs(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13131
SCIP_EXPORT SCIP_Real SCIPexprGetMonomialCoef(SCIP_EXPRDATA_MONOMIAL *monomial)
Definition: expr.c:5902
SCIP_EXPORT SCIP_RETCODE SCIPexprtreeEvalInt(SCIP_EXPRTREE *tree, SCIP_Real infinity, SCIP_INTERVAL *varvals, SCIP_INTERVAL *val)
Definition: expr.c:8741
SCIP_EXPORT SCIP_Real * SCIPexprGetMonomialExponents(SCIP_EXPRDATA_MONOMIAL *monomial)
Definition: expr.c:5932
SCIP_EXPORT void SCIPquadelemSqueeze(SCIP_QUADELEM *quadelems, int nquadelems, int *nquadelemsnew)
Definition: expr.c:9290
SCIP_EXPORT void SCIPexprgraphEnableNode(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:14571
SCIP_EXPORT SCIP_RETCODE SCIPexprCheckCurvature(SCIP_EXPR *expr, SCIP_Real infinity, SCIP_INTERVAL *varbounds, SCIP_Real *param, SCIP_EXPRCURV *curv, SCIP_INTERVAL *bounds)
Definition: expr.c:8064
SCIP_EXPORT SCIP_RETCODE SCIPexprGetMaxDegree(SCIP_EXPR *expr, int *maxdegree)
Definition: expr.c:7234
SCIP_EXPORT SCIP_RETCODE SCIPexprEvalUser(SCIP_EXPR *expr, SCIP_Real *argvals, SCIP_Real *val, SCIP_Real *gradient, SCIP_Real *hessian)
Definition: expr.c:7971
SCIP_EXPORT SCIP_EXPRINTCAPABILITY SCIPexprGetUserEvalCapability(SCIP_EXPR *expr)
Definition: expr.c:5964
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphFree(SCIP_EXPRGRAPH **exprgraph)
Definition: expr.c:15148
SCIP_EXPORT SCIP_Real SCIPexprgraphGetNodeOperatorReal(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13072
SCIP_EXPORT SCIP_Real SCIPexprGetSignPowerExponent(SCIP_EXPR *expr)
Definition: expr.c:5780
SCIP_EXPORT SCIP_EXPROP SCIPexprGetOperator(SCIP_EXPR *expr)
Definition: expr.c:5695
#define SCIP_DECL_USEREXPRCURV(x)
Definition: type_expr.h:272
SCIP_EXPORT int SCIPexprtreeGetNParams(SCIP_EXPRTREE *tree)
Definition: expr.c:8624
#define SCIP_DECL_USEREXPRESTIMATE(x)
Definition: type_expr.h:236
#define SCIP_DECL_USEREXPRPROP(x)
Definition: type_expr.h:284
SCIP_EXPORT void * SCIPexprGetOpData(SCIP_EXPR *expr)
Definition: expr.c:5747
SCIP_EXPORT SCIP_RETCODE SCIPexprParse(BMS_BLKMEM *blkmem, SCIP_MESSAGEHDLR *messagehdlr, SCIP_EXPR **expr, const char *str, const char *lastchar, int *nvars, int *varnames, int varnameslength)
Definition: expr.c:8540
SCIP_EXPORT SCIP_Bool SCIPquadelemSortedFind(SCIP_QUADELEM *quadelems, int idx1, int idx2, int nquadelems, int *pos)
Definition: expr.c:9238
SCIP_EXPORT int SCIPexprGetMonomialNFactors(SCIP_EXPRDATA_MONOMIAL *monomial)
Definition: expr.c:5912
SCIP_EXPORT void SCIPexprSortMonomials(SCIP_EXPR *expr)
Definition: expr.c:7025
SCIP_EXPORT SCIP_Bool SCIPexprtreeHasParam(SCIP_EXPRTREE *tree)
Definition: expr.c:8696
char ** varnames
Definition: nlpioracle.c:68
#define SCIP_Bool
Definition: def.h:70
SCIP_EXPORT void SCIPexprReindexParams(SCIP_EXPR *expr, int *newindices)
Definition: expr.c:8206
SCIP_EXPORT SCIP_Bool SCIPexprHasParam(SCIP_EXPR *expr)
Definition: expr.c:7215
SCIP_EXPORT SCIP_QUADELEM * SCIPexprgraphGetNodeQuadraticQuadElements(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13178
SCIP_EXPORT SCIP_Bool SCIPexprgraphHasNodeUserEstimator(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13333
SCIP_EXPORT int * SCIPexprGetMonomialChildIndices(SCIP_EXPRDATA_MONOMIAL *monomial)
Definition: expr.c:5922
SCIP_EXPORT SCIP_RETCODE SCIPexprMultiplyPolynomialByMonomial(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, SCIP_EXPRDATA_MONOMIAL *factor, int *childmap)
Definition: expr.c:6718
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphEval(SCIP_EXPRGRAPH *exprgraph, SCIP_Real *varvals)
Definition: expr.c:15840
SCIP_EXPORT void SCIPexprFreeShallow(BMS_BLKMEM *blkmem, SCIP_EXPR **expr)
Definition: expr.c:6223
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphAddExprtreeSum(SCIP_EXPRGRAPH *exprgraph, int nexprtrees, SCIP_EXPRTREE **exprtrees, SCIP_Real *coefs, SCIP_EXPRGRAPHNODE **rootnode, SCIP_Bool *rootnodeisnew)
Definition: expr.c:15401
SCIP_EXPORT void SCIPexprPrint(SCIP_EXPR *expr, SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char **varnames, const char **paramnames, SCIP_Real *paramvals)
Definition: expr.c:8227
SCIP_EXPORT SCIP_Bool SCIPexprgraphFindVarNode(SCIP_EXPRGRAPH *exprgraph, void *var, SCIP_EXPRGRAPHNODE **varnode)
Definition: expr.c:15714
SCIP_EXPORT int SCIPexprgraphGetNodePolynomialNMonomials(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13214
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphNodeSplitOffLinear(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE **node, int linvarssize, int *nlinvars, void **linvars, SCIP_Real *lincoefs, SCIP_Real *constant)
Definition: expr.c:13608
SCIP_EXPORT void SCIPexprMergeMonomialFactors(SCIP_EXPRDATA_MONOMIAL *monomial, SCIP_Real eps)
Definition: expr.c:6958
SCIP_EXPORT int SCIPexprGetNQuadElements(SCIP_EXPR *expr)
Definition: expr.c:5854
SCIP_EXPORT SCIP_RETCODE SCIPexprEval(SCIP_EXPR *expr, SCIP_Real *varvals, SCIP_Real *param, SCIP_Real *val)
Definition: expr.c:7868
SCIP_EXPORT int SCIPexprgraphGetNodeNParents(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13011
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphAddVars(SCIP_EXPRGRAPH *exprgraph, int nvars, void **vars, SCIP_EXPRGRAPHNODE **varnodes)
Definition: expr.c:15281
SCIP_EXPORT void SCIPexprChgMonomialCoef(SCIP_EXPRDATA_MONOMIAL *monomial, SCIP_Real newcoef)
Definition: expr.c:6853
SCIP_EXPORT void SCIPexprgraphSetVarNodeValue(SCIP_EXPRGRAPHNODE *varnode, SCIP_Real value)
Definition: expr.c:14997
SCIP_EXPORT SCIP_Real SCIPexprgraphGetNodePolynomialConstant(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13226
SCIP_EXPORT int SCIPexprgraphGetNodeDepth(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13031
SCIP_EXPORT SCIP_INTERVAL SCIPexprgraphGetNodeBounds(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13345
SCIP_EXPORT int SCIPexprGetIntPowerExponent(SCIP_EXPR *expr)
Definition: expr.c:5769
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphAddNode(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, int mindepth, int nchildren, SCIP_EXPRGRAPHNODE **children)
Definition: expr.c:15197
SCIP_EXPORT SCIP_EXPRDATA_MONOMIAL ** SCIPexprgraphGetNodePolynomialMonomials(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13202
SCIP_EXPORT SCIP_EXPROP SCIPexprgraphGetNodeOperator(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13051
SCIP_EXPORT void SCIPexprFreeMonomial(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_MONOMIAL **monomial)
Definition: expr.c:7094
SCIP_EXPORT SCIP_RETCODE SCIPexprEvalIntShallow(SCIP_EXPR *expr, SCIP_Real infinity, SCIP_INTERVAL *argvals, SCIP_INTERVAL *varvals, SCIP_Real *param, SCIP_INTERVAL *val)
Definition: expr.c:7909
SCIP_EXPORT SCIP_EXPRINTDATA * SCIPexprtreeGetInterpreterData(SCIP_EXPRTREE *tree)
Definition: expr.c:8659
SCIP_EXPORT int SCIPexprgraphGetSumTreesNSummands(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:16757
SCIP_EXPORT SCIP_RETCODE SCIPexprPolynomialPower(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, int exponent)
Definition: expr.c:6787
SCIP_EXPORT SCIP_RETCODE SCIPexprtreeGetMaxDegree(SCIP_EXPRTREE *tree, int *maxdegree)
Definition: expr.c:8712
SCIP_EXPORT SCIP_RETCODE SCIPexprtreeSetParams(SCIP_EXPRTREE *tree, int nparams, SCIP_Real *paramvals)
Definition: expr.c:8878
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphCreateNodeQuadratic(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE **node, int nchildren, SCIP_Real *lincoefs, int nquadelems, SCIP_QUADELEM *quadelems, SCIP_Real constant)
Definition: expr.c:13484
SCIP_EXPORT SCIP_EXPRCURV SCIPexprcurvMonomial(int nfactors, SCIP_Real *exponents, int *factoridxs, SCIP_EXPRCURV *factorcurv, SCIP_INTERVAL *factorbounds)
Definition: expr.c:362
SCIP_EXPORT void SCIPexprgraphSetVarNodeBounds(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *varnode, SCIP_INTERVAL varbounds)
Definition: expr.c:15041
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphPrintDot(SCIP_EXPRGRAPH *exprgraph, SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char **varnames)
Definition: expr.c:15791
SCIP_EXPORT SCIP_RETCODE SCIPexprEstimateUser(SCIP_EXPR *expr, SCIP_Real infinity, SCIP_Real *argvals, SCIP_INTERVAL *argbounds, SCIP_Bool overestimate, SCIP_Real *coeffs, SCIP_Real *constant, SCIP_Bool *success)
Definition: expr.c:8109
#define SCIP_DECL_EXPRGRAPHVARREMOVE(x)
Definition: type_expr.h:193
SCIP_EXPORT void SCIPexprMonomialPower(SCIP_EXPRDATA_MONOMIAL *monomial, int exponent)
Definition: expr.c:6928
enum SCIP_ExprCurv SCIP_EXPRCURV
Definition: type_expr.h:95
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphNodePolynomialAddMonomials(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE *node, int nmonomials, SCIP_EXPRDATA_MONOMIAL **monomials, SCIP_Bool copymonomials)
Definition: expr.c:13535
SCIP_EXPORT SCIP_Real * SCIPexprGetLinearCoefs(SCIP_EXPR *expr)
Definition: expr.c:5791
SCIP_EXPORT SCIP_RETCODE SCIPexprCreateUser(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, int nchildren, SCIP_EXPR **children, SCIP_USEREXPRDATA *data, SCIP_EXPRINTCAPABILITY evalcapability, SCIP_DECL_USEREXPREVAL((*eval)), SCIP_DECL_USEREXPRINTEVAL((*inteval)), SCIP_DECL_USEREXPRCURV((*curv)), SCIP_DECL_USEREXPRPROP((*prop)), SCIP_DECL_USEREXPRESTIMATE((*estimate)), SCIP_DECL_USEREXPRCOPYDATA((*copydata)), SCIP_DECL_USEREXPRFREEDATA((*freedata)), SCIP_DECL_USEREXPRPRINT((*print)))
Definition: expr.c:7155
SCIP_EXPORT SCIP_Bool SCIPexprgraphHasNodeNonlinearAncestor(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:14671
SCIP_EXPORT void ** SCIPexprgraphGetVars(SCIP_EXPRGRAPH *exprgraph)
Definition: expr.c:14977
SCIP_EXPORT SCIP_RETCODE SCIPexprtreeCheckCurvature(SCIP_EXPRTREE *tree, SCIP_Real infinity, SCIP_INTERVAL *varbounds, SCIP_EXPRCURV *curv, SCIP_INTERVAL *bounds)
Definition: expr.c:9012
SCIP_EXPORT SCIP_EXPRDATA_MONOMIAL ** SCIPexprGetMonomials(SCIP_EXPR *expr)
Definition: expr.c:5866
SCIP_EXPORT void SCIPexprtreeSetParamVal(SCIP_EXPRTREE *tree, int paramidx, SCIP_Real paramval)
Definition: expr.c:8644
SCIP_EXPORT SCIP_EXPRCURV SCIPexprcurvAdd(SCIP_EXPRCURV curv1, SCIP_EXPRCURV curv2)
Definition: expr.c:206
type definitions for expressions and expression trees
SCIP_EXPORT int SCIPexprgraphGetDepth(SCIP_EXPRGRAPH *exprgraph)
Definition: expr.c:14937
public methods for message output
SCIP_EXPORT SCIP_Bool SCIPexprAreEqual(SCIP_EXPR *expr1, SCIP_EXPR *expr2, SCIP_Real eps)
Definition: expr.c:7582
SCIP_EXPORT SCIP_RETCODE SCIPexprAddToLinear(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, int nchildren, SCIP_Real *coefs, SCIP_EXPR **children, SCIP_Real constant)
Definition: expr.c:6541
SCIP_EXPORT SCIP_Real * SCIPexprtreeGetParamVals(SCIP_EXPRTREE *tree)
Definition: expr.c:8634
#define SCIP_DECL_USEREXPRCOPYDATA(x)
Definition: type_expr.h:293
SCIP_EXPORT SCIP_RETCODE SCIPexprEvalShallow(SCIP_EXPR *expr, SCIP_Real *argvals, SCIP_Real *varvals, SCIP_Real *param, SCIP_Real *val)
Definition: expr.c:7849
#define SCIP_Real
Definition: def.h:163
SCIP_EXPORT SCIP_RETCODE SCIPexprtreeCopy(BMS_BLKMEM *blkmem, SCIP_EXPRTREE **targettree, SCIP_EXPRTREE *sourcetree)
Definition: expr.c:8814
SCIP_EXPORT SCIP_INTERVAL * SCIPexprgraphGetVarsBounds(SCIP_EXPRGRAPH *exprgraph)
Definition: expr.c:15101
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphCreate(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPH **exprgraph, int varssizeinit, int depthinit, SCIP_DECL_EXPRGRAPHVARADDED((*exprgraphvaradded)), SCIP_DECL_EXPRGRAPHVARREMOVE((*exprgraphvarremove)), SCIP_DECL_EXPRGRAPHVARCHGIDX((*exprgraphvarchgidx)), void *userdata)
Definition: expr.c:15109
SCIP_EXPORT SCIP_Bool SCIPexprgraphFindConstNode(SCIP_EXPRGRAPH *exprgraph, SCIP_Real constant, SCIP_EXPRGRAPHNODE **constnode)
Definition: expr.c:15743
SCIP_EXPORT int SCIPexprgraphGetNodeNChildren(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:12991
SCIP_EXPORT SCIP_Real * SCIPexprGetQuadLinearCoefs(SCIP_EXPR *expr)
Definition: expr.c:5842
SCIP_EXPORT SCIP_EXPR * SCIPexprtreeGetRoot(SCIP_EXPRTREE *tree)
Definition: expr.c:8604
SCIP_EXPORT SCIP_EXPRGRAPHNODE *** SCIPexprgraphGetNodes(SCIP_EXPRGRAPH *exprgraph)
Definition: expr.c:14957
BMS_BLKMEM * blkmem
Definition: nlpioracle.c:60
SCIP_EXPORT void SCIPexprtreePrint(SCIP_EXPRTREE *tree, SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char **varnames, const char **paramnames)
Definition: expr.c:8758
SCIP_EXPORT SCIP_Real SCIPexprgraphGetNodeRealPowerExponent(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13098
SCIP_EXPORT void SCIPexprtreeSetInterpreterData(SCIP_EXPRTREE *tree, SCIP_EXPRINTDATA *interpreterdata)
Definition: expr.c:8669
SCIP_EXPORT SCIP_Bool SCIPexprFindMonomialFactor(SCIP_EXPRDATA_MONOMIAL *monomial, int childidx, int *pos)
Definition: expr.c:7138
SCIP_EXPORT SCIP_Real SCIPexprGetLinearConstant(SCIP_EXPR *expr)
Definition: expr.c:5804
SCIP_EXPORT SCIP_RETCODE SCIPexprCreateLinear(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, int nchildren, SCIP_EXPR **children, SCIP_Real *coefs, SCIP_Real constant)
Definition: expr.c:6504
common defines and data types used in all packages of SCIP
SCIP_EXPORT SCIP_RETCODE SCIPexprAdd(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, SCIP_Real coef1, SCIP_EXPR *term1, SCIP_Real coef2, SCIP_EXPR *term2, SCIP_Real constant)
Definition: expr.c:6248
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:429
SCIP_EXPORT int SCIPexprgraphGetNodeOperatorIndex(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13061
SCIP_EXPORT int SCIPexprGetNMonomials(SCIP_EXPR *expr)
Definition: expr.c:5878
struct SCIP_ExprIntData SCIP_EXPRINTDATA
SCIP_EXPORT int SCIPexprgraphGetNodeIntPowerExponent(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13109
#define SCIP_DECL_USEREXPRFREEDATA(x)
Definition: type_expr.h:301
SCIP_EXPORT SCIP_USEREXPRDATA * SCIPexprgraphGetNodeUserData(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13321
SCIP_EXPORT SCIP_EXPRGRAPHNODE ** SCIPexprgraphGetNodeChildren(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13001
SCIP_EXPORT SCIP_RETCODE SCIPexprEvalInt(SCIP_EXPR *expr, SCIP_Real infinity, SCIP_INTERVAL *varvals, SCIP_Real *param, SCIP_INTERVAL *val)
Definition: expr.c:7929
SCIP_EXPORT SCIP_RETCODE SCIPexprgraphGetTree(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *rootnode, SCIP_EXPRTREE **exprtree)
Definition: expr.c:16254
SCIP_EXPORT SCIP_RETCODE SCIPexprEvalIntUser(SCIP_EXPR *expr, SCIP_Real infinity, SCIP_INTERVAL *argvals, SCIP_INTERVAL *val, SCIP_INTERVAL *gradient, SCIP_INTERVAL *hessian)
Definition: expr.c:7994
SCIP_EXPORT SCIP_Real * SCIPexprgraphGetNodeQuadraticLinearCoefs(SCIP_EXPRGRAPHNODE *node)
Definition: expr.c:13166
#define SCIP_DECL_EXPRGRAPHVARCHGIDX(x)
Definition: type_expr.h:205
SCIP_EXPORT void SCIPexprgraphPropagateNodeBounds(SCIP_EXPRGRAPH *exprgraph, SCIP_Real infinity, SCIP_Real minstrength, SCIP_Bool *cutoff)
Definition: expr.c:15915
SCIP_EXPORT SCIP_RETCODE SCIPexprtreeAddExpr(SCIP_EXPRTREE *tree, SCIP_EXPR *expr, SCIP_Bool copyexpr)
Definition: expr.c:8983
SCIP_EXPORT int SCIPexprGetOpIndex(SCIP_EXPR *expr)
Definition: expr.c:5725
memory allocation routines