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-2014 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 email to scip@zib.de. */
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 */
46 extern
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 */
57 extern
59  SCIP_EXPRCURV curvature /**< curvature of function */
60  );
61 
62 /** gives curvature for a functions with given curvature multiplied by a constant factor */
63 extern
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 */
70 extern
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 */
78 extern
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 */
88 extern
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 */
99 extern
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  */
107 extern
109  SCIP_EXPROP op /**< expression operand */
110  );
111 
112 /**@} */
113 
114 /**@name Expression methods */
115 /**@{ */
116 
117 /** gives operator of expression */
118 extern
120  SCIP_EXPR* expr /**< expression */
121  );
122 
123 /** gives number of children of an expression */
124 extern
126  SCIP_EXPR* expr /**< expression */
127  );
128 
129 /** gives pointer to array with children of an expression */
130 extern
132  SCIP_EXPR* expr /**< expression */
133  );
134 
135 /** gives index belonging to a SCIP_EXPR_VARIDX or SCIP_EXPR_PARAM operand */
136 extern
138  SCIP_EXPR* expr /**< expression */
139  );
140 
141 /** gives real belonging to a SCIP_EXPR_CONST operand */
142 extern
144  SCIP_EXPR* expr /**< expression */
145  );
146 
147 /** gives void* belonging to a complex operand */
148 extern
149 void* SCIPexprGetOpData(
150  SCIP_EXPR* expr /**< expression */
151  );
152 
153 /** gives exponent belonging to a SCIP_EXPR_REALPOWER expression */
154 extern
156  SCIP_EXPR* expr /**< expression */
157  );
158 
159 /** gives exponent belonging to a SCIP_EXPR_INTPOWER expression */
160 extern
162  SCIP_EXPR* expr /**< expression */
163  );
164 
165 /** gives exponent belonging to a SCIP_EXPR_SIGNPOWER expression */
166 extern
168  SCIP_EXPR* expr /**< expression */
169  );
170 
171 /** gives linear coefficients belonging to a SCIP_EXPR_LINEAR expression */
172 extern
174  SCIP_EXPR* expr /**< expression */
175  );
176 
177 /** gives constant belonging to a SCIP_EXPR_LINEAR expression */
178 extern
180  SCIP_EXPR* expr /**< expression */
181  );
182 
183 /** gives quadratic elements belonging to a SCIP_EXPR_QUADRATIC expression */
184 extern
186  SCIP_EXPR* expr /**< quadratic expression */
187  );
188 
189 /** gives constant belonging to a SCIP_EXPR_QUADRATIC expression */
190 extern
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 */
197 extern
199  SCIP_EXPR* expr /**< quadratic expression */
200  );
201 
202 /** gives number of quadratic elements belonging to a SCIP_EXPR_QUADRATIC expression */
203 extern
205  SCIP_EXPR* expr /**< quadratic expression */
206  );
207 
208 /** gives the monomials belonging to a SCIP_EXPR_POLYNOMIAL expression */
209 extern
211  SCIP_EXPR* expr /**< expression */
212  );
213 
214 /** gives the number of monomials belonging to a SCIP_EXPR_POLYNOMIAL expression */
215 extern
217  SCIP_EXPR* expr /**< expression */
218  );
219 
220 /** gives the constant belonging to a SCIP_EXPR_POLYNOMIAL expression */
221 extern
223  SCIP_EXPR* expr /**< expression */
224  );
225 
226 /** gets coefficient of a monomial */
227 extern
229  SCIP_EXPRDATA_MONOMIAL* monomial /**< monomial */
230  );
231 
232 /** gets number of factors of a monomial */
233 extern
235  SCIP_EXPRDATA_MONOMIAL* monomial /**< monomial */
236  );
237 
238 /** gets indices of children corresponding to factors of a monomial */
239 extern
241  SCIP_EXPRDATA_MONOMIAL* monomial /**< monomial */
242  );
243 
244 /** gets exponents in factors of a monomial */
245 extern
247  SCIP_EXPRDATA_MONOMIAL* monomial /**< monomial */
248  );
249 
250 #ifdef NDEBUG
251 
252 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
253  * speed up the algorithms.
254  */
255 
256 #define SCIPexprGetOperator(expr) (expr)->op
257 #define SCIPexprGetNChildren(expr) (expr)->nchildren
258 #define SCIPexprGetChildren(expr) (expr)->children
259 #define SCIPexprGetOpIndex(expr) (expr)->data.intval
260 #define SCIPexprGetOpReal(expr) (expr)->data.dbl
261 #define SCIPexprGetOpData(expr) (expr)->data.data
262 #define SCIPexprGetRealPowerExponent(expr) (expr)->data.dbl
263 #define SCIPexprGetIntPowerExponent(expr) (expr)->data.intval
264 #define SCIPexprGetSignPowerExponent(expr) (expr)->data.dbl
265 #define SCIPexprGetLinearCoefs(expr) ((SCIP_Real*)(expr)->data.data)
266 #define SCIPexprGetLinearConstant(expr) (((SCIP_Real*)(expr)->data.data)[(expr)->nchildren])
267 #define SCIPexprGetQuadElements(expr) ((SCIP_EXPRDATA_QUADRATIC*)(expr)->data.data)->quadelems
268 #define SCIPexprGetQuadConstant(expr) ((SCIP_EXPRDATA_QUADRATIC*)(expr)->data.data)->constant
269 #define SCIPexprGetQuadLinearCoefs(expr) ((SCIP_EXPRDATA_QUADRATIC*)(expr)->data.data)->lincoefs
270 #define SCIPexprGetNQuadElements(expr) ((SCIP_EXPRDATA_QUADRATIC*)(expr)->data.data)->nquadelems
271 #define SCIPexprGetMonomials(expr) ((SCIP_EXPRDATA_POLYNOMIAL*)(expr)->data.data)->monomials
272 #define SCIPexprGetNMonomials(expr) ((SCIP_EXPRDATA_POLYNOMIAL*)(expr)->data.data)->nmonomials
273 #define SCIPexprGetPolynomialConstant(expr) ((SCIP_EXPRDATA_POLYNOMIAL*)(expr)->data.data)->constant
274 #define SCIPexprGetMonomialCoef(monomial) (monomial)->coef
275 #define SCIPexprGetMonomialNFactors(monomial) (monomial)->nfactors
276 #define SCIPexprGetMonomialChildIndices(monomial) (monomial)->childidxs
277 #define SCIPexprGetMonomialExponents(monomial) (monomial)->exponents
278 
279 #endif
280 
281 /** creates a simple expression */
282 extern
284  BMS_BLKMEM* blkmem, /**< block memory data structure */
285  SCIP_EXPR** expr, /**< pointer to buffer for expression address */
286  SCIP_EXPROP op, /**< operand of expression */
287  ... /**< arguments of operand */
288  );
289 
290 /** copies an expression including its children */
291 extern
293  BMS_BLKMEM* blkmem, /**< block memory data structure */
294  SCIP_EXPR** targetexpr, /**< buffer to store pointer to copied expression */
295  SCIP_EXPR* sourceexpr /**< expression to copy */
296  );
297 
298 /** frees an expression including its children */
299 extern
300 void SCIPexprFreeDeep(
301  BMS_BLKMEM* blkmem, /**< block memory data structure */
302  SCIP_EXPR** expr /**< pointer to expression to free */
303  );
304 
305 /** frees an expression but not its children */
306 extern
308  BMS_BLKMEM* blkmem, /**< block memory data structure */
309  SCIP_EXPR** expr /**< pointer to expression to free */
310  );
311 
312 /** creates an expression from the addition of two given expression, with coefficients, and a constant
313  *
314  * the given expressions may be modified or freed, otherwise it will be used a child expression
315  * favors creation and maintaining of SCIP_EXPR_LINEAR over SCIP_EXPR_PLUS or SCIP_EXPR_SUM
316  */
317 extern
319  BMS_BLKMEM* blkmem, /**< block memory data structure */
320  SCIP_EXPR** expr, /**< pointer to store pointer to created expression */
321  SCIP_Real coef1, /**< coefficient of first term */
322  SCIP_EXPR* term1, /**< expression of first term, or NULL */
323  SCIP_Real coef2, /**< coefficient of second term */
324  SCIP_EXPR* term2, /**< expression of second term, or NULL */
325  SCIP_Real constant /**< constant term to add */
326  );
327 
328 /** creates an expression from the multiplication of an expression with a constant
329  *
330  * the given expressions may be modified or freed, otherwise it will be used a child expression
331  * favors creation of SCIP_EXPR_LINEAR over SCIP_EXPR_MUP or SCIP_EXPR_PROD
332  */
333 extern
335  BMS_BLKMEM* blkmem, /**< block memory data structure */
336  SCIP_EXPR** expr, /**< buffer to store pointer to created expression */
337  SCIP_EXPR* term, /**< term to multiply by factor */
338  SCIP_Real factor /**< factor */
339  );
340 
341 /** creates a SCIP_EXPR_LINEAR expression that is (affine) linear in its children: constant + sum_i coef_i child_i */
342 extern
344  BMS_BLKMEM* blkmem, /**< block memory data structure */
345  SCIP_EXPR** expr, /**< pointer to buffer for expression address */
346  int nchildren, /**< number of children */
347  SCIP_EXPR** children, /**< children of expression */
348  SCIP_Real* coefs, /**< coefficients of children */
349  SCIP_Real constant /**< constant part */
350  );
351 
352 /** adds new terms to a linear expression */
353 extern
355  BMS_BLKMEM* blkmem, /**< block memory */
356  SCIP_EXPR* expr, /**< linear expression */
357  int nchildren, /**< number of children to add */
358  SCIP_Real* coefs, /**< coefficients of additional children */
359  SCIP_EXPR** children, /**< additional children expressions */
360  SCIP_Real constant /**< constant to add */
361  );
362 
363 /** creates a SCIP_EXPR_QUADRATIC expression: constant + sum_i coef_i child_i + sum_i coef_i child1_i child2_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 constant, /**< constant */
370  SCIP_Real* lincoefs, /**< linear coefficients of children, or NULL if all 0.0 */
371  int nquadelems, /**< number of quadratic elements */
372  SCIP_QUADELEM* quadelems /**< quadratic elements specifying coefficients and child indices */
373  );
374 
375 /** ensures that quadratic elements of a quadratic expression are sorted */
376 extern
378  SCIP_EXPR* expr /**< quadratic expression */
379  );
380 
381 /** creates a SCIP_EXPR_POLYNOMIAL expression from an array of monomials: constant + sum_i monomial_i */
382 extern
384  BMS_BLKMEM* blkmem, /**< block memory data structure */
385  SCIP_EXPR** expr, /**< pointer to buffer for expression address */
386  int nchildren, /**< number of children */
387  SCIP_EXPR** children, /**< children of expression */
388  int nmonomials, /**< number of monomials */
389  SCIP_EXPRDATA_MONOMIAL** monomials, /**< monomials */
390  SCIP_Real constant, /**< constant part */
391  SCIP_Bool copymonomials /**< should monomials by copied or ownership be assumed? */
392  );
393 
394 /** adds an array of monomials to a SCIP_EXPR_POLYNOMIAL expression */
395 extern
397  BMS_BLKMEM* blkmem, /**< block memory of expression */
398  SCIP_EXPR* expr, /**< expression */
399  int nmonomials, /**< number of monomials to add */
400  SCIP_EXPRDATA_MONOMIAL** monomials, /**< the monomials to add */
401  SCIP_Bool copymonomials /**< should monomials by copied or ownership be assumed? */
402  );
403 
404 /** changes the constant in a SCIP_EXPR_POLYNOMIAL expression */
405 extern
407  SCIP_EXPR* expr, /**< expression */
408  SCIP_Real constant /**< new value for constant */
409  );
410 
411 /** multiplies each summand of a polynomial by a given constant */
412 extern
414  BMS_BLKMEM* blkmem, /**< block memory */
415  SCIP_EXPR* expr, /**< polynomial expression */
416  SCIP_Real factor /**< constant factor */
417  );
418 
419 /** multiplies each summand of a polynomial by a given monomial */
420 extern
422  BMS_BLKMEM* blkmem, /**< block memory */
423  SCIP_EXPR* expr, /**< polynomial expression */
424  SCIP_EXPRDATA_MONOMIAL* factor, /**< monomial factor */
425  int* childmap /**< map children in factor to children in expr, or NULL for 1:1 */
426  );
427 
428 /** multiplies this polynomial by a polynomial
429  * factor needs to be different from expr */
430 extern
432  BMS_BLKMEM* blkmem, /**< block memory */
433  SCIP_EXPR* expr, /**< polynomial expression */
434  SCIP_EXPR* factor, /**< polynomial factor */
435  int* childmap /**< map children in factor to children in expr, or NULL for 1:1 */
436  );
437 
438 /** takes a power of the polynomial
439  * exponent need to be an integer
440  * polynomial need to be a monomial, if exponent is negative
441  */
442 extern
444  BMS_BLKMEM* blkmem, /**< block memory */
445  SCIP_EXPR* expr, /**< polynomial expression */
446  int exponent /**< exponent of power operation */
447  );
448 
449 /** merges monomials in a polynomial expression that differ only in coefficient into a single monomial
450  * eliminates monomials with coefficient between -eps and eps
451  */
452 extern
454  BMS_BLKMEM* blkmem, /**< block memory */
455  SCIP_EXPR* expr, /**< polynomial expression */
456  SCIP_Real eps, /**< threshold under which numbers are treat as zero */
457  SCIP_Bool mergefactors /**< whether to merge factors in monomials too */
458  );
459 
460 /** creates a monomial */
461 extern
463  BMS_BLKMEM* blkmem, /**< block memory */
464  SCIP_EXPRDATA_MONOMIAL** monomial, /**< buffer where to store pointer to new monomial */
465  SCIP_Real coef, /**< coefficient of monomial */
466  int nfactors, /**< number of factors in monomial */
467  int* childidxs, /**< indices of children corresponding to factors, or NULL if identity */
468  SCIP_Real* exponents /**< exponent in each factor, or NULL if all 1.0 */
469  );
470 
471 /** frees a monomial */
472 extern
474  BMS_BLKMEM* blkmem, /**< block memory */
475  SCIP_EXPRDATA_MONOMIAL** monomial /**< pointer to monomial that should be freed */
476  );
477 
478 /** ensures that factors in a monomial are sorted */
479 extern
481  SCIP_EXPRDATA_MONOMIAL* monomial /**< monomial */
482  );
483 
484 /** finds a factor corresponding to a given child index in a monomial
485  * note that if the factors have not been merged, the position of some factor corresponding to a given child is given
486  * returns TRUE if a factor is found, FALSE if not
487  */
488 extern
490  SCIP_EXPRDATA_MONOMIAL* monomial, /**< monomial */
491  int childidx, /**< index of the child which factor to search for */
492  int* pos /**< buffer to store position of factor */
493  );
494 
495 /** checks if two monomials are equal */
496 extern
498  SCIP_EXPRDATA_MONOMIAL* monomial1, /**< first monomial */
499  SCIP_EXPRDATA_MONOMIAL* monomial2, /**< second monomial */
500  SCIP_Real eps /**< threshold under which numbers are treated as 0.0 */
501  );
502 
503 /** adds factors to a monomial */
504 extern
506  BMS_BLKMEM* blkmem, /**< block memory */
507  SCIP_EXPRDATA_MONOMIAL* monomial, /**< monomial */
508  int nfactors, /**< number of factors to add */
509  int* childidxs, /**< indices of children corresponding to factors */
510  SCIP_Real* exponents /**< exponent in each factor */
511  );
512 
513 /** changes coefficient of monomial */
514 extern
516  SCIP_EXPRDATA_MONOMIAL* monomial, /**< monomial */
517  SCIP_Real newcoef /**< new coefficient */
518  );
519 
520 /** multiplies a monomial with a monomial */
521 extern
523  BMS_BLKMEM* blkmem, /**< block memory */
524  SCIP_EXPRDATA_MONOMIAL* monomial, /**< monomial */
525  SCIP_EXPRDATA_MONOMIAL* factor, /**< factor monomial */
526  int* childmap /**< map to apply to children in factor, or NULL for 1:1 */
527  );
528 
529 /** replaces the monomial by a power of the monomial
530  * allows only integers as exponent
531  */
532 extern
534  SCIP_EXPRDATA_MONOMIAL* monomial, /**< monomial */
535  int exponent /**< integer exponent of power operation */
536  );
537 
538 /** merges factors that correspond to the same child by adding exponents
539  * eliminates factors with exponent between -eps and eps
540  */
541 extern
543  SCIP_EXPRDATA_MONOMIAL* monomial, /**< monomial */
544  SCIP_Real eps /**< threshold under which numbers are treated as 0.0 */
545  );
546 
547 /** ensures that monomials of a polynomial are sorted */
548 extern
550  SCIP_EXPR* expr /**< polynomial expression */
551  );
552 
553 /** indicates whether the expression contains a SCIP_EXPR_PARAM */
554 extern
556  SCIP_EXPR* expr /**< expression */
557  );
558 
559 /** gets maximal degree of expression, or SCIP_EXPR_DEGREEINFINITY if not a polynomial */
560 extern
562  SCIP_EXPR* expr, /**< expression */
563  int* maxdegree /**< buffer to store maximal degree */
564  );
565 
566 /** counts usage of variables in expression */
567 extern
569  SCIP_EXPR* expr, /**< expression to update */
570  int* varsusage /**< array with counters of variable usage */
571  );
572 
573 /** compares whether two expressions are the same
574  * inconclusive, i.e., may give FALSE even if expressions are equivalent (x*y != y*x)
575  */
576 extern
578  SCIP_EXPR* expr1, /**< first expression */
579  SCIP_EXPR* expr2, /**< second expression */
580  SCIP_Real eps /**< threshold under which numbers are assumed to be zero */
581  );
582 
583 /** aims at simplifying an expression and splitting of a linear expression
584  * if linear variables are split off, expression interpreter data, if stored in the tree, is freed
585  */
586 extern
588  BMS_BLKMEM* blkmem, /**< block memory data structure */
589  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
590  SCIP_EXPR* expr, /**< expression */
591  SCIP_Real eps, /**< threshold, under which positive values are treat as 0 */
592  int maxexpansionexponent,/**< maximal exponent for which we still expand non-monomial polynomials */
593  int nvars, /**< number of variables in expression */
594  int* nlinvars, /**< buffer to store number of linear variables in linear part, or NULL if linear part should not be separated */
595  int* linidxs, /**< array to store indices of variables in expression tree which belong to linear part, or NULL */
596  SCIP_Real* lincoefs /**< array to store coefficients of linear part, or NULL */
597  );
598 
599 /** evaluates an expression w.r.t. a point */
600 extern
602  SCIP_EXPR* expr, /**< expression */
603  SCIP_Real* varvals, /**< values for variables, can be NULL if the expression is constant */
604  SCIP_Real* param, /**< values for parameters, can be NULL if the expression is not parameterized */
605  SCIP_Real* val /**< buffer to store value */
606  );
607 
608 /** evaluates an expression w.r.t. an interval */
609 extern
611  SCIP_EXPR* expr, /**< expression */
612  SCIP_Real infinity, /**< value to use for infinity */
613  SCIP_INTERVAL* varvals, /**< interval values for variables, can be NULL if the expression is constant */
614  SCIP_Real* param, /**< values for parameters, can be NULL if the expression is not parameterized */
615  SCIP_INTERVAL* val /**< buffer to store value */
616  );
617 
618 /** tries to determine the curvature type of an expression w.r.t. given variable domains */
619 extern
621  SCIP_EXPR* expr, /**< expression to check */
622  SCIP_Real infinity, /**< value to use for infinity */
623  SCIP_INTERVAL* varbounds, /**< domains of variables */
624  SCIP_Real* param, /**< values for parameters, can be NULL if the expression is not parameterized */
625  SCIP_EXPRCURV* curv, /**< buffer to store curvature of expression */
626  SCIP_INTERVAL* bounds /**< buffer to store bounds on expression */
627  );
628 
629 /** substitutes variables (SCIP_EXPR_VARIDX) by expressions
630  * Note that only the children of the given expr are checked!
631  * A variable with index i is replaced by a copy of substexprs[i], if that latter is not NULL
632  * if substexprs[i] == NULL, then the variable expression i is not touched
633  */
634 extern
636  BMS_BLKMEM* blkmem, /**< block memory data structure */
637  SCIP_EXPR* expr, /**< expression, which of the children may be replaced */
638  SCIP_EXPR** substexprs /**< array of substitute expressions; single entries can be NULL */
639  );
640 
641 /** updates variable indices in expression tree */
642 extern
644  SCIP_EXPR* expr, /**< expression to update */
645  int* newindices /**< new indices of variables */
646  );
647 
648 /** updates parameter indices in expression tree */
649 extern
651  SCIP_EXPR* expr, /**< expression to update */
652  int* newindices /**< new indices of variables */
653  );
654 
655 /** prints an expression */
656 extern
657 void SCIPexprPrint(
658  SCIP_EXPR* expr, /**< expression */
659  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
660  FILE* file, /**< file for printing, or NULL for stdout */
661  const char** varnames, /**< names of variables, or NULL for default names */
662  const char** paramnames, /**< names of parameters, or NULL for default names */
663  SCIP_Real* paramvals /**< values of parameters, or NULL for not printing */
664  );
665 
666 /** parses an expression from a string */
667 extern
669  BMS_BLKMEM* blkmem, /**< block memory data structure */
670  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
671  SCIP_EXPR** expr, /**< buffer to store pointer to created expression */
672  const char* str, /**< pointer to the string to be parsed */
673  const char* lastchar, /**< pointer to the last char of str that should be parsed */
674  int* nvars, /**< buffer to store number of variables */
675  int* varnames /**< buffer to store variable names, prefixed by index (as int) */
676  );
677 
678 /**@} */
679 
680 /**@name Expression tree methods */
681 /**@{ */
682 
683 /** returns root expression of an expression tree */
684 extern
686  SCIP_EXPRTREE* tree /**< expression tree */
687  );
688 
689 /** returns number of variables in expression tree */
690 extern
692  SCIP_EXPRTREE* tree /**< expression tree */
693  );
694 
695 /** returns number of parameters in expression tree */
696 extern
698  SCIP_EXPRTREE* tree /**< expression tree */
699  );
700 
701 /** returns values of parameters or NULL if none */
702 extern
704  SCIP_EXPRTREE* tree /**< expression tree */
705  );
706 
707 /** sets value of a single parameter in expression tree */
708 extern
710  SCIP_EXPRTREE* tree, /**< expression tree */
711  int paramidx, /**< index of parameter */
712  SCIP_Real paramval /**< new value of parameter */
713  );
714 
715 /** gets data of expression tree interpreter, or NULL if not set */
716 extern
718  SCIP_EXPRTREE* tree /**< expression tree */
719  );
720 
721 /** sets data of expression tree interpreter */
722 extern
724  SCIP_EXPRTREE* tree, /**< expression tree */
725  SCIP_EXPRINTDATA* interpreterdata /**< expression interpreter data */
726  );
727 
728 /** frees data of expression tree interpreter, if any */
729 extern
731  SCIP_EXPRTREE* tree /**< expression tree */
732  );
733 
734 /** indicates whether there are parameterized constants (SCIP_EXPR_PARAM) in expression tree */
735 extern
737  SCIP_EXPRTREE* tree /**< expression tree */
738  );
739 
740 /** Gives maximal degree of expression in expression tree.
741  * If constant expression, gives 0,
742  * if linear expression, gives 1,
743  * if polynomial expression, gives its maximal degree,
744  * otherwise (nonpolynomial nonconstant expressions) gives at least SCIP_EXPR_DEGREEINFINITY.
745  */
746 extern
748  SCIP_EXPRTREE* tree, /**< expression tree */
749  int* maxdegree /**< buffer to store maximal degree */
750  );
751 
752 /** evaluates an expression tree w.r.t. a point */
753 extern
755  SCIP_EXPRTREE* tree, /**< expression tree */
756  SCIP_Real* varvals, /**< values for variables */
757  SCIP_Real* val /**< buffer to store expression tree value */
758  );
759 
760 /** evaluates an expression tree w.r.t. an interval */
761 extern
763  SCIP_EXPRTREE* tree, /**< expression tree */
764  SCIP_Real infinity, /**< value for infinity */
765  SCIP_INTERVAL* varvals, /**< intervals for variables */
766  SCIP_INTERVAL* val /**< buffer to store expression tree value */
767  );
768 
769 /** prints an expression tree */
770 extern
771 void SCIPexprtreePrint(
772  SCIP_EXPRTREE* tree, /**< expression tree */
773  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
774  FILE* file, /**< file for printing, or NULL for stdout */
775  const char** varnames, /**< names of variables, or NULL for default names */
776  const char** paramnames /**< names of parameters, or NULL for default names */
777  );
778 
779 #ifdef NDEBUG
780 
781 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
782  * speed up the algorithms.
783  */
784 
785 #define SCIPexprtreeGetRoot(tree) (tree)->root
786 #define SCIPexprtreeGetNVars(tree) (tree)->nvars
787 #define SCIPexprtreeGetNParams(tree) (tree)->nparams
788 #define SCIPexprtreeGetParamVals(tree) (tree)->params
789 #define SCIPexprtreeSetParamVal(tree, paramidx, paramval) do { (tree)->params[(paramidx)] = paramval; } while (FALSE)
790 #define SCIPexprtreeGetInterpreterData(tree) (tree)->interpreterdata
791 #define SCIPexprtreeSetInterpreterData(tree, newinterpreterdata) do { (tree)->interpreterdata = newinterpreterdata; } while (FALSE)
792 #define SCIPexprtreeFreeInterpreterData(tree) ((tree)->interpreterdata != NULL ? SCIPexprintFreeData(&(tree)->interpreterdata) : SCIP_OKAY)
793 #define SCIPexprtreeHasParam(tree) SCIPexprHasParam((tree)->root)
794 #define SCIPexprtreeGetMaxDegree(tree, maxdegree) SCIPexprGetMaxDegree((tree)->root, maxdegree)
795 #define SCIPexprtreeEval(tree, varvals, val) SCIPexprEval((tree)->root, varvals, (tree)->params, val)
796 #define SCIPexprtreeEvalInt(tree, infinity, varvals, val) SCIPexprEvalInt((tree)->root, infinity, varvals, (tree)->params, val)
797 #define SCIPexprtreePrint(tree, messagehdlr, file, varnames, paramnames) SCIPexprPrint((tree)->root, messagehdlr, file, varnames, paramnames, (tree)->params)
798 
799 #endif
800 
801 /** creates an expression tree */
802 extern
804  BMS_BLKMEM* blkmem, /**< block memory data structure */
805  SCIP_EXPRTREE** tree, /**< buffer to store address of created expression tree */
806  SCIP_EXPR* root, /**< pointer to root expression, not copied deep !, can be NULL */
807  int nvars, /**< number of variables in variable mapping */
808  int nparams, /**< number of parameters in expression */
809  SCIP_Real* params /**< values for parameters, or NULL (if NULL but nparams > 0, then params is initialized with zeros) */
810  );
811 
812 /** copies an expression tree */
813 extern
815  BMS_BLKMEM* blkmem, /**< block memory that should be used in new expression tree */
816  SCIP_EXPRTREE** targettree, /**< buffer to store address of copied expression tree */
817  SCIP_EXPRTREE* sourcetree /**< expression tree to copy */
818  );
819 
820 /** frees an expression tree */
821 extern
823  SCIP_EXPRTREE** tree /**< pointer to expression tree that is freed */
824  );
825 
826 /** sets number and values of all parameters in expression tree */
827 extern
829  SCIP_EXPRTREE* tree, /**< expression tree */
830  int nparams, /**< number of parameters */
831  SCIP_Real* paramvals /**< values of parameters, can be NULL if nparams == 0 */
832  );
833 
834 /** gives the number of usages for each variable in the expression tree */
835 extern
837  SCIP_EXPRTREE* tree, /**< expression tree */
838  int* varsusage /**< array where to store for each variable how often it is used in the tree */
839  );
840 
841 /** aims at simplifying an expression and splitting of a linear expression
842  * if linear variables are split off, expression interpreter data, if stored in the tree, is freed
843  */
844 extern
846  SCIP_EXPRTREE* tree, /**< expression tree */
847  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
848  SCIP_Real eps, /**< threshold, under which positive values are treat as 0 */
849  int maxexpansionexponent,/**< maximal exponent for which we still expand non-monomial polynomials */
850  int* nlinvars, /**< buffer to store number of linear variables in linear part, or NULL if linear part should not be separated */
851  int* linidxs, /**< array to store indices of variables in expression tree which belong to linear part, or NULL */
852  SCIP_Real* lincoefs /**< array to store coefficients of linear part, or NULL */
853  );
854 
855 /** adds an expression to the root expression of the tree
856  * the root is replaced with an SCIP_EXPR_PLUS expression which has the previous root and the given expression as children
857  */
858 extern
860  SCIP_EXPRTREE* tree, /**< expression tree */
861  SCIP_EXPR* expr, /**< expression to add to tree */
862  SCIP_Bool copyexpr /**< whether expression should be copied */
863  );
864 
865 /** tries to determine the curvature type of an expression tree w.r.t. given variable domains */
866 extern
868  SCIP_EXPRTREE* tree, /**< expression tree */
869  SCIP_Real infinity, /**< value for infinity */
870  SCIP_INTERVAL* varbounds, /**< domains of variables */
871  SCIP_EXPRCURV* curv, /**< buffer to store curvature of expression */
872  SCIP_INTERVAL* bounds /**< buffer to store bounds on expression, or NULL if not needed */
873  );
874 
875 /** substitutes variables (SCIP_EXPR_VARIDX) in an expression tree by expressions
876  * A variable with index i is replaced by a copy of substexprs[i], if that latter is not NULL
877  * if substexprs[i] == NULL, then the variable expression i is not touched
878  */
879 extern
881  SCIP_EXPRTREE* tree, /**< expression tree */
882  SCIP_EXPR** substexprs /**< array of substitute expressions; single entries can be NULL */
883  );
884 
885 /**@} */
886 
887 /**@name Quadratic element methods */
888 /**@{ */
889 
890 /** sorts an array of quadratic elements
891  * The elements are sorted such that the first index is increasing and
892  * such that among elements with the same first index, the second index is increasing.
893  * For elements with same first and second index, the order is not defined.
894  */
895 extern
896 void SCIPquadelemSort(
897  SCIP_QUADELEM* quadelems, /**< array of quadratic elements */
898  int nquadelems /**< number of quadratic elements */
899  );
900 
901 /** Finds an index pair in a sorted array of quadratic elements.
902  * If (idx1,idx2) is found in quadelems, then returns TRUE and stores position of quadratic element in *pos.
903  * 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.
904  * Assumes that idx1 <= idx2.
905  */
906 extern
908  SCIP_QUADELEM* quadelems, /**< array of quadratic elements */
909  int idx1, /**< index of first variable in element to search for */
910  int idx2, /**< index of second variable in element to search for */
911  int nquadelems, /**< number of quadratic elements in array */
912  int* pos /**< buffer to store position of found quadratic element, or position where it would be inserted */
913  );
914 
915 /** Adds quadratic elements with same index and removes elements with coefficient 0.0.
916  * Assumes that elements have been sorted before.
917  */
918 extern
920  SCIP_QUADELEM* quadelems, /**< array of quadratic elements */
921  int nquadelems, /**< number of quadratic elements */
922  int* nquadelemsnew /**< pointer to store new (reduced) number of quadratic elements */
923  );
924 
925 /**@} */
926 
927 /**@name Expression graph node methods */
928 /**@{ */
929 
930 /** captures node, i.e., increases number of uses */
931 extern
933  SCIP_EXPRGRAPHNODE* node /**< expression graph node to capture */
934  );
935 
936 /** returns whether a node is currently enabled */
937 extern
939  SCIP_EXPRGRAPHNODE* node /**< expression graph node to enable */
940  );
941 
942 /** gets number of children of a node in an expression graph */
943 extern
945  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
946  );
947 
948 /** gets children of a node in an expression graph */
949 extern
951  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
952  );
953 
954 /** gets number of parents of a node in an expression graph */
955 extern
957  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
958  );
959 
960 /** gets parents of a node in an expression graph */
961 extern
963  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
964  );
965 
966 /** gets depth of node in expression graph */
967 extern
969  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
970  );
971 
972 /** gets position of node in expression graph at its depth level */
973 extern
975  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
976  );
977 
978 /** gets operator of a node in an expression graph */
979 extern
981  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
982  );
983 
984 /** gives index belonging to a SCIP_EXPR_VARIDX or SCIP_EXPR_PARAM operand */
985 extern
987  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
988  );
989 
990 /** gives real belonging to a SCIP_EXPR_CONST operand */
991 extern
993  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
994  );
995 
996 /** gives variable belonging to a SCIP_EXPR_VARIDX expression */
997 extern
999  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1000  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1001  );
1002 
1003 /** gives exponent belonging to a SCIP_EXPR_REALPOWER expression */
1004 extern
1006  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1007  );
1008 
1009 /** gives exponent belonging to a SCIP_EXPR_INTPOWER expression */
1010 extern
1012  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1013  );
1014 
1015 /** gives exponent belonging to a SCIP_EXPR_SIGNPOWER expression */
1016 extern
1018  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1019  );
1020 
1021 /** gives linear coefficients belonging to a SCIP_EXPR_LINEAR expression */
1022 extern
1024  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1025  );
1026 
1027 /** gives constant belonging to a SCIP_EXPR_LINEAR expression */
1028 extern
1030  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1031  );
1032 
1033 /** gives constant belonging to a SCIP_EXPR_QUADRATIC expression */
1034 extern
1036  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1037  );
1038 
1039 /** gives linear coefficients belonging to a SCIP_EXPR_QUADRATIC expression, or NULL if all coefficients are 0.0 */
1040 extern
1042  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1043  );
1044 
1045 /** gives quadratic elements belonging to a SCIP_EXPR_QUADRATIC expression */
1046 extern
1048  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1049  );
1050 
1051 /** gives number of quadratic elements belonging to a SCIP_EXPR_QUADRATIC expression */
1052 extern
1054  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1055  );
1056 
1057 /** gives the monomials belonging to a SCIP_EXPR_POLYNOMIAL expression */
1058 extern
1060  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1061  );
1062 
1063 /** gives the number of monomials belonging to a SCIP_EXPR_POLYNOMIAL expression */
1064 extern
1066  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1067  );
1068 
1069 /** gives the constant belonging to a SCIP_EXPR_POLYNOMIAL expression */
1070 extern
1072  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1073  );
1074 
1075 /** gives the curvature of a single monomial belonging to a SCIP_EXPR_POLYNOMIAL expression */
1076 extern
1078  SCIP_EXPRGRAPHNODE* node, /**< expression graph node */
1079  int monomialidx, /**< index of monomial */
1080  SCIP_EXPRCURV* curv /**< buffer to store monomial curvature */
1081  );
1082 
1083 /** gets bounds of a node in an expression graph */
1084 extern
1085 SCIP_INTERVAL SCIPexprgraphGetNodeBounds(
1086  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1087  );
1088 
1089 /** gets value of expression associated to node from last evaluation call */
1090 extern
1092  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1093  );
1094 
1095 /** gets curvature of expression associated to node from last curvature check call */
1096 extern
1098  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1099  );
1100 
1101 #ifdef NDEBUG
1102 
1103 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
1104  * speed up the algorithms.
1105  */
1106 
1107 #define SCIPexprgraphCaptureNode(node) do { ++(node)->nuses; } while( FALSE )
1108 #define SCIPexprgraphIsNodeEnabled(node) (node)->enabled
1109 #define SCIPexprgraphGetNodeNChildren(node) (node)->nchildren
1110 #define SCIPexprgraphGetNodeChildren(node) (node)->children
1111 #define SCIPexprgraphGetNodeNParents(node) (node)->nparents
1112 #define SCIPexprgraphGetNodeParents(node) (node)->parents
1113 #define SCIPexprgraphGetNodeDepth(node) (node)->depth
1114 #define SCIPexprgraphGetNodePosition(node) (node)->pos
1115 #define SCIPexprgraphGetNodeOperator(node) (node)->op
1116 #define SCIPexprgraphGetNodeOperatorIndex(node) (node)->data.intval
1117 #define SCIPexprgraphGetNodeOperatorReal(node) (node)->data.dbl
1118 #define SCIPexprgraphGetNodeVar(exprgraph, node) (exprgraph)->vars[(node)->data.intval]
1119 #define SCIPexprgraphGetNodeRealPowerExponent(node) (node)->data.dbl
1120 #define SCIPexprgraphGetNodeIntPowerExponent(node) (node)->data.intval
1121 #define SCIPexprgraphGetNodeSignPowerExponent(node) (node)->data.dbl
1122 #define SCIPexprgraphGetNodeLinearCoefs(node) ((SCIP_Real*)(node)->data.data)
1123 #define SCIPexprgraphGetNodeLinearConstant(node) (((SCIP_Real*)(node)->data.data)[(node)->nchildren])
1124 #define SCIPexprgraphGetNodeQuadraticConstant(node) ((SCIP_EXPRDATA_QUADRATIC*)(node)->data.data)->constant
1125 #define SCIPexprgraphGetNodeQuadraticLinearCoefs(node) ((SCIP_EXPRDATA_QUADRATIC*)(node)->data.data)->lincoefs
1126 #define SCIPexprgraphGetNodeQuadraticQuadElements(node) ((SCIP_EXPRDATA_QUADRATIC*)(node)->data.data)->quadelems
1127 #define SCIPexprgraphGetNodeQuadraticNQuadElements(node) ((SCIP_EXPRDATA_QUADRATIC*)(node)->data.data)->nquadelems
1128 #define SCIPexprgraphGetNodePolynomialMonomials(node) ((SCIP_EXPRDATA_POLYNOMIAL*)(node)->data.data)->monomials
1129 #define SCIPexprgraphGetNodePolynomialNMonomials(node) ((SCIP_EXPRDATA_POLYNOMIAL*)(node)->data.data)->nmonomials
1130 #define SCIPexprgraphGetNodePolynomialConstant(node) ((SCIP_EXPRDATA_POLYNOMIAL*)(node)->data.data)->constant
1131 #define SCIPexprgraphGetNodeBounds(node) (node)->bounds
1132 #define SCIPexprgraphGetNodeVal(node) (node)->value
1133 #define SCIPexprgraphGetNodeCurvature(node) (node)->curv
1134 
1135 #endif
1136 
1137 /** creates an expression graph node */
1138 extern
1140  BMS_BLKMEM* blkmem, /**< block memory */
1141  SCIP_EXPRGRAPHNODE** node, /**< buffer to store expression graph node */
1142  SCIP_EXPROP op, /**< operator type of expression */
1143  ...
1144  );
1145 
1146 /** creates an expression graph node for a linear expression */
1147 extern
1149  BMS_BLKMEM* blkmem, /**< block memory */
1150  SCIP_EXPRGRAPHNODE** node, /**< buffer to store expression graph node */
1151  int ncoefs, /**< number of coefficients */
1152  SCIP_Real* coefs, /**< coefficients of linear expression */
1153  SCIP_Real constant /**< constant of linear expression */
1154  );
1155 
1156 /** creates an expression graph node for a quadratic expression */
1157 extern
1159  BMS_BLKMEM* blkmem, /**< block memory */
1160  SCIP_EXPRGRAPHNODE** node, /**< buffer to store expression graph node */
1161  int nchildren, /**< number of children */
1162  SCIP_Real* lincoefs, /**< linear coefficients for children, or NULL */
1163  int nquadelems, /**< number of quadratic elements */
1164  SCIP_QUADELEM* quadelems, /**< quadratic elements, or NULL if nquadelems == 0 */
1165  SCIP_Real constant /**< constant */
1166  );
1167 
1168 /** creates an expression graph node for a polynomial expression */
1169 extern
1171  BMS_BLKMEM* blkmem, /**< block memory */
1172  SCIP_EXPRGRAPHNODE** node, /**< buffer to store expression graph node */
1173  int nmonomials, /**< number of monomials */
1174  SCIP_EXPRDATA_MONOMIAL** monomials, /**< monomials */
1175  SCIP_Real constant, /**< constant of polynomial */
1176  SCIP_Bool copymonomials /**< whether to copy monomials or to assume ownership */
1177  );
1178 
1179 /** adds monomials to an expression graph node that is a polynomial expression */
1180 extern
1182  BMS_BLKMEM* blkmem, /**< block memory */
1183  SCIP_EXPRGRAPHNODE* node, /**< store expression graph node with polynomial operator */
1184  int nmonomials, /**< number of monomials */
1185  SCIP_EXPRDATA_MONOMIAL** monomials, /**< monomials */
1186  SCIP_Bool copymonomials /**< whether to copy monomials or to assume ownership */
1187  );
1188 
1189 /** given a node of an expression graph, splitup a linear part which variables are not used somewhere else in the same expression
1190  * E.g., if the expression is 1 + x + y + y^2, one gets 1 + x and the node remains at y + y^2.
1191  * If the node is a linear expression, it may be freed.
1192  * If it is not linear, the node may change, i.e., the remaining nonlinear part may be stored in a new node.
1193  * It is assumed that the user had captured the node.
1194  * It is assumed that the expression graph has been simplified before.
1195  */
1196 extern
1198  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1199  SCIP_EXPRGRAPHNODE** node, /**< expression graph node where to splitup linear part */
1200  int linvarssize, /**< length of linvars and lincoefs arrays */
1201  int* nlinvars, /**< buffer to store length of linear term that have been splitup */
1202  void** linvars, /**< buffer to store variables of linear part */
1203  SCIP_Real* lincoefs, /**< buffer to store coefficients of linear part */
1204  SCIP_Real* constant /**< buffer to store constant part */
1205  );
1206 
1207 /** moves parents from a one node to another node
1208  * in other words, replaces the child srcnode by targetnode in all parents of srcnode
1209  * srcnode may be freed, if not captured
1210  * it is assumes that targetnode represents the same expression as srcnode
1211  */
1212 extern
1214  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1215  SCIP_EXPRGRAPHNODE** srcnode, /**< node which parents to move */
1216  SCIP_EXPRGRAPHNODE* targetnode /**< node where to move parents to */
1217  );
1218 
1219 /** releases node, i.e., decreases number of uses
1220  * node is freed if no parents and no other uses
1221  * children are recursively released if they have no other parents
1222  * nodes that are removed are also freed
1223  * if node correspond to a variable, then the variable is removed from the expression graph
1224  * similar for constants
1225  */
1226 extern
1228  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1229  SCIP_EXPRGRAPHNODE** node /**< expression graph node to release */
1230  );
1231 
1232 /** frees a node of an expression graph */
1233 extern
1235  BMS_BLKMEM* blkmem, /**< block memory */
1236  SCIP_EXPRGRAPHNODE** node /**< pointer to expression graph node that should be freed */
1237  );
1238 
1239 /** enables a node and recursively all its children in an expression graph */
1240 extern
1242  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1243  SCIP_EXPRGRAPHNODE* node /**< expression graph node to enable */
1244  );
1245 
1246 /** disables a node and recursively all children which have no enabled parents in an expression graph */
1247 extern
1249  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1250  SCIP_EXPRGRAPHNODE* node /**< expression graph node to enable */
1251  );
1252 
1253 /** returns whether the node has siblings in the expression graph */
1254 extern
1256  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1257  );
1258 
1259 /** returns whether all children of an expression graph node are variable nodes
1260  * gives TRUE for nodes without children
1261  */
1262 extern
1264  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1265  );
1266 
1267 /** returns whether the node has an ancestor which has a nonlinear expression operand */
1268 extern
1270  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1271  );
1272 
1273 /** prints an expression graph node */
1274 extern
1276  SCIP_EXPRGRAPHNODE* node, /**< expression graph node */
1277  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1278  FILE* file /**< file to print to, or NULL for stdout */
1279  );
1280 
1281 /** tightens the bounds in a node of the graph
1282  * preparation for reverse propagation
1283  * sets bound status to SCIP_EXPRBOUNDSTATUS_TIGHTENEDBYPARENTRECENT if tightening is strong enough and not cutoff
1284  */
1285 extern
1287  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1288  SCIP_EXPRGRAPHNODE* node, /**< node in expression graph with no parents */
1289  SCIP_INTERVAL nodebounds, /**< new bounds for node */
1290  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) */
1291  SCIP_Bool* cutoff /**< buffer to store whether a node's bounds were propagated to an empty interval */
1292  );
1293 
1294 /** ensures that bounds and curvature information in a node is uptodate
1295  * assumes that bounds and curvature in children are uptodate
1296  */
1297 extern
1299  SCIP_EXPRGRAPHNODE* node, /**< expression graph node */
1300  SCIP_Real infinity, /**< value for infinity in interval arithmetics */
1301  SCIP_Real minstrength, /**< minimal required relative bound strengthening to trigger a bound recalculation in parent nodes */
1302  SCIP_Bool clearreverseprop /**< whether to reset bound tightenings from reverse propagation */
1303  );
1304 
1305 /**@} */
1306 
1307 /**@name Expression graph methods */
1308 /**@{ */
1309 
1310 /** get current maximal depth of expression graph */
1311 extern
1313  SCIP_EXPRGRAPH* exprgraph /**< expression graph */
1314  );
1315 
1316 /** gets array with number of nodes at each depth of expression graph */
1317 extern
1319  SCIP_EXPRGRAPH* exprgraph /**< expression graph */
1320  );
1321 
1322 /** gets nodes of expression graph, one array per depth */
1323 extern
1325  SCIP_EXPRGRAPH* exprgraph /**< expression graph */
1326  );
1327 
1328 /** gets number of variables in expression graph */
1329 extern
1331  SCIP_EXPRGRAPH* exprgraph /**< pointer to expression graph that should be freed */
1332  );
1333 
1334 /** gets array of variables in expression graph */
1335 extern
1336 void** SCIPexprgraphGetVars(
1337  SCIP_EXPRGRAPH* exprgraph /**< pointer to expression graph that should be freed */
1338  );
1339 
1340 /** gets array of expression graph nodes corresponding to variables */
1341 extern
1343  SCIP_EXPRGRAPH* exprgraph /**< pointer to expression graph that should be freed */
1344  );
1345 
1346 /** sets value for a single variable given as expression graph node */
1347 extern
1349  SCIP_EXPRGRAPHNODE* varnode, /**< expression graph node corresponding to variable */
1350  SCIP_Real value /**< new value for variable */
1351  );
1352 
1353 /** sets bounds for variables */
1354 extern
1356  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1357  SCIP_INTERVAL* varbounds /**< new bounds for variables */
1358  );
1359 
1360 /** sets bounds for a single variable */
1361 extern
1363  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1364  void* var, /**< variable */
1365  SCIP_INTERVAL varbounds /**< new bounds of variable */
1366  );
1367 
1368 /** sets bounds for a single variable given as expression graph node */
1369 extern
1371  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1372  SCIP_EXPRGRAPHNODE* varnode, /**< expression graph node corresponding to variable */
1373  SCIP_INTERVAL varbounds /**< new bounds of variable */
1374  );
1375 
1376 /** sets lower bound for a single variable given as expression graph node */
1377 extern
1379  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1380  SCIP_EXPRGRAPHNODE* varnode, /**< expression graph node corresponding to variable */
1381  SCIP_Real lb /**< new lower bound for variable */
1382  );
1383 
1384 /** sets upper bound for a single variable given as expression graph node */
1385 extern
1387  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1388  SCIP_EXPRGRAPHNODE* varnode, /**< expression graph node corresponding to variable */
1389  SCIP_Real ub /**< new upper bound for variable */
1390  );
1391 
1392 /** gets bounds that are stored for all variables */
1393 extern
1394 SCIP_INTERVAL* SCIPexprgraphGetVarsBounds(
1395  SCIP_EXPRGRAPH* exprgraph /**< expression graph */
1396  );
1397 
1398 #ifdef NDEBUG
1399 
1400 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and
1401  * speed up the algorithms.
1402  */
1403 
1404 #define SCIPexprgraphGetDepth(exprgraph) (exprgraph)->depth
1405 #define SCIPexprgraphGetNNodes(exprgraph) (exprgraph)->nnodes
1406 #define SCIPexprgraphGetNodes(exprgraph) (exprgraph)->nodes
1407 #define SCIPexprgraphGetNVars(exprgraph) (exprgraph)->nvars
1408 #define SCIPexprgraphGetVars(exprgraph) (exprgraph)->vars
1409 #define SCIPexprgraphGetVarNodes(exprgraph) (exprgraph)->varnodes
1410 #define SCIPexprgraphSetVarNodeValue(varnode, newvalue) do { (varnode)->value = newvalue; } while (FALSE)
1411 #define SCIPexprgraphSetVarsBounds(exprgraph, newvarbounds) BMScopyMemoryArray((exprgraph)->varbounds, newvarbounds, (exprgraph)->nvars)
1412 #define SCIPexprgraphSetVarBounds(exprgraph, var, newvarbounds) do { (exprgraph)->varbounds[(int)(size_t)SCIPhashmapGetImage((exprgraph)->varidxs, var)] = newvarbounds; } while (FALSE)
1413 #define SCIPexprgraphSetVarNodeBounds(exprgraph, varnode, newvarbounds) do { (exprgraph)->varbounds[(varnode)->data.intval] = newvarbounds; } while (FALSE)
1414 #define SCIPexprgraphSetVarNodeLb(exprgraph, varnode, lb) do { (exprgraph)->varbounds[(varnode)->data.intval].inf = lb; } while (FALSE)
1415 #define SCIPexprgraphSetVarNodeUb(exprgraph, varnode, ub) do { (exprgraph)->varbounds[(varnode)->data.intval].sup = ub; } while (FALSE)
1416 #define SCIPexprgraphGetVarsBounds(exprgraph) (exprgraph)->varbounds
1417 
1418 #endif
1419 
1420 /** creates an empty expression graph */
1421 extern
1423  BMS_BLKMEM* blkmem, /**< block memory */
1424  SCIP_EXPRGRAPH** exprgraph, /**< buffer to store pointer to expression graph */
1425  int varssizeinit, /**< minimal initial size for variables array, or -1 to choose automatically */
1426  int depthinit, /**< minimal initial depth of expression graph, or -1 to choose automatically */
1427  SCIP_DECL_EXPRGRAPHVARADDED((*exprgraphvaradded)), /** callback method to invoke when a variable has been added to the expression graph, or NULL if not needed */
1428  SCIP_DECL_EXPRGRAPHVARREMOVE((*exprgraphvarremove)), /** callback method to invoke when a variable will be removed from the expression graph, or NULL if not needed */
1429  SCIP_DECL_EXPRGRAPHVARCHGIDX((*exprgraphvarchgidx)), /** callback method to invoke when a variable changes its index in the expression graph, or NULL if not needed */
1430  void* userdata /**< user data to pass to callback functions */
1431  );
1432 
1433 /** frees an expression graph */
1434 extern
1436  SCIP_EXPRGRAPH** exprgraph /**< pointer to expression graph that should be freed */
1437  );
1438 
1439 /** adds an expression graph node to an expression graph
1440  * expression graph assumes ownership of node
1441  * children are notified about new parent
1442  * depth will be chosen to be the maximum of mindepth and the depth of all children plus one
1443  */
1444 extern
1446  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1447  SCIP_EXPRGRAPHNODE* node, /**< expression graph node to add */
1448  int mindepth, /**< minimal depth in expression graph where to add node, e.g., 0 or smaller to choose automatically */
1449  int nchildren, /**< number of children */
1450  SCIP_EXPRGRAPHNODE** children /**< children nodes, or NULL if no children */
1451  );
1452 
1453 /** adds variables to an expression graph, if not existing yet
1454  * also already existing nodes are enabled
1455  */
1456 extern
1458  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1459  int nvars, /**< number of variables to add */
1460  void** vars, /**< variables to add */
1461  SCIP_EXPRGRAPHNODE** varnodes /**< array to store nodes corresponding to variables, or NULL if not of interest */
1462  );
1463 
1464 /** adds a constant to an expression graph, if not existing yet
1465  * also already existing nodes are enabled
1466  */
1468  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1469  SCIP_Real constant, /**< constant to add */
1470  SCIP_EXPRGRAPHNODE** constnode /**< buffer to store pointer to expression graph node corresponding to constant */
1471  );
1472 
1473 /** adds sum of expression trees into expression graph
1474  * node will also be captured
1475  */
1476 extern
1478  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1479  int nexprtrees, /**< number of expression trees to add */
1480  SCIP_EXPRTREE** exprtrees, /**< expression trees that should be added */
1481  SCIP_Real* coefs, /**< coefficients of expression trees, or NULL if all 1.0 */
1482  SCIP_EXPRGRAPHNODE** rootnode, /**< buffer to store expression graph node corresponding to root of expression tree */
1483  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) */
1484  );
1485 
1486 /** replaces variable in expression graph by a linear sum of variables
1487  * variables will be added if not in the graph yet
1488  */
1489 extern
1491  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1492  void* var, /**< variable to replace */
1493  int ncoefs, /**< number of coefficients in linear term */
1494  SCIP_Real* coefs, /**< coefficients in linear term, or NULL if ncoefs == 0 */
1495  void** vars, /**< variables in linear term */
1496  SCIP_Real constant /**< constant offset */
1497  );
1498 
1499 /** finds expression graph node corresponding to a variable */
1500 extern
1502  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1503  void* var, /**< variable to search for */
1504  SCIP_EXPRGRAPHNODE** varnode /**< buffer to store node corresponding to variable, if found, or NULL if not found */
1505  );
1506 
1507 /** finds expression graph node corresponding to a constant */
1508 extern
1510  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1511  SCIP_Real constant, /**< constant to search for */
1512  SCIP_EXPRGRAPHNODE** constnode /**< buffer to store node corresponding to constant, if found, or NULL if not found */
1513  );
1514 
1515 /** prints an expression graph in dot format */
1516 extern
1518  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1519  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1520  FILE* file, /**< file to print to, or NULL for stdout */
1521  const char** varnames /**< variable names, or NULL for generic names */
1522  );
1523 
1524 /** evaluates nodes of expression graph for given values of variables */
1525 extern
1527  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1528  SCIP_Real* varvals /**< values for variables */
1529  );
1530 
1531 /** propagates bound changes in variables forward through the expression graph */
1532 extern
1534  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1535  SCIP_Real infinity, /**< value for infinity in interval arithmetics */
1536  SCIP_Bool clearreverseprop, /**< whether to reset bound tightenings from reverse propagation */
1537  SCIP_Bool* domainerror /**< buffer to store whether a node with empty bounds has been found, propagation is interrupted in this case */
1538  );
1539 
1540 /** propagates bound changes in nodes backward through the graph
1541  * new bounds are not stored in varbounds, but only in nodes corresponding to variables
1542  * NOTE: it is assumed that SCIPexprgraphPropagateVarBounds was called before if variable bounds were relaxed
1543  */
1544 extern
1546  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1547  SCIP_Real infinity, /**< value for infinity in interval arithmetics */
1548  SCIP_Real minstrength, /**< minimal required relative bound strengthening in a node to trigger a propagation into children nodes */
1549  SCIP_Bool* cutoff /**< buffer to store whether a node's bounds were propagated to an empty interval */
1550  );
1551 
1552 /** updates curvature information in expression graph nodes w.r.t. currently stored variable bounds
1553  * implies update of bounds in expression graph
1554  */
1555 extern
1557  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1558  SCIP_Real infinity, /**< value for infinity in interval arithmetics */
1559  SCIP_Bool clearreverseprop /**< whether to reset bound tightenings from reverse propagation */
1560  );
1561 
1562 /** aims at simplifying an expression graph
1563  * 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))
1564  */
1565 extern
1567  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1568  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
1569  SCIP_Real eps, /**< threshold, under which positive values are treat as 0 */
1570  int maxexpansionexponent,/**< maximal exponent for which we still expand non-monomial polynomials */
1571  SCIP_Bool* havechange, /**< buffer to indicate whether the graph has been modified */
1572  SCIP_Bool* domainerror /**< buffer to indicate whether a domain error has been encountered, i.e., some expressions turned into NaN */
1573  );
1574 
1575 /** creates an expression tree from a given node in an expression graph */
1576 extern
1578  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1579  SCIP_EXPRGRAPHNODE* rootnode, /**< expression graph node that should represent root of expression tree */
1580  SCIP_EXPRTREE** exprtree /**< buffer to store pointer to created expression tree */
1581  );
1582 
1583 /** creates a sum of expression trees with pairwise disjoint variables from a given node in an expression graph
1584  * Giving SCIPexprgraphGetNodeNChildren() for exprtreesize is always sufficient.
1585  */
1586 extern
1588  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1589  SCIP_EXPRGRAPHNODE* node, /**< expression graph node which represents expression to get */
1590  int exprtreessize, /**< length of exprtrees and exprtreecoefs arrays, need to be at least one */
1591  int* nexprtrees, /**< buffer to store number of expression trees */
1592  SCIP_EXPRTREE** exprtrees, /**< array where to store expression trees */
1593  SCIP_Real* exprtreecoefs /**< array where to store coefficients of expression trees */
1594  );
1595 
1596 /** returns how often expression graph variables are used in a subtree of the expression graph */
1597 extern
1599  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1600  SCIP_EXPRGRAPHNODE* node, /**< root node of expression graph subtree */
1601  int* varsusage /**< array where to count usage of variables, length must be at least the number of variables in the graph */
1602  );
1603 
1604 /** gives the number of summands which the expression of an expression graph node consists of */
1605 extern
1607  SCIP_EXPRGRAPHNODE* node /**< expression graph node */
1608  );
1609 
1610 /** creates a sum of expression trees, possibly sharing variables, from a given node in an expression graph */
1611 extern
1613  SCIP_EXPRGRAPH* exprgraph, /**< expression graph */
1614  SCIP_EXPRGRAPHNODE* node, /**< expression graph node which represents expression to get */
1615  int exprtreessize, /**< length of exprtrees and exptreecoefs arrays, should be at least SCIPexprgraphGetSumTreesNSummands() */
1616  int* nexprtrees, /**< buffer to store number of expression trees */
1617  SCIP_EXPRTREE** exprtrees, /**< array where to store expression trees */
1618  SCIP_Real* exprtreecoefs /**< array where to store coefficients of expression trees */
1619  );
1620 
1621 /**@} */
1622 
1623 #ifdef __cplusplus
1624 }
1625 #endif
1626 
1627 #endif /* __NLPI_PUB_EXPR_H__ */
SCIP_RETCODE SCIPexprAdd(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, SCIP_Real coef1, SCIP_EXPR *term1, SCIP_Real coef2, SCIP_EXPR *term2, SCIP_Real constant)
SCIP_EXPRCURV SCIPexprcurvNegate(SCIP_EXPRCURV curvature)
int SCIPexprgraphGetNodeIntPowerExponent(SCIP_EXPRGRAPHNODE *node)
void ** SCIPexprgraphGetVars(SCIP_EXPRGRAPH *exprgraph)
SCIP_RETCODE SCIPexprMultiplyPolynomialByPolynomial(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, SCIP_EXPR *factor, int *childmap)
void SCIPexprgraphDisableNode(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node)
SCIP_RETCODE SCIPexprgraphAddConst(SCIP_EXPRGRAPH *exprgraph, SCIP_Real constant, SCIP_EXPRGRAPHNODE **constnode)
void SCIPexprtreeGetVarsUsage(SCIP_EXPRTREE *tree, int *varsusage)
void SCIPquadelemSqueeze(SCIP_QUADELEM *quadelems, int nquadelems, int *nquadelemsnew)
SCIP_RETCODE SCIPexprtreeEval(SCIP_EXPRTREE *tree, SCIP_Real *varvals, SCIP_Real *val)
int SCIPexprgraphGetNodeNParents(SCIP_EXPRGRAPHNODE *node)
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)
SCIP_QUADELEM * SCIPexprgraphGetNodeQuadraticQuadElements(SCIP_EXPRGRAPHNODE *node)
int SCIPexprGetNChildren(SCIP_EXPR *expr)
void SCIPexprtreeSetInterpreterData(SCIP_EXPRTREE *tree, SCIP_EXPRINTDATA *interpreterdata)
struct SCIP_QuadElement SCIP_QUADELEM
Definition: type_expr.h:105
void SCIPexprFreeMonomial(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_MONOMIAL **monomial)
SCIP_QUADELEM * SCIPexprGetQuadElements(SCIP_EXPR *expr)
int SCIPexprgraphGetNodePolynomialNMonomials(SCIP_EXPRGRAPHNODE *node)
SCIP_Real SCIPexprGetMonomialCoef(SCIP_EXPRDATA_MONOMIAL *monomial)
void SCIPexprtreePrint(SCIP_EXPRTREE *tree, SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char **varnames, const char **paramnames)
void SCIPexprMergeMonomialFactors(SCIP_EXPRDATA_MONOMIAL *monomial, SCIP_Real eps)
SCIP_Real SCIPexprgraphGetNodeLinearConstant(SCIP_EXPRGRAPHNODE *node)
void SCIPexprgraphTightenNodeBounds(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, SCIP_INTERVAL nodebounds, SCIP_Real minstrength, SCIP_Bool *cutoff)
void SCIPexprgraphSetVarsBounds(SCIP_EXPRGRAPH *exprgraph, SCIP_INTERVAL *varbounds)
type definitions for expression interpreter
SCIP_RETCODE SCIPexprgraphNodeSplitOffLinear(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE **node, int linvarssize, int *nlinvars, void **linvars, SCIP_Real *lincoefs, SCIP_Real *constant)
void SCIPexprChgMonomialCoef(SCIP_EXPRDATA_MONOMIAL *monomial, SCIP_Real newcoef)
SCIP_RETCODE SCIPexprgraphGetSumTrees(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, int exprtreessize, int *nexprtrees, SCIP_EXPRTREE **exprtrees, SCIP_Real *exprtreecoefs)
void SCIPexprPrint(SCIP_EXPR *expr, SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char **varnames, const char **paramnames, SCIP_Real *paramvals)
struct SCIP_ExprData_Monomial SCIP_EXPRDATA_MONOMIAL
Definition: type_expr.h:108
SCIP_RETCODE SCIPexprgraphCreateNodeQuadratic(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE **node, int nchildren, SCIP_Real *lincoefs, int nquadelems, SCIP_QUADELEM *quadelems, SCIP_Real constant)
int SCIPexprgraphGetSumTreesNSummands(SCIP_EXPRGRAPHNODE *node)
SCIP_Bool SCIPexprAreMonomialsEqual(SCIP_EXPRDATA_MONOMIAL *monomial1, SCIP_EXPRDATA_MONOMIAL *monomial2, SCIP_Real eps)
int SCIPexprgraphGetNodeQuadraticNQuadElements(SCIP_EXPRGRAPHNODE *node)
struct SCIP_Messagehdlr SCIP_MESSAGEHDLR
Definition: type_message.h:50
SCIP_Real * SCIPexprGetMonomialExponents(SCIP_EXPRDATA_MONOMIAL *monomial)
void SCIPexprReindexVars(SCIP_EXPR *expr, int *newindices)
int SCIPexprtreeGetNVars(SCIP_EXPRTREE *tree)
SCIP_RETCODE SCIPexprgraphFree(SCIP_EXPRGRAPH **exprgraph)
void SCIPexprgraphSetVarNodeUb(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *varnode, SCIP_Real ub)
SCIP_RETCODE SCIPexprSubstituteVars(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, SCIP_EXPR **substexprs)
SCIP_RETCODE SCIPexprgraphCreateNodePolynomial(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE **node, int nmonomials, SCIP_EXPRDATA_MONOMIAL **monomials, SCIP_Real constant, SCIP_Bool copymonomials)
SCIP_RETCODE SCIPexprgraphUpdateNodeBoundsCurvature(SCIP_EXPRGRAPHNODE *node, SCIP_Real infinity, SCIP_Real minstrength, SCIP_Bool clearreverseprop)
SCIP_EXPRGRAPHNODE ** SCIPexprgraphGetVarNodes(SCIP_EXPRGRAPH *exprgraph)
void SCIPexprgraphFreeNode(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE **node)
SCIP_RETCODE SCIPexprgraphGetSeparableTrees(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, int exprtreessize, int *nexprtrees, SCIP_EXPRTREE **exprtrees, SCIP_Real *exprtreecoefs)
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_RETCODE SCIPexprAddMonomialFactors(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_MONOMIAL *monomial, int nfactors, int *childidxs, SCIP_Real *exponents)
SCIP_Real SCIPexprGetSignPowerExponent(SCIP_EXPR *expr)
void * SCIPexprgraphGetNodeVar(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node)
SCIP_RETCODE SCIPexprCopyDeep(BMS_BLKMEM *blkmem, SCIP_EXPR **targetexpr, SCIP_EXPR *sourceexpr)
SCIP_EXPRCURV SCIPexprgraphGetNodeCurvature(SCIP_EXPRGRAPHNODE *node)
void * SCIPexprGetOpData(SCIP_EXPR *expr)
SCIP_RETCODE SCIPexprgraphNodePolynomialAddMonomials(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE *node, int nmonomials, SCIP_EXPRDATA_MONOMIAL **monomials, SCIP_Bool copymonomials)
SCIP_Bool SCIPexprHasParam(SCIP_EXPR *expr)
SCIP_EXPRINTDATA * SCIPexprtreeGetInterpreterData(SCIP_EXPRTREE *tree)
int SCIPexprGetNMonomials(SCIP_EXPR *expr)
SCIP_RETCODE SCIPexprgraphAddExprtreeSum(SCIP_EXPRGRAPH *exprgraph, int nexprtrees, SCIP_EXPRTREE **exprtrees, SCIP_Real *coefs, SCIP_EXPRGRAPHNODE **rootnode, SCIP_Bool *rootnodeisnew)
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)
SCIP_Bool SCIPexprgraphAreAllNodeChildrenVars(SCIP_EXPRGRAPHNODE *node)
void SCIPexprgraphSetVarNodeBounds(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *varnode, SCIP_INTERVAL varbounds)
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)
int SCIPexprgraphGetNodeDepth(SCIP_EXPRGRAPHNODE *node)
int SCIPexprGetNQuadElements(SCIP_EXPR *expr)
SCIP_INTERVAL * SCIPexprgraphGetVarsBounds(SCIP_EXPRGRAPH *exprgraph)
SCIP_EXPR ** SCIPexprGetChildren(SCIP_EXPR *expr)
SCIP_RETCODE SCIPexprtreeGetMaxDegree(SCIP_EXPRTREE *tree, int *maxdegree)
SCIP_EXPRCURV SCIPexprcurvMonomial(int nfactors, SCIP_Real *exponents, int *factoridxs, SCIP_EXPRCURV *factorcurv, SCIP_INTERVAL *factorbounds)
SCIP_EXPRCURV SCIPexprcurvMultiply(SCIP_Real factor, SCIP_EXPRCURV curvature)
SCIP_Bool SCIPexprgraphHasNodeNonlinearAncestor(SCIP_EXPRGRAPHNODE *node)
void SCIPexprSortQuadElems(SCIP_EXPR *expr)
SCIP_EXPRGRAPHNODE ** SCIPexprgraphGetNodeParents(SCIP_EXPRGRAPHNODE *node)
SCIP_RETCODE SCIPexprEvalInt(SCIP_EXPR *expr, SCIP_Real infinity, SCIP_INTERVAL *varvals, SCIP_Real *param, SCIP_INTERVAL *val)
#define SCIP_DECL_EXPRGRAPHVARADDED(x)
Definition: type_expr.h:178
SCIP_RETCODE SCIPexprEval(SCIP_EXPR *expr, SCIP_Real *varvals, SCIP_Real *param, SCIP_Real *val)
void SCIPexprSortMonomialFactors(SCIP_EXPRDATA_MONOMIAL *monomial)
int * SCIPexprGetMonomialChildIndices(SCIP_EXPRDATA_MONOMIAL *monomial)
SCIP_RETCODE SCIPexprtreeFree(SCIP_EXPRTREE **tree)
SCIP_RETCODE SCIPexprgraphPrintDot(SCIP_EXPRGRAPH *exprgraph, SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char **varnames)
SCIP_Real SCIPexprGetQuadConstant(SCIP_EXPR *expr)
SCIP_Bool SCIPexprAreEqual(SCIP_EXPR *expr1, SCIP_EXPR *expr2, SCIP_Real eps)
enum SCIP_ExprOp SCIP_EXPROP
Definition: type_expr.h:88
int SCIPexpropGetNChildren(SCIP_EXPROP op)
SCIP_EXPR * SCIPexprtreeGetRoot(SCIP_EXPRTREE *tree)
SCIP_RETCODE SCIPexprPolynomialPower(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, int exponent)
SCIP_RETCODE SCIPexprParse(BMS_BLKMEM *blkmem, SCIP_MESSAGEHDLR *messagehdlr, SCIP_EXPR **expr, const char *str, const char *lastchar, int *nvars, int *varnames)
SCIP_RETCODE SCIPexprAddToLinear(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, int nchildren, SCIP_Real *coefs, SCIP_EXPR **children, SCIP_Real constant)
SCIP_RETCODE SCIPexprtreeFreeInterpreterData(SCIP_EXPRTREE *tree)
SCIP_RETCODE SCIPexprgraphEval(SCIP_EXPRGRAPH *exprgraph, SCIP_Real *varvals)
SCIP_RETCODE SCIPexprgraphMoveNodeParents(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE **srcnode, SCIP_EXPRGRAPHNODE *targetnode)
void SCIPexprMergeMonomials(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, SCIP_Real eps, SCIP_Bool mergefactors)
SCIP_Real SCIPexprgraphGetNodeRealPowerExponent(SCIP_EXPRGRAPHNODE *node)
int SCIPexprgraphGetNodePosition(SCIP_EXPRGRAPHNODE *node)
SCIP_RETCODE SCIPexprtreeEvalInt(SCIP_EXPRTREE *tree, SCIP_Real infinity, SCIP_INTERVAL *varvals, SCIP_INTERVAL *val)
SCIP_RETCODE SCIPexprgraphCreateNodeLinear(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE **node, int ncoefs, SCIP_Real *coefs, SCIP_Real constant)
SCIP_EXPROP SCIPexprgraphGetNodeOperator(SCIP_EXPRGRAPHNODE *node)
SCIP_RETCODE SCIPexprgraphAddNode(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, int mindepth, int nchildren, SCIP_EXPRGRAPHNODE **children)
SCIP_EXPRDATA_MONOMIAL ** SCIPexprGetMonomials(SCIP_EXPR *expr)
void SCIPexprgraphEnableNode(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node)
void SCIPexprMultiplyPolynomialByConstant(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, SCIP_Real factor)
SCIP_RETCODE SCIPexprgraphCheckCurvature(SCIP_EXPRGRAPH *exprgraph, SCIP_Real infinity, SCIP_Bool clearreverseprop)
const char * SCIPexpropGetName(SCIP_EXPROP op)
void SCIPexprChgPolynomialConstant(SCIP_EXPR *expr, SCIP_Real constant)
SCIP_RETCODE SCIPexprGetMaxDegree(SCIP_EXPR *expr, int *maxdegree)
SCIP_Real SCIPexprGetOpReal(SCIP_EXPR *expr)
SCIP_Bool SCIPexprtreeHasParam(SCIP_EXPRTREE *tree)
void SCIPexprFreeShallow(BMS_BLKMEM *blkmem, SCIP_EXPR **expr)
int SCIPexprgraphGetNVars(SCIP_EXPRGRAPH *exprgraph)
struct SCIP_ExprTree SCIP_EXPRTREE
Definition: type_expr.h:91
SCIP_Real SCIPexprGetRealPowerExponent(SCIP_EXPR *expr)
SCIP_EXPRCURV SCIPexprcurvPower(SCIP_INTERVAL basebounds, SCIP_EXPRCURV basecurv, SCIP_Real exponent)
int SCIPexprGetMonomialNFactors(SCIP_EXPRDATA_MONOMIAL *monomial)
#define SCIP_Bool
Definition: def.h:49
struct SCIP_ExprGraph SCIP_EXPRGRAPH
Definition: type_expr.h:168
SCIP_Bool SCIPquadelemSortedFind(SCIP_QUADELEM *quadelems, int idx1, int idx2, int nquadelems, int *pos)
void SCIPexprFreeDeep(BMS_BLKMEM *blkmem, SCIP_EXPR **expr)
SCIP_EXPRCURV SCIPexprcurvAdd(SCIP_EXPRCURV curv1, SCIP_EXPRCURV curv2)
int SCIPexprGetOpIndex(SCIP_EXPR *expr)
int SCIPexprgraphGetNodeOperatorIndex(SCIP_EXPRGRAPHNODE *node)
SCIP_RETCODE SCIPexprMultiplyMonomialByMonomial(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_MONOMIAL *monomial, SCIP_EXPRDATA_MONOMIAL *factor, int *childmap)
SCIP_RETCODE SCIPexprtreeSubstituteVars(SCIP_EXPRTREE *tree, SCIP_EXPR **substexprs)
SCIP_Real SCIPexprGetPolynomialConstant(SCIP_EXPR *expr)
void SCIPexprgraphSetVarBounds(SCIP_EXPRGRAPH *exprgraph, void *var, SCIP_INTERVAL varbounds)
SCIP_Real * SCIPexprtreeGetParamVals(SCIP_EXPRTREE *tree)
struct SCIP_ExprGraphNode SCIP_EXPRGRAPHNODE
Definition: type_expr.h:167
int * SCIPexprgraphGetNNodes(SCIP_EXPRGRAPH *exprgraph)
SCIP_RETCODE SCIPexprgraphReleaseNode(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE **node)
SCIP_Real SCIPexprgraphGetNodeSignPowerExponent(SCIP_EXPRGRAPHNODE *node)
SCIP_RETCODE SCIPexprgraphSimplify(SCIP_EXPRGRAPH *exprgraph, SCIP_MESSAGEHDLR *messagehdlr, SCIP_Real eps, int maxexpansionexponent, SCIP_Bool *havechange, SCIP_Bool *domainerror)
SCIP_RETCODE SCIPexprMultiplyPolynomialByMonomial(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, SCIP_EXPRDATA_MONOMIAL *factor, int *childmap)
SCIP_RETCODE SCIPexprgraphGetTree(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *rootnode, SCIP_EXPRTREE **exprtree)
void SCIPexprgraphSetVarNodeValue(SCIP_EXPRGRAPHNODE *varnode, SCIP_Real value)
SCIP_RETCODE SCIPexprtreeCheckCurvature(SCIP_EXPRTREE *tree, SCIP_Real infinity, SCIP_INTERVAL *varbounds, SCIP_EXPRCURV *curv, SCIP_INTERVAL *bounds)
SCIP_RETCODE SCIPexprtreeCopy(BMS_BLKMEM *blkmem, SCIP_EXPRTREE **targettree, SCIP_EXPRTREE *sourcetree)
const char * SCIPexprcurvGetName(SCIP_EXPRCURV curv)
int SCIPexprgraphGetNodeNChildren(SCIP_EXPRGRAPHNODE *node)
SCIP_Real * SCIPexprgraphGetNodeLinearCoefs(SCIP_EXPRGRAPHNODE *node)
#define SCIP_DECL_EXPRGRAPHVARREMOVE(x)
Definition: type_expr.h:188
SCIP_RETCODE SCIPexprCreate(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, SCIP_EXPROP op,...)
SCIP_RETCODE SCIPexprgraphPropagateVarBounds(SCIP_EXPRGRAPH *exprgraph, SCIP_Real infinity, SCIP_Bool clearreverseprop, SCIP_Bool *domainerror)
enum SCIP_ExprCurv SCIP_EXPRCURV
Definition: type_expr.h:92
SCIP_Bool SCIPexprgraphHasNodeSibling(SCIP_EXPRGRAPHNODE *node)
void SCIPexprgraphSetVarNodeLb(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *varnode, SCIP_Real lb)
SCIP_RETCODE SCIPexprAddMonomials(BMS_BLKMEM *blkmem, SCIP_EXPR *expr, int nmonomials, SCIP_EXPRDATA_MONOMIAL **monomials, SCIP_Bool copymonomials)
int SCIPexprtreeGetNParams(SCIP_EXPRTREE *tree)
SCIP_Bool SCIPexprgraphFindVarNode(SCIP_EXPRGRAPH *exprgraph, void *var, SCIP_EXPRGRAPHNODE **varnode)
int SCIPexprgraphGetDepth(SCIP_EXPRGRAPH *exprgraph)
SCIP_RETCODE SCIPexprtreeSimplify(SCIP_EXPRTREE *tree, SCIP_MESSAGEHDLR *messagehdlr, SCIP_Real eps, int maxexpansionexponent, int *nlinvars, int *linidxs, SCIP_Real *lincoefs)
SCIP_Real SCIPexprgraphGetNodeOperatorReal(SCIP_EXPRGRAPHNODE *node)
SCIP_Real SCIPexprgraphGetNodePolynomialConstant(SCIP_EXPRGRAPHNODE *node)
void SCIPexprgraphCaptureNode(SCIP_EXPRGRAPHNODE *node)
SCIP_Bool SCIPexprgraphFindConstNode(SCIP_EXPRGRAPH *exprgraph, SCIP_Real constant, SCIP_EXPRGRAPHNODE **constnode)
SCIP_RETCODE SCIPexprMulConstant(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, SCIP_EXPR *term, SCIP_Real factor)
type definitions for expressions and expression trees
void SCIPexprgraphPrintNode(SCIP_EXPRGRAPHNODE *node, SCIP_MESSAGEHDLR *messagehdlr, FILE *file)
public methods for message output
void SCIPquadelemSort(SCIP_QUADELEM *quadelems, int nquadelems)
SCIP_RETCODE SCIPexprgraphCreateNode(BMS_BLKMEM *blkmem, SCIP_EXPRGRAPHNODE **node, SCIP_EXPROP op,...)
SCIP_RETCODE SCIPexprgraphGetNodePolynomialMonomialCurvature(SCIP_EXPRGRAPHNODE *node, int monomialidx, SCIP_EXPRCURV *curv)
void SCIPexprReindexParams(SCIP_EXPR *expr, int *newindices)
SCIP_EXPROP SCIPexprGetOperator(SCIP_EXPR *expr)
#define SCIP_Real
Definition: def.h:123
int SCIPexprGetIntPowerExponent(SCIP_EXPR *expr)
SCIP_RETCODE SCIPexprgraphReplaceVarByLinearSum(SCIP_EXPRGRAPH *exprgraph, void *var, int ncoefs, SCIP_Real *coefs, void **vars, SCIP_Real constant)
void SCIPexprGetVarsUsage(SCIP_EXPR *expr, int *varsusage)
void SCIPexprgraphPropagateNodeBounds(SCIP_EXPRGRAPH *exprgraph, SCIP_Real infinity, SCIP_Real minstrength, SCIP_Bool *cutoff)
SCIP_Real SCIPexprGetLinearConstant(SCIP_EXPR *expr)
SCIP_EXPRGRAPHNODE *** SCIPexprgraphGetNodes(SCIP_EXPRGRAPH *exprgraph)
SCIP_RETCODE SCIPexprtreeCreate(BMS_BLKMEM *blkmem, SCIP_EXPRTREE **tree, SCIP_EXPR *root, int nvars, int nparams, SCIP_Real *params)
void SCIPexprMonomialPower(SCIP_EXPRDATA_MONOMIAL *monomial, int exponent)
SCIP_EXPRDATA_MONOMIAL ** SCIPexprgraphGetNodePolynomialMonomials(SCIP_EXPRGRAPHNODE *node)
SCIP_EXPRGRAPHNODE ** SCIPexprgraphGetNodeChildren(SCIP_EXPRGRAPHNODE *node)
void SCIPexprtreeSetParamVal(SCIP_EXPRTREE *tree, int paramidx, SCIP_Real paramval)
SCIP_RETCODE SCIPexprCreateMonomial(BMS_BLKMEM *blkmem, SCIP_EXPRDATA_MONOMIAL **monomial, SCIP_Real coef, int nfactors, int *childidxs, SCIP_Real *exponents)
SCIP_Real * SCIPexprGetLinearCoefs(SCIP_EXPR *expr)
SCIP_Bool SCIPexprFindMonomialFactor(SCIP_EXPRDATA_MONOMIAL *monomial, int childidx, int *pos)
SCIP_Real * SCIPexprgraphGetNodeQuadraticLinearCoefs(SCIP_EXPRGRAPHNODE *node)
SCIP_RETCODE SCIPexprtreeAddExpr(SCIP_EXPRTREE *tree, SCIP_EXPR *expr, SCIP_Bool copyexpr)
SCIP_Real SCIPexprgraphGetNodeQuadraticConstant(SCIP_EXPRGRAPHNODE *node)
common defines and data types used in all packages of SCIP
SCIP_RETCODE SCIPexprCheckCurvature(SCIP_EXPR *expr, SCIP_Real infinity, SCIP_INTERVAL *varbounds, SCIP_Real *param, SCIP_EXPRCURV *curv, SCIP_INTERVAL *bounds)
void SCIPexprgraphGetSubtreeVarsUsage(SCIP_EXPRGRAPH *exprgraph, SCIP_EXPRGRAPHNODE *node, int *varsusage)
struct SCIP_ExprIntData SCIP_EXPRINTDATA
SCIP_RETCODE SCIPexprCreateLinear(BMS_BLKMEM *blkmem, SCIP_EXPR **expr, int nchildren, SCIP_EXPR **children, SCIP_Real *coefs, SCIP_Real constant)
SCIP_Real SCIPexprgraphGetNodeVal(SCIP_EXPRGRAPHNODE *node)
SCIP_RETCODE SCIPexprtreeSetParams(SCIP_EXPRTREE *tree, int nparams, SCIP_Real *paramvals)
SCIP_RETCODE SCIPexprgraphAddVars(SCIP_EXPRGRAPH *exprgraph, int nvars, void **vars, SCIP_EXPRGRAPHNODE **varnodes)
SCIP_Bool SCIPexprgraphIsNodeEnabled(SCIP_EXPRGRAPHNODE *node)
void SCIPexprSortMonomials(SCIP_EXPR *expr)
SCIP_Real * SCIPexprGetQuadLinearCoefs(SCIP_EXPR *expr)
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)
struct SCIP_Expr SCIP_EXPR
Definition: type_expr.h:90
#define SCIP_DECL_EXPRGRAPHVARCHGIDX(x)
Definition: type_expr.h:200
SCIP_INTERVAL SCIPexprgraphGetNodeBounds(SCIP_EXPRGRAPHNODE *node)