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-2023 Zuse Institute Berlin (ZIB) */
7 /* */
8 /* Licensed under the Apache License, Version 2.0 (the "License"); */
9 /* you may not use this file except in compliance with the License. */
10 /* You may obtain a copy of the License at */
11 /* */
12 /* http://www.apache.org/licenses/LICENSE-2.0 */
13 /* */
14 /* Unless required by applicable law or agreed to in writing, software */
15 /* distributed under the License is distributed on an "AS IS" BASIS, */
16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17 /* See the License for the specific language governing permissions and */
18 /* limitations under the License. */
19 /* */
20 /* You should have received a copy of the Apache-2.0 license */
21 /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22 /* */
23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24 
25 /**@file pub_expr.h
26  * @ingroup PUBLICCOREAPI
27  * @brief public functions to work with algebraic expressions
28  * @author Ksenia Bestuzheva
29  * @author Benjamin Mueller
30  * @author Felipe Serrano
31  * @author Stefan Vigerske
32  */
33 
34 #ifndef SCIP_PUB_EXPR_H_
35 #define SCIP_PUB_EXPR_H_
36 
37 #include "scip/def.h"
38 #include "scip/type_expr.h"
39 #include "scip/type_misc.h"
40 
41 #ifdef NDEBUG
42 #include "scip/struct_expr.h"
43 #endif
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 /**@addtogroup PublicExprHandlerMethods
50  * @{
51  */
52 
53 /** set the expression handler callbacks to copy and free an expression handler */
54 SCIP_EXPORT
56  SCIP_EXPRHDLR* exprhdlr, /**< expression handler */
57  SCIP_DECL_EXPRCOPYHDLR((*copyhdlr)), /**< handler copy callback (can be NULL) */
58  SCIP_DECL_EXPRFREEHDLR((*freehdlr)) /**< handler free callback (can be NULL) */
59 );
60 
61 /** set the expression handler callbacks to copy and free expression data */
62 SCIP_EXPORT
64  SCIP_EXPRHDLR* exprhdlr, /**< expression handler */
65  SCIP_DECL_EXPRCOPYDATA((*copydata)), /**< expression data copy callback (can be NULL for expressions without data) */
66  SCIP_DECL_EXPRFREEDATA((*freedata)) /**< expression data free callback (can be NULL if data does not need to be freed) */
67 );
68 
69 /** set the print callback of an expression handler */
70 SCIP_EXPORT
72  SCIP_EXPRHDLR* exprhdlr, /**< expression handler */
73  SCIP_DECL_EXPRPRINT((*print)) /**< print callback (can be NULL) */
74 );
75 
76 /** set the parse callback of an expression handler */
77 SCIP_EXPORT
79  SCIP_EXPRHDLR* exprhdlr, /**< expression handler */
80  SCIP_DECL_EXPRPARSE((*parse)) /**< parse callback (can be NULL) */
81 );
82 
83 /** set the curvature detection callback of an expression handler */
84 SCIP_EXPORT
86  SCIP_EXPRHDLR* exprhdlr, /**< expression handler */
87  SCIP_DECL_EXPRCURVATURE((*curvature)) /**< curvature detection callback (can be NULL) */
88 );
89 
90 /** set the monotonicity detection callback of an expression handler */
91 SCIP_EXPORT
93  SCIP_EXPRHDLR* exprhdlr, /**< expression handler */
94  SCIP_DECL_EXPRMONOTONICITY((*monotonicity)) /**< monotonicity detection callback (can be NULL) */
95 );
96 
97 /** set the integrality detection callback of an expression handler */
98 SCIP_EXPORT
100  SCIP_EXPRHDLR* exprhdlr, /**< expression handler */
101  SCIP_DECL_EXPRINTEGRALITY((*integrality)) /**< integrality detection callback (can be NULL) */
102 );
103 
104 /** set the hash callback of an expression handler */
105 SCIP_EXPORT
107  SCIP_EXPRHDLR* exprhdlr, /**< expression handler */
108  SCIP_DECL_EXPRHASH((*hash)) /**< hash callback (can be NULL) */
109 );
110 
111 /** set the compare callback of an expression handler */
112 SCIP_EXPORT
114  SCIP_EXPRHDLR* exprhdlr, /**< expression handler */
115  SCIP_DECL_EXPRCOMPARE((*compare)) /**< compare callback (can be NULL) */
116 );
117 
118 /** set differentiation callbacks of an expression handler */
119 SCIP_EXPORT
121  SCIP_EXPRHDLR* exprhdlr, /**< expression handler */
122  SCIP_DECL_EXPRBWDIFF((*bwdiff)), /**< backward derivative evaluation callback (can be NULL) */
123  SCIP_DECL_EXPRFWDIFF((*fwdiff)), /**< forward derivative evaluation callback (can be NULL) */
124  SCIP_DECL_EXPRBWFWDIFF((*bwfwdiff)) /**< backward-forward derivative evaluation callback (can be NULL) */
125 );
126 
127 /** set the interval evaluation callback of an expression handler */
128 SCIP_EXPORT
130  SCIP_EXPRHDLR* exprhdlr, /**< expression handler */
131  SCIP_DECL_EXPRINTEVAL((*inteval)) /**< interval evaluation callback (can be NULL) */
132 );
133 
134 /** set the simplify callback of an expression handler */
135 SCIP_EXPORT
137  SCIP_EXPRHDLR* exprhdlr, /**< expression handler */
138  SCIP_DECL_EXPRSIMPLIFY((*simplify)) /**< simplify callback (can be NULL) */
139 );
140 
141 /** set the reverse propagation callback of an expression handler */
142 SCIP_EXPORT
144  SCIP_EXPRHDLR* exprhdlr, /**< expression handler */
145  SCIP_DECL_EXPRREVERSEPROP((*reverseprop)) /**< reverse propagation callback (can be NULL) */
146 );
147 
148 /** set the estimation callbacks of an expression handler */
149 SCIP_EXPORT
151  SCIP_EXPRHDLR* exprhdlr, /**< expression handler */
152  SCIP_DECL_EXPRINITESTIMATES((*initestimates)), /**< initial estimators callback (can be NULL) */
153  SCIP_DECL_EXPRESTIMATE((*estimate)) /**< estimator callback (can be NULL) */
154 );
155 
156 /** gives the name of an expression handler */
157 SCIP_EXPORT
158 const char* SCIPexprhdlrGetName(
159  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
160 );
161 
162 /** gives the description of an expression handler (can be NULL) */
163 SCIP_EXPORT
164 const char* SCIPexprhdlrGetDescription(
165  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
166 );
167 
168 /** gives the precedence of an expression handler */
169 SCIP_EXPORT
170 unsigned int SCIPexprhdlrGetPrecedence(
171  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
172 );
173 
174 /** gives the data of an expression handler */
175 SCIP_EXPORT
177  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
178 );
179 
180 /** returns whether expression handler implements the print callback */
181 SCIP_EXPORT
183  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
184  );
185 
186 /** returns whether expression handler implements the backward differentiation callback */
187 SCIP_EXPORT
189  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
190  );
191 
192 /** returns whether expression handler implements the forward differentiation callback */
193 SCIP_EXPORT
195  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
196  );
197 
198 /** returns whether expression handler implements the interval evaluation callback */
199 SCIP_EXPORT
201  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
202  );
203 
204 /** returns whether expression handler implements the estimator callback */
205 SCIP_EXPORT
207  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
208  );
209 
210 /** returns whether expression handler implements the initial estimators callback */
211 SCIP_EXPORT
213  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
214  );
215 
216 /** returns whether expression handler implements the simplification callback */
217 SCIP_EXPORT
219  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
220  );
221 
222 /** returns whether expression handler implements the curvature callback */
223 SCIP_EXPORT
225  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
226  );
227 
228 /** returns whether expression handler implements the monotonicity callback */
229 SCIP_EXPORT
231  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
232  );
233 
234 /** returns whether expression handler implements the reverse propagation callback */
235 SCIP_EXPORT
237  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
238  );
239 
240 /** compares two expression handler w.r.t. their name */
241 SCIP_EXPORT
242 SCIP_DECL_SORTPTRCOMP(SCIPexprhdlrComp);
243 
244 /**@name Expression Handler Statistics */
245 /**@{ */
246 
247 /** gets number of times an expression has been created with given expression handler */
248 SCIP_EXPORT
249 unsigned int SCIPexprhdlrGetNCreated(
250  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
251  );
252 
253 /** gets number of times the interval evaluation callback was called */
254 SCIP_EXPORT
256  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
257  );
258 
259 /** gets time spend in interval evaluation callback */
260 SCIP_EXPORT
262  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
263  );
264 
265 /** gets number of times the reverse propagation callback was called */
266 SCIP_EXPORT
268  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
269  );
270 
271 /** gets time spend in reverse propagation callback */
272 SCIP_EXPORT
274  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
275  );
276 
277 /** gets number of times an empty interval was found in reverse propagation */
278 SCIP_EXPORT
280  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
281  );
282 
283 /** gets number of times a bound reduction was found in reverse propagation (and accepted by caller) */
284 SCIP_EXPORT
286  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
287  );
288 
289 /** increments the domain reductions count of an expression handler */
290 SCIP_EXPORT
292  SCIP_EXPRHDLR* exprhdlr, /**< expression handler */
293  int nreductions /**< number of reductions to add to counter */
294  );
295 
296 /** gets number of times the estimation callback was called */
297 SCIP_EXPORT
299  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
300  );
301 
302 /** gets time spend in estimation callback */
303 SCIP_EXPORT
305  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
306  );
307 
308 /** gets number of times branching candidates reported by of this expression handler were used to assemble branching candidates
309  *
310  * that is, how often did we consider branching on a child of this expression
311  */
312 SCIP_EXPORT
314  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
315  );
316 
317 /** increments the branching candidates count of an expression handler */
318 SCIP_EXPORT
320  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
321  );
322 
323 /** gets number of times the simplify callback was called */
324 SCIP_EXPORT
326  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
327  );
328 
329 /** gets time spend in simplify callback */
330 SCIP_EXPORT
332  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
333  );
334 
335 /** gets number of times the simplify callback found a simplification */
336 SCIP_EXPORT
338  SCIP_EXPRHDLR* exprhdlr /**< expression handler */
339  );
340 
341 /** @} */ /* expression handler statistics */
342 
343 #ifdef NDEBUG
344 
345 /* If NDEBUG is defined, the function calls are overwritten by defines to reduce the number of function calls and
346  * speed up the algorithms.
347  */
348 
349 #define SCIPexprhdlrSetCopyFreeHdlr(exprhdlr, copyhdlr_, freehdlr_) do { (exprhdlr)->copyhdlr = copyhdlr_; (exprhdlr)->freehdlr = freehdlr_; } while (FALSE)
350 #define SCIPexprhdlrSetCopyFreeData(exprhdlr, copydata_, freedata_) do { (exprhdlr)->copydata = copydata_; (exprhdlr)->freedata = freedata_; } while (FALSE)
351 #define SCIPexprhdlrSetPrint(exprhdlr, print_) (exprhdlr)->print = print_
352 #define SCIPexprhdlrSetParse(exprhdlr, parse_) (exprhdlr)->parse = parse_
353 #define SCIPexprhdlrSetCurvature(exprhdlr, curvature_) (exprhdlr)->curvature = curvature_
354 #define SCIPexprhdlrSetMonotonicity(exprhdlr, monotonicity_) (exprhdlr)->monotonicity = monotonicity_
355 #define SCIPexprhdlrSetIntegrality(exprhdlr, integrality_) (exprhdlr)->integrality = integrality_
356 #define SCIPexprhdlrSetHash(exprhdlr, hash_) (exprhdlr)->hash = hash_
357 #define SCIPexprhdlrSetCompare(exprhdlr, compare_) (exprhdlr)->compare = compare_
358 #define SCIPexprhdlrSetDiff(exprhdlr, bwdiff_, fwdiff_, bwfwdiff_) do { (exprhdlr)->bwdiff = bwdiff_; (exprhdlr)->fwdiff = fwdiff_; (exprhdlr)->bwfwdiff = bwfwdiff_; } while (FALSE)
359 #define SCIPexprhdlrSetIntEval(exprhdlr, inteval_) (exprhdlr)->inteval = inteval_
360 #define SCIPexprhdlrSetSimplify(exprhdlr, simplify_) (exprhdlr)->simplify = simplify_
361 #define SCIPexprhdlrSetReverseProp(exprhdlr, reverseprop_) (exprhdlr)->reverseprop = reverseprop_
362 #define SCIPexprhdlrSetEstimate(exprhdlr, initestimates_, estimate_) do { (exprhdlr)->initestimates = initestimates_; (exprhdlr)->estimate = estimate_; } while (FALSE)
363 #define SCIPexprhdlrGetName(exprhdlr) (exprhdlr)->name
364 #define SCIPexprhdlrGetDescription(exprhdlr) (exprhdlr)->desc
365 #define SCIPexprhdlrGetPrecedence(exprhdlr) (exprhdlr)->precedence
366 #define SCIPexprhdlrGetData(exprhdlr) (exprhdlr)->data
367 #define SCIPexprhdlrHasPrint(exprhdlr) ((exprhdlr)->print != NULL)
368 #define SCIPexprhdlrHasBwdiff(exprhdlr) ((exprhdlr)->bwdiff != NULL)
369 #define SCIPexprhdlrHasFwdiff(exprhdlr) ((exprhdlr)->fwdiff != NULL)
370 #define SCIPexprhdlrHasIntEval(exprhdlr) ((exprhdlr)->inteval != NULL)
371 #define SCIPexprhdlrHasEstimate(exprhdlr) ((exprhdlr)->estimate != NULL)
372 #define SCIPexprhdlrHasInitEstimates(exprhdlr) ((exprhdlr)->initestimates != NULL)
373 #define SCIPexprhdlrHasSimplify(exprhdlr) ((exprhdlr)->simplify != NULL)
374 #define SCIPexprhdlrHasCurvature(exprhdlr) ((exprhdlr)->curvature != NULL)
375 #define SCIPexprhdlrHasMonotonicity(exprhdlr) ((exprhdlr)->monotonicity != NULL)
376 #define SCIPexprhdlrHasReverseProp(exprhdlr) ((exprhdlr)->reverseprop != NULL)
377 #define SCIPexprhdlrGetNCreated(exprhdlr) (exprhdlr)->ncreated
378 #define SCIPexprhdlrGetNIntevalCalls(exprhdlr) (exprhdlr)->nintevalcalls
379 #define SCIPexprhdlrGetIntevalTime(exprhdlr) SCIPclockGetTime((exprhdlr)->intevaltime)
380 #define SCIPexprhdlrGetNReversepropCalls(exprhdlr) (exprhdlr)->npropcalls
381 #define SCIPexprhdlrGetReversepropTime(exprhdlr) SCIPclockGetTime((exprhdlr)->proptime)
382 #define SCIPexprhdlrGetNCutoffs(exprhdlr) (exprhdlr)->ncutoffs
383 #define SCIPexprhdlrGetNDomainReductions(exprhdlr) (exprhdlr)->ndomreds
384 #define SCIPexprhdlrIncrementNDomainReductions(exprhdlr, nreductions) (exprhdlr)->ndomreds += nreductions
385 #define SCIPexprhdlrGetNEstimateCalls(exprhdlr) (exprhdlr)->nestimatecalls
386 #define SCIPexprhdlrGetEstimateTime(exprhdlr) SCIPclockGetTime((exprhdlr)->estimatetime)
387 #define SCIPexprhdlrGetNBranchings(exprhdlr) (exprhdlr)->nbranchscores
388 #define SCIPexprhdlrIncrementNBranchings(exprhdlr) ++(exprhdlr)->nbranchscores
389 #define SCIPexprhdlrGetNSimplifyCalls(exprhdlr) (exprhdlr)->nsimplifycalls
390 #define SCIPexprhdlrGetSimplifyTime(exprhdlr) SCIPclockGetTime((exprhdlr)->simplifytime)
391 #define SCIPexprhdlrGetNSimplifications(exprhdlr) (exprhdlr)->nsimplified
392 #endif
393 
394 
395 /** @} */ /* expression handler methods */
396 
397 /**@defgroup PublicExprMethods Expressions
398  * @ingroup DataStructures
399  * @brief an algebraic expression used for nonlinear constraints and NLPs
400  *
401  *@{
402  */
403 
404 /**@name Expressions */
405 /**@{ */
406 
407 /** gets the number of times the expression is currently captured */
408 SCIP_EXPORT
409 int SCIPexprGetNUses(
410  SCIP_EXPR* expr /**< expression */
411  );
412 
413 /** gives the number of children of an expression */
414 SCIP_EXPORT
416  SCIP_EXPR* expr /**< expression */
417  );
418 
419 /** gives the children of an expression (can be NULL if no children) */
420 SCIP_EXPORT
422  SCIP_EXPR* expr /**< expression */
423  );
424 
425 /** gets the expression handler of an expression
426  *
427  * This identifies the type of the expression (sum, variable, ...).
428  */
429 SCIP_EXPORT
431  SCIP_EXPR* expr /**< expression */
432  );
433 
434 /** gets the expression data of an expression */
435 SCIP_EXPORT
437  SCIP_EXPR* expr /**< expression */
438  );
439 
440 /** sets the expression data of an expression
441  *
442  * The pointer to possible old data is overwritten and the
443  * freedata-callback is not called before.
444  * This function is intended to be used by expression handler only.
445  */
446 SCIP_EXPORT
447 void SCIPexprSetData(
448  SCIP_EXPR* expr, /**< expression */
449  SCIP_EXPRDATA* exprdata /**< expression data to be set (can be NULL) */
450  );
451 
452 /** gets the data that the owner of an expression has stored in an expression */
453 SCIP_EXPORT
455  SCIP_EXPR* expr /**< expression */
456  );
457 
458 /** gives the value from the last evaluation of an expression (or SCIP_INVALID if there was an eval error)
459  *
460  * @see SCIPevalExpr to evaluate the expression at a given solution.
461  */
462 SCIP_EXPORT
464  SCIP_EXPR* expr /**< expression */
465  );
466 
467 /** gives the evaluation tag from the last evaluation, or 0
468  *
469  * @see SCIPevalExpr
470  */
471 SCIP_EXPORT
473  SCIP_EXPR* expr /**< expression */
474  );
475 
476 /** returns the derivative stored in an expression (or SCIP_INVALID if there was an evaluation error)
477  *
478  * @see SCIPevalExprGradient
479  */
480 SCIP_EXPORT
482  SCIP_EXPR* expr /**< expression */
483  );
484 
485 /** gives the value of directional derivative from the last evaluation of a directional derivative of expression
486  * (or SCIP_INVALID if there was an error)
487  *
488  * @see SCIPevalExprHessianDir
489  */
490 SCIP_EXPORT
492  SCIP_EXPR* expr /**< expression */
493  );
494 
495 /** gives the value of directional derivative from the last evaluation of a directional derivative of derivative
496  * of root (or SCIP_INVALID if there was an error)
497  *
498  * @see SCIPevalExprHessianDir
499  */
500 SCIP_EXPORT
502  SCIP_EXPR* expr /**< expression */
503  );
504 
505 /** returns the difftag stored in an expression
506  *
507  * can be used to check whether partial derivative value is valid
508  *
509  * @see SCIPevalExprGradient
510  */
511 SCIP_EXPORT
513  SCIP_EXPR* expr /**< expression */
514  );
515 
516 /** returns the activity that is currently stored for an expression
517  *
518  * @see SCIPevalExprActivity
519  */
520 SCIP_EXPORT
522  SCIP_EXPR* expr /**< expression */
523  );
524 
525 /** returns the tag associated with the activity of the expression
526  *
527  * It can depend on the owner of the expression how to interpret this tag.
528  * SCIPevalExprActivity() compares with `stat->domchgcount`.
529  *
530  * @see SCIPevalExprActivity
531  */
532 SCIP_EXPORT
534  SCIP_EXPR* expr /**< expression */
535  );
536 
537 /** set the activity with tag for an expression */
538 SCIP_EXPORT
540  SCIP_EXPR* expr, /**< expression */
541  SCIP_INTERVAL activity, /**< new activity */
542  SCIP_Longint activitytag /**< tag associated with activity */
543  );
544 
545 /** returns the curvature of an expression
546  *
547  * @note Call SCIPcomputeExprCurvature() before calling this function.
548  */
549 SCIP_EXPORT
551  SCIP_EXPR* expr /**< expression */
552  );
553 
554 /** sets the curvature of an expression */
555 SCIP_EXPORT
557  SCIP_EXPR* expr, /**< expression */
558  SCIP_EXPRCURV curvature /**< curvature of the expression */
559  );
560 
561 /** returns whether an expression is integral */
562 SCIP_EXPORT
564  SCIP_EXPR* expr /**< expression */
565  );
566 
567 /** sets the integrality flag of an expression */
568 SCIP_EXPORT
570  SCIP_EXPR* expr, /**< expression */
571  SCIP_Bool isintegral /**< integrality of the expression */
572  );
573 
574 /** @} */
575 
576 /**@name Quadratic Expressions */
577 /**@{ */
578 
579 /** gives the coefficients and expressions that define a quadratic expression
580  *
581  * It can return the constant part, the number, arguments, and coefficients of the purely linear part
582  * and the number of quadratic terms and bilinear terms.
583  * Note that for arguments that appear in the quadratic part, a linear coefficient is
584  * stored with the quadratic term.
585  * Use SCIPexprGetQuadraticQuadTerm() and SCIPexprGetQuadraticBilinTerm()
586  * to access the data for a quadratic or bilinear term.
587  *
588  * It can also return the eigenvalues and the eigenvectors of the matrix \f$Q\f$ when the quadratic is written
589  * as \f$x^T Q x + b^T x + c^T y + d\f$, where \f$c^T y\f$ defines the purely linear part.
590  * Note, however, that to have access to them one needs to call SCIPcomputeExprQuadraticCurvature()
591  * with `storeeigeninfo=TRUE`. If the eigen information was not stored or it failed to be computed,
592  * `eigenvalues` and `eigenvectors` will be set to NULL.
593  *
594  * This function returns pointers to internal data in linexprs and lincoefs.
595  * The user must not change this data.
596  *
597  * @attention SCIPcheckExprQuadratic() needs to be called first to check whether expression is quadratic and initialize the data of the quadratic representation.
598  */
599 SCIP_EXPORT
601  SCIP_EXPR* expr, /**< quadratic expression */
602  SCIP_Real* constant, /**< buffer to store constant term, or NULL */
603  int* nlinexprs, /**< buffer to store number of expressions that appear linearly, or NULL */
604  SCIP_EXPR*** linexprs, /**< buffer to store pointer to array of expressions that appear linearly, or NULL */
605  SCIP_Real** lincoefs, /**< buffer to store pointer to array of coefficients of expressions that appear linearly, or NULL */
606  int* nquadexprs, /**< buffer to store number of expressions in quadratic terms, or NULL */
607  int* nbilinexprs, /**< buffer to store number of bilinear expressions terms, or NULL */
608  SCIP_Real** eigenvalues, /**< buffer to store pointer to array of eigenvalues of Q, or NULL */
609  SCIP_Real** eigenvectors /**< buffer to store pointer to array of eigenvectors of Q, or NULL */
610  );
611 
612 /** gives the data of a quadratic expression term
613  *
614  * For a term \f$a \cdot \text{expr}^2 + b \cdot \text{expr} + \sum_i (c_i \cdot \text{expr} \cdot \text{otherexpr}_i)\f$, returns
615  * `expr`, \f$a\f$, \f$b\f$, the number of summands, and indices of bilinear terms in the quadratic expressions `bilinexprterms`.
616  *
617  * This function returns pointers to internal data in adjbilin.
618  * The user must not change this data.
619  */
620 SCIP_EXPORT
622  SCIP_EXPR* quadexpr, /**< quadratic expression */
623  int termidx, /**< index of quadratic term */
624  SCIP_EXPR** expr, /**< buffer to store pointer to argument expression (the 'x') of this term, or NULL */
625  SCIP_Real* lincoef, /**< buffer to store linear coefficient of variable, or NULL */
626  SCIP_Real* sqrcoef, /**< buffer to store square coefficient of variable, or NULL */
627  int* nadjbilin, /**< buffer to store number of bilinear terms this variable is involved in, or NULL */
628  int** adjbilin, /**< buffer to store pointer to indices of associated bilinear terms, or NULL */
629  SCIP_EXPR** sqrexpr /**< buffer to store pointer to square expression (the 'x^2') of this term or NULL if no square expression, or NULL */
630  );
631 
632 /** gives the data of a bilinear expression term
633  *
634  * For a term a*expr1*expr2, returns expr1, expr2, a, and
635  * the position of the quadratic expression term that uses expr2 in the quadratic expressions `quadexprterms`.
636  */
637 SCIP_EXPORT
639  SCIP_EXPR* expr, /**< quadratic expression */
640  int termidx, /**< index of bilinear term */
641  SCIP_EXPR** expr1, /**< buffer to store first factor, or NULL */
642  SCIP_EXPR** expr2, /**< buffer to store second factor, or NULL */
643  SCIP_Real* coef, /**< buffer to coefficient, or NULL */
644  int* pos2, /**< buffer to position of expr2 in quadexprterms array of quadratic expression, or NULL */
645  SCIP_EXPR** prodexpr /**< buffer to store pointer to expression that is product if first and second factor, or NULL */
646  );
647 
648 /** returns whether all expressions that are used in a quadratic expression are variable expressions
649  *
650  * @return TRUE iff all `linexprs` and `quadexprterms[.].expr` are variable expressions
651  */
652 SCIP_EXPORT
654  SCIP_EXPR* expr /**< quadratic expression */
655  );
656 
657 /** @} */
658 
659 #ifdef NDEBUG
660 #define SCIPexprGetNUses(expr) (expr)->nuses
661 #define SCIPexprGetNChildren(expr) (expr)->nchildren
662 #define SCIPexprGetChildren(expr) (expr)->children
663 #define SCIPexprGetHdlr(expr) (expr)->exprhdlr
664 #define SCIPexprGetData(expr) (expr)->exprdata
665 #define SCIPexprSetData(expr, exprdata_) (expr)->exprdata = exprdata_
666 #define SCIPexprGetOwnerData(expr) (expr)->ownerdata
667 #define SCIPexprGetEvalValue(expr) (expr)->evalvalue
668 #define SCIPexprGetEvalTag(expr) (expr)->evaltag
669 #define SCIPexprGetDerivative(expr) (expr)->derivative
670 #define SCIPexprGetDot(expr) (expr)->dot
671 #define SCIPexprGetBardot(expr) (expr)->bardot
672 #define SCIPexprGetDiffTag(expr) (expr)->difftag
673 #define SCIPexprGetActivity(expr) (expr)->activity
674 #define SCIPexprGetActivityTag(expr) (expr)->activitytag
675 #define SCIPexprSetActivity(expr, activity_, activitytag_) do { (expr)->activity = activity_; (expr)->activitytag = activitytag_; } while (FALSE)
676 #define SCIPexprGetCurvature(expr) (expr)->curvature
677 #define SCIPexprSetCurvature(expr, curvature_) (expr)->curvature = curvature_
678 #define SCIPexprIsIntegral(expr) (expr)->isintegral
679 #define SCIPexprSetIntegrality(expr, isintegral_) expr->isintegral = isintegral_
680 #define SCIPexprAreQuadraticExprsVariables(expr) (expr)->quaddata->allexprsarevars
681 #endif
682 
683 /**@name Core Expression Handlers */
684 /**@{ */
685 /* these are here to have them accessible also in the expr core
686  * so these cannot make use of SCIP pointer
687  */
688 
689 /** gets the variable of a variable expression */
690 SCIP_EXPORT
692  SCIP_EXPR* expr /**< var expression */
693  );
694 
695 /** gets the value of a constant value expression */
696 SCIP_EXPORT
698  SCIP_EXPR* expr /**< value expression */
699  );
700 
701 /** gets the coefficients of a summation expression */
702 SCIP_EXPORT
704  SCIP_EXPR* expr /**< sum expression */
705  );
706 
707 /** gets the constant of a summation expression */
708 SCIP_EXPORT
710  SCIP_EXPR* expr /**< sum expression */
711  );
712 
713 /** gets the constant coefficient of a product expression */
714 SCIP_EXPORT
716  SCIP_EXPR* expr /**< product expression */
717  );
718 
719 /** gets the exponent of a power or signed power expression */
720 SCIP_EXPORT
722  SCIP_EXPR* expr /**< (signed) power expression */
723  );
724 
725 #ifdef NDEBUG
726 #define SCIPgetVarExprVar(expr) ((SCIP_VAR*)SCIPexprGetData(expr))
727 #endif
728 
729 /**@} */
730 
731 
732 /**@name Expression Iterator
733  *
734  * @anchor SCIP_EXPRITER_DFS
735  * More details on the DFS mode:
736  * Many algorithms over expression trees need to traverse the tree in depth-first manner and a
737  * natural way of implementing these algorithms is by using recursion.
738  * In general, a function which traverses the tree in depth-first looks like
739  * <pre>
740  * fun( expr )
741  * enterexpr()
742  * continue skip or abort
743  * for( child in expr->children )
744  * visitingchild()
745  * continue skip or abort
746  * fun(child, data, proceed)
747  * visitedchild()
748  * continue skip or abort
749  * leaveexpr()
750  * </pre>
751  * Given that some expressions might be quite deep we provide this functionality in an iterative fashion.
752  *
753  * Consider an expression (x*y) + z + log(x-y).
754  * The corresponding expression graph is
755  * <pre>
756  * [+]
757  * / | \
758  * [*] | [log]
759  * / \ | |
760  * / \ | [-]
761  * | | | / \
762  * [x] [y] [z] [x] [y]
763  * </pre>
764  * (where [x] and [y] are actually the same expression).
765  *
766  * If a pointer to the [+] expression is given as root to this expression, it will iterate
767  * the graph in a depth-first manner and stop at various stages.
768  * - When entering an expression, it stops in the \ref SCIP_EXPRITER_ENTEREXPR stage.
769  * The SCIPexpriterGetParentDFS() function indicates from where the expression has been entered (NULL for the root expression).
770  * - Before visiting a child of an expression, it stops in the \ref SCIP_EXPRITER_VISITINGCHILD stage.
771  * The SCIPexpriterGetChildIdxDFS() function returns which child will be visited (as an index in the current expr's children array).
772  * Use SCIPexpriterGetChildExprDFS() to obtain the corresponding expression.
773  * - When returning from visiting a child of an expression, it stops in the \ref SCIP_EXPRITER_VISITEDCHILD stage.
774  * Again the SCIPexpriterGetChildExprDFS() function returns which child has been visited.
775  * - When leaving an expression, it stops in the \ref SCIP_EXPRITER_LEAVEEXPR stage.
776  *
777  * Thus, for the above expression, the expression are visited in the following order and stages:
778  * - `enterexpr([+])`
779  * - `visitingchild([+])`, currentchild = 0
780  * - `enterexpr([*])`
781  * - `visitingchild([*])`, currentchild = 0
782  * - `enterexpr([x])`
783  * - `leaveexpr([x])`
784  * - `visitedchild([*])`, currentchild = 0
785  * - `visitingchild([*])`, currentchild = 1
786  * - `enterexpr([y])`
787  * - `leaveexpr([y])`
788  * - `visitedchild([*])`, currentchild = 1
789  * - `leaveexpr([*])`
790  * - `visitedchild([+])`, currentchild = 0
791  * - `visitingchild([+])`, currentchild = 1
792  * - `enterexpr([z])`
793  * - `leaveexpr([z])`
794  * - `visitedchild([+])`, currentchild = 1
795  * - `visitingchild([+])`, currentchild = 2
796  * - `enterexpr([log])`
797  * - `visitingchild([log])`, currentchild = 0
798  * - `enterexpr([-])`
799  * - `visitingchild([-])`, currentchild = 0
800  * - `enterexpr([x])`
801  * - `leaveexpr([x])`
802  * - `visitedchild([-])`, currentchild = 0
803  * - `visitingchild([-])`, currentchild = 1
804  * - `enterexpr([y])`
805  * - `leaveexpr([y])`
806  * - `visitedchild([-])`, currentchild = 1
807  * - `leaveexpr([-])`
808  * - `visitedchild([log])`, currentchild = 0
809  * - `leaveexpr([log])`
810  * - `visitedchild([+])` currentchild = 2
811  * - `leaveexpr([+])`
812  *
813  * The caller can direct the iterator to skip parts of the tree:
814  * - If calling SCIPexpriterSkipDFS() in SCIP_EXPRITER_ENTEREXPR stage, all children of that expression will be skipped. The SCIP_EXPRITER_LEAVEEXPR stage will still be next.
815  * - If calling SCIPexpriterSkipDFS() in SCIP_EXPRITER_VISITINGCHILD stage, visiting the current child will be skipped.
816  * - If calling SCIPexpriterSkipDFS() in SCIP_EXPRITER_VISITEDCHILD child, visiting the remaining children will be skipped.
817  *
818  * @{
819  */
820 
821 /** returns whether expression iterator is currently initialized */
822 SCIP_EXPORT
824  SCIP_EXPRITER* iterator /**< expression iterator */
825  );
826 
827 /** initializes an expression iterator
828  *
829  * @note If `expr` is NULL, then iterator will be set into ended-state (SCIPexpriterIsEnd() is TRUE). Useful if following with SCIPexpriterRestartDFS().
830  *
831  * If type is DFS, then `stopstages` will be set to \ref SCIP_EXPRITER_ENTEREXPR.
832  * Use `SCIPexpriterSetStagesDFS` to change this.
833  */
834 SCIP_EXPORT
836  SCIP_EXPRITER* iterator, /**< expression iterator */
837  SCIP_EXPR* expr, /**< expression of the iterator, can be NULL */
838  SCIP_EXPRITER_TYPE type, /**< type of expression iterator */
839  SCIP_Bool allowrevisit /**< whether expression are allowed to be visited more than once */
840  );
841 
842 /** restarts an already initialized expression iterator in DFS mode
843  *
844  * The expression iterator will continue from the given expression, not revisiting expressions that
845  * this iterator has already been visited (if initialized with `allowrevisit=FALSE`) and giving access
846  * to the same iterator specified expression data that may have been set already.
847  * Also the stop-stages are not reset.
848  *
849  * If revisiting is forbidden and given expr has already been visited, then the iterator will behave
850  * as on the end of iteration (SCIPexpriterIsEnd() is TRUE).
851  * If the enterexpr stage is not one of the stop stages, then the iterator will be moved forward
852  * (SCIPexpriterGetNext() is called).
853  *
854  * @return The current expression.
855  */
856 SCIP_EXPORT
858  SCIP_EXPRITER* iterator, /**< expression iterator */
859  SCIP_EXPR* expr /**< expression of the iterator */
860  );
861 
862 /** specifies in which stages to stop a DFS iterator
863  *
864  * Parameter `stopstages` should be a bitwise OR of different \ref SCIP_EXPRITER_STAGE values
865  *
866  * If the current stage is not one of the `stopstages`, then the iterator will be moved on.
867  */
868 SCIP_EXPORT
870  SCIP_EXPRITER* iterator, /**< expression iterator */
871  SCIP_EXPRITER_STAGE stopstages /**< the stages in which to stop when iterating via DFS */
872  );
873 
874 /** gets the current expression that the expression iterator points to */
875 SCIP_EXPORT
877  SCIP_EXPRITER* iterator /**< expression iterator */
878  );
879 
880 /** gets the current stage that the expression iterator is in when using DFS
881  *
882  * If the iterator has finished (SCIPexpriterIsEnd() is TRUE), then the stage is undefined.
883  */
884 SCIP_EXPORT
886  SCIP_EXPRITER* iterator /**< expression iterator */
887  );
888 
889 /** gets the index of the child that the expression iterator considers when in DFS mode and stage \ref SCIP_EXPRITER_VISITINGCHILD or \ref SCIP_EXPRITER_VISITEDCHILD */
890 SCIP_EXPORT
892  SCIP_EXPRITER* iterator /**< expression iterator */
893  );
894 
895 /** gets the child expression that the expression iterator considers when in DFS mode and stage \ref SCIP_EXPRITER_VISITINGCHILD or \ref SCIP_EXPRITER_VISITEDCHILD */
896 SCIP_EXPORT
898  SCIP_EXPRITER* iterator /**< expression iterator */
899  );
900 
901 /** gives the parent of the current expression of an expression iteration if in DFS mode
902  *
903  * @return the expression from which the current expression has been accessed
904  */
905 SCIP_EXPORT
907  SCIP_EXPRITER* iterator /**< expression iterator */
908  );
909 
910 /** gives the iterator specific user data of the current expression
911  *
912  * @note The expression iterator mode must be DFS or another mode with allowrevisit=FALSE
913  */
914 SCIP_EXPORT
916  SCIP_EXPRITER* iterator /**< expression iterator */
917  );
918 
919 /** gives the iterator specific user data of the current expressions current child
920  *
921  * @note The expression iterator mode must be in DFS mode and stage \ref SCIP_EXPRITER_VISITINGCHILD or \ref SCIP_EXPRITER_VISITEDCHILD
922  */
923 SCIP_EXPORT
925  SCIP_EXPRITER* iterator /**< expression iterator */
926  );
927 
928 /** gives the iterator specific user data of a given expression
929  *
930  * @note The expression iterator mode must be DFS or another mode with allowrevisit=FALSE
931  */
932 SCIP_EXPORT
934  SCIP_EXPRITER* iterator, /**< expression iterator */
935  SCIP_EXPR* expr /**< expression for which to get the userdata of this iterator */
936  );
937 
938 /** sets the iterator specific user data of the current expression for an expression iteration if in DFS mode
939  *
940  * @note The expression iterator mode must be DFS or another mode with allowrevisit=FALSE
941  */
942 SCIP_EXPORT
944  SCIP_EXPRITER* iterator, /**< expression iterator */
945  SCIP_EXPRITER_USERDATA userdata /**< data to be stored */
946  );
947 
948 /** sets the iterator specific user data of a given expression
949  *
950  * @note The expression iterator mode must be DFS or another mode with allowrevisit=FALSE
951  */
952 SCIP_EXPORT
954  SCIP_EXPRITER* iterator, /**< expression iterator */
955  SCIP_EXPR* expr, /**< expression where to set iterator data */
956  SCIP_EXPRITER_USERDATA userdata /**< data to be stored in current child */
957  );
958 
959 /** sets the iterator specific user data of the current expressions current child
960  *
961  * @note The expression iterator mode must be in DFS mode and stage \ref SCIP_EXPRITER_VISITINGCHILD or \ref SCIP_EXPRITER_VISITEDCHILD
962  */
963 SCIP_EXPORT
965  SCIP_EXPRITER* iterator, /**< expression iterator */
966  SCIP_EXPRITER_USERDATA userdata /**< data to be stored in current child */
967  );
968 
969 /** moves the iterator to the next expression according to the mode of the expression iterator
970  *
971  * @return the next expression, if any, and NULL otherwise
972  */
973 SCIP_EXPORT
975  SCIP_EXPRITER* iterator /**< expression iterator */
976  );
977 
978 /** moves a DFS iterator to one of the next expressions
979  *
980  * - If in \ref SCIP_EXPRITER_ENTEREXPR stage, then all children of that expression will be skipped.
981  * If \ref SCIP_EXPRITER_LEAVEEXPR is one of the `stopstages`, then it will be the next stage. Otherwise, the iterator will move further on (go to the parent, etc).
982  * - If in \ref SCIP_EXPRITER_VISITINGCHILD stage, then the child that was going to be visited next will be skipped and the iterator will be moved on to the next child (if any).
983  * - If in \ref SCIP_EXPRITER_VISITEDCHILD stage, then all remaining children will be skipped and we move on to the \ref SCIP_EXPRITER_LEAVEEXPR stage (if a stop stage, otherwise further on).
984  * - It is not allowed to call this function when in \ref SCIP_EXPRITER_LEAVEEXPR stage.
985  *
986  * @return the next expression, if any, and NULL otherwise
987  */
988 SCIP_EXPORT
990  SCIP_EXPRITER* iterator /**< expression iterator */
991  );
992 
993 /** returns whether the iterator visited all expressions already */
994 SCIP_EXPORT
996  SCIP_EXPRITER* iterator /**< expression iterator */
997  );
998 
999 #ifdef NDEBUG
1000 #define SCIPexpriterIsInit(iterator) (iterator)->initialized
1001 #define SCIPexpriterGetCurrent(iterator) (iterator)->curr
1002 #define SCIPexpriterGetStageDFS(iterator) (iterator)->dfsstage
1003 #define SCIPexpriterGetChildIdxDFS(iterator) (iterator)->curr->iterdata[(iterator)->iterindex].currentchild
1004 #define SCIPexpriterGetChildExprDFS(iterator) (iterator)->curr->children[(iterator)->curr->iterdata[(iterator)->iterindex].currentchild]
1005 #define SCIPexpriterGetParentDFS(iterator) (iterator)->curr->iterdata[(iterator)->iterindex].parent
1006 #define SCIPexpriterGetCurrentUserData(iterator) (iterator)->curr->iterdata[(iterator)->iterindex].userdata
1007 #define SCIPexpriterGetChildUserDataDFS(iterator) (iterator)->curr->children[(iterator)->curr->iterdata[(iterator)->iterindex].currentchild]->iterdata[(iterator)->iterindex].userdata
1008 #define SCIPexpriterGetExprUserData(iterator, expr) (expr)->iterdata[(iterator)->iterindex].userdata
1009 #define SCIPexpriterSetCurrentUserData(iterator, userdata_) (iterator)->curr->iterdata[(iterator)->iterindex].userdata = userdata_
1010 #define SCIPexpriterSetExprUserData(iterator, expr, userdata_) (expr)->iterdata[(iterator)->iterindex].userdata = userdata_
1011 #define SCIPexpriterSetChildUserData(iterator, userdata_) (iterator)->curr->children[(iterator)->curr->iterdata[(iterator)->iterindex].currentchild]->iterdata[(iterator)->iterindex].userdata = userdata_
1012 #define SCIPexpriterIsEnd(iterator) ((iterator)->curr == NULL)
1013 #endif
1014 
1015 /** @} */
1016 
1017 /**@name Function Curvature */
1018 /**@{ */
1019 
1020 /** gives curvature for a sum of two functions with given curvature */
1021 SCIP_EXPORT
1023  SCIP_EXPRCURV curv1, /**< curvature of first summand */
1024  SCIP_EXPRCURV curv2 /**< curvature of second summand */
1025  );
1026 
1027 /** gives the curvature for the negation of a function with given curvature */
1028 SCIP_EXPORT
1030  SCIP_EXPRCURV curvature /**< curvature of function */
1031  );
1032 
1033 /** gives curvature for a functions with given curvature multiplied by a constant factor */
1034 SCIP_EXPORT
1036  SCIP_Real factor, /**< constant factor */
1037  SCIP_EXPRCURV curvature /**< curvature of other factor */
1038  );
1039 
1040 /** gives curvature for base^exponent for given bounds and curvature of base-function and constant exponent */
1041 SCIP_EXPORT
1043  SCIP_INTERVAL basebounds, /**< bounds on base function */
1044  SCIP_EXPRCURV basecurv, /**< curvature of base function */
1045  SCIP_Real exponent /**< exponent */
1046  );
1047 
1048 /** gives required curvature for base so that base^exponent has given curvature under given bounds on base and constant exponent
1049  *
1050  * returns curvature unknown if expected curvature cannot be obtained
1051  */
1052 SCIP_EXPORT
1054  SCIP_INTERVAL basebounds, /**< bounds on base function */
1055  SCIP_Real exponent, /**< exponent, must not be 0 */
1056  SCIP_EXPRCURV powercurv /**< expected curvature for power */
1057  );
1058 
1059 /** gives curvature for a monomial with given curvatures and bounds for each factor
1060  *
1061  * See Maranas and Floudas, Finding All Solutions of Nonlinearly Constrained Systems of Equations, JOGO 7, 1995
1062  * for the categorization in the case that all factors are linear.
1063  *
1064  * Exponents can also be negative or rational.
1065  */
1066 SCIP_EXPORT
1068  int nfactors, /**< number of factors in monomial */
1069  SCIP_Real* exponents, /**< exponents in monomial, or NULL if all 1.0 */
1070  int* factoridxs, /**< indices of factors, or NULL if identity mapping */
1071  SCIP_EXPRCURV* factorcurv, /**< curvature of each factor */
1072  SCIP_INTERVAL* factorbounds /**< bounds of each factor */
1073  );
1074 
1075 /** for a monomial with given bounds for each factor, gives condition on the curvature of each factor, so that monomial has a requested curvature, if possible
1076  *
1077  * @return whether `monomialcurv` can be achieved
1078  */
1079 SCIP_EXPORT
1081  SCIP_EXPRCURV monomialcurv, /**< desired curvature */
1082  int nfactors, /**< number of factors in monomial */
1083  SCIP_Real* exponents, /**< exponents in monomial, or NULL if all 1.0 */
1084  SCIP_INTERVAL* factorbounds, /**< bounds of each factor */
1085  SCIP_EXPRCURV* factorcurv /**< buffer to store required curvature of each factor */
1086  );
1087 
1088 /** gives name as string for a curvature */
1089 SCIP_EXPORT
1090 const char* SCIPexprcurvGetName(
1091  SCIP_EXPRCURV curv /**< curvature */
1092  );
1093 
1094 #ifdef NDEBUG
1095 #define SCIPexprcurvAdd(curv1, curv2) ((SCIP_EXPRCURV) ((curv1) & (curv2)))
1096 #define SCIPexprcurvNegate(curvature) (((curvature) == SCIP_EXPRCURV_CONCAVE) ? SCIP_EXPRCURV_CONVEX : ((curvature) == SCIP_EXPRCURV_CONVEX) ? SCIP_EXPRCURV_CONCAVE : (curvature))
1097 #define SCIPexprcurvMultiply(factor, curvature) (((factor) == 0.0) ? SCIP_EXPRCURV_LINEAR : (factor) > 0.0 ? (curvature) : SCIPexprcurvNegate(curvature))
1098 #endif
1099 
1100 /**@} */
1101 
1102 /**@} */
1103 
1104 #ifdef __cplusplus
1105 }
1106 #endif
1107 
1108 #endif /* SCIP_PUB_EXPR_H_ */
SCIP_Longint SCIPexprhdlrGetNSimplifyCalls(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:806
SCIP_Longint SCIPexprhdlrGetNEstimateCalls(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:762
void SCIPexprGetQuadraticData(SCIP_EXPR *expr, SCIP_Real *constant, int *nlinexprs, SCIP_EXPR ***linexprs, SCIP_Real **lincoefs, int *nquadexprs, int *nbilinexprs, SCIP_Real **eigenvalues, SCIP_Real **eigenvectors)
Definition: expr.c:4067
const char * SCIPexprcurvGetName(SCIP_EXPRCURV curv)
Definition: exprcurv.c:585
SCIP_RETCODE SCIPexpriterInit(SCIP_EXPRITER *iterator, SCIP_EXPR *expr, SCIP_EXPRITER_TYPE type, SCIP_Bool allowrevisit)
Definition: expriter.c:500
SCIP_EXPR_OWNERDATA * SCIPexprGetOwnerData(SCIP_EXPR *expr)
Definition: expr.c:3869
void SCIPexprSetIntegrality(SCIP_EXPR *expr, SCIP_Bool isintegral)
Definition: expr.c:4037
#define SCIP_DECL_EXPRPRINT(x)
Definition: type_expr.h:286
#define SCIP_DECL_EXPRMONOTONICITY(x)
Definition: type_expr.h:355
SCIP_Bool SCIPexprhdlrHasFwdiff(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:594
type definitions for miscellaneous datastructures
int SCIPexprGetNChildren(SCIP_EXPR *expr)
Definition: expr.c:3808
SCIP_EXPR * SCIPexpriterGetParentDFS(SCIP_EXPRITER *iterator)
Definition: expriter.c:739
#define SCIP_DECL_EXPRINITESTIMATES(x)
Definition: type_expr.h:605
void SCIPexprhdlrSetDiff(SCIP_EXPRHDLR *exprhdlr, SCIP_DECL_EXPRBWDIFF((*bwdiff)), SCIP_DECL_EXPRFWDIFF((*fwdiff)), SCIP_DECL_EXPRBWFWDIFF((*bwfwdiff)))
Definition: expr.c:473
const char * SCIPexprhdlrGetName(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:534
SCIP_Real SCIPgetConstantExprSum(SCIP_EXPR *expr)
Definition: expr_sum.c:1181
SCIP_EXPR * SCIPexpriterSkipDFS(SCIP_EXPRITER *iterator)
Definition: expriter.c:929
SCIP_EXPRCURV SCIPexprcurvNegate(SCIP_EXPRCURV curvature)
Definition: exprcurv.c:61
#define SCIP_DECL_EXPRFWDIFF(x)
Definition: type_expr.h:477
#define SCIP_DECL_EXPRREVERSEPROP(x)
Definition: type_expr.h:654
void SCIPexprhdlrSetParse(SCIP_EXPRHDLR *exprhdlr, SCIP_DECL_EXPRPARSE((*parse)))
Definition: expr.c:407
structure definitions related to algebraic expressions
SCIP_EXPRHDLRDATA * SCIPexprhdlrGetData(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:564
SCIP_Bool SCIPexprhdlrHasPrint(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:574
void SCIPexprSetCurvature(SCIP_EXPR *expr, SCIP_EXPRCURV curvature)
Definition: expr.c:4016
SCIP_Bool SCIPexprhdlrHasBwdiff(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:584
struct SCIP_ExprData SCIP_EXPRDATA
Definition: type_expr.h:53
SCIP_EXPRCURV SCIPexprcurvPower(SCIP_INTERVAL basebounds, SCIP_EXPRCURV basecurv, SCIP_Real exponent)
Definition: exprcurv.c:100
SCIP_Real SCIPgetExponentExprPow(SCIP_EXPR *expr)
Definition: expr_pow.c:3352
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
SCIP_Real SCIPexprhdlrGetEstimateTime(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:772
SCIP_EXPRITER_TYPE
Definition: type_expr.h:696
void SCIPexpriterSetChildUserData(SCIP_EXPRITER *iterator, SCIP_EXPRITER_USERDATA userdata)
Definition: expriter.c:837
SCIP_Bool SCIPexpriterIsInit(SCIP_EXPRITER *iterator)
Definition: expriter.c:484
void SCIPexprhdlrSetHash(SCIP_EXPRHDLR *exprhdlr, SCIP_DECL_EXPRHASH((*hash)))
Definition: expr.c:451
SCIP_INTERVAL SCIPexprGetActivity(SCIP_EXPR *expr)
Definition: expr.c:3964
SCIP_EXPRITER_USERDATA SCIPexpriterGetChildUserDataDFS(SCIP_EXPRITER *iterator)
Definition: expriter.c:770
void SCIPexprhdlrSetIntegrality(SCIP_EXPRHDLR *exprhdlr, SCIP_DECL_EXPRINTEGRALITY((*integrality)))
Definition: expr.c:440
SCIP_Real SCIPexprhdlrGetSimplifyTime(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:816
SCIP_EXPRITER_USERDATA SCIPexpriterGetCurrentUserData(SCIP_EXPRITER *iterator)
Definition: expriter.c:755
SCIP_Real SCIPexprhdlrGetIntevalTime(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:700
#define SCIP_DECL_EXPRFREEDATA(x)
Definition: type_expr.h:265
SCIP_Bool SCIPexprAreQuadraticExprsVariables(SCIP_EXPR *expr)
Definition: expr.c:4195
SCIP_EXPR * SCIPexpriterGetCurrent(SCIP_EXPRITER *iterator)
Definition: expriter.c:682
struct SCIP_Expr_OwnerData SCIP_EXPR_OWNERDATA
Definition: type_expr.h:77
SCIP_EXPRCURV SCIPexprcurvPowerInv(SCIP_INTERVAL basebounds, SCIP_Real exponent, SCIP_EXPRCURV powercurv)
Definition: exprcurv.c:208
SCIP_EXPRITER_USERDATA SCIPexpriterGetExprUserData(SCIP_EXPRITER *iterator, SCIP_EXPR *expr)
Definition: expriter.c:789
SCIP_EXPRDATA * SCIPexprGetData(SCIP_EXPR *expr)
Definition: expr.c:3841
SCIP_EXPR ** SCIPexprGetChildren(SCIP_EXPR *expr)
Definition: expr.c:3818
SCIP_Real * SCIPgetCoefsExprSum(SCIP_EXPR *expr)
Definition: expr_sum.c:1166
#define SCIP_DECL_EXPRPARSE(x)
Definition: type_expr.h:309
SCIP_Longint SCIPexprGetActivityTag(SCIP_EXPR *expr)
Definition: expr.c:3980
SCIP_Real SCIPexprGetEvalValue(SCIP_EXPR *expr)
Definition: expr.c:3882
SCIP_Real SCIPexprGetDerivative(SCIP_EXPR *expr)
Definition: expr.c:3908
SCIP_Bool SCIPexprhdlrHasMonotonicity(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:654
SCIP_VAR * SCIPgetVarExprVar(SCIP_EXPR *expr)
Definition: expr_var.c:416
SCIP_Longint SCIPexprhdlrGetNSimplifications(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:826
SCIP_Bool SCIPexprhdlrHasEstimate(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:614
void SCIPexprGetQuadraticQuadTerm(SCIP_EXPR *quadexpr, int termidx, SCIP_EXPR **expr, SCIP_Real *lincoef, SCIP_Real *sqrcoef, int *nadjbilin, int **adjbilin, SCIP_EXPR **sqrexpr)
Definition: expr.c:4114
SCIP_EXPRCURV SCIPexprcurvAdd(SCIP_EXPRCURV curv1, SCIP_EXPRCURV curv2)
Definition: exprcurv.c:52
SCIP_Real SCIPexprGetBardot(SCIP_EXPR *expr)
Definition: expr.c:3936
SCIP_Longint SCIPexprGetDiffTag(SCIP_EXPR *expr)
Definition: expr.c:3951
SCIP_Real SCIPexprGetDot(SCIP_EXPR *expr)
Definition: expr.c:3922
#define SCIP_DECL_EXPRFREEHDLR(x)
Definition: type_expr.h:221
int SCIPexpriterGetChildIdxDFS(SCIP_EXPRITER *iterator)
Definition: expriter.c:706
SCIP_Bool SCIPexprhdlrHasCurvature(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:644
SCIP_Longint SCIPexprGetEvalTag(SCIP_EXPR *expr)
Definition: expr.c:3895
SCIP_Bool SCIPexprhdlrHasIntEval(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:604
void SCIPexprhdlrSetCopyFreeHdlr(SCIP_EXPRHDLR *exprhdlr, SCIP_DECL_EXPRCOPYHDLR((*copyhdlr)), SCIP_DECL_EXPRFREEHDLR((*freehdlr)))
Definition: expr.c:368
SCIP_EXPRCURV SCIPexprGetCurvature(SCIP_EXPR *expr)
Definition: expr.c:4006
SCIP_Real SCIPgetCoefExprProduct(SCIP_EXPR *expr)
#define SCIP_DECL_EXPRINTEVAL(x)
Definition: type_expr.h:536
#define SCIP_Bool
Definition: def.h:93
SCIP_EXPR * SCIPexpriterRestartDFS(SCIP_EXPRITER *iterator, SCIP_EXPR *expr)
Definition: expriter.c:629
SCIP_Bool SCIPexprhdlrHasReverseProp(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:664
SCIP_EXPRCURV
Definition: type_expr.h:57
void SCIPexprhdlrSetMonotonicity(SCIP_EXPRHDLR *exprhdlr, SCIP_DECL_EXPRMONOTONICITY((*monotonicity)))
Definition: expr.c:429
SCIP_Longint SCIPexprhdlrGetNCutoffs(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:730
void SCIPexpriterSetExprUserData(SCIP_EXPRITER *iterator, SCIP_EXPR *expr, SCIP_EXPRITER_USERDATA userdata)
Definition: expriter.c:821
#define SCIP_DECL_EXPRINTEGRALITY(x)
Definition: type_expr.h:372
#define SCIP_DECL_EXPRBWDIFF(x)
Definition: type_expr.h:446
SCIP_Bool SCIPexprcurvMonomialInv(SCIP_EXPRCURV monomialcurv, int nfactors, SCIP_Real *exponents, SCIP_INTERVAL *factorbounds, SCIP_EXPRCURV *factorcurv)
Definition: exprcurv.c:456
void SCIPexprhdlrSetReverseProp(SCIP_EXPRHDLR *exprhdlr, SCIP_DECL_EXPRREVERSEPROP((*reverseprop)))
Definition: expr.c:510
SCIP_Longint SCIPexprhdlrGetNDomainReductions(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:740
SCIP_Bool SCIPexprIsIntegral(SCIP_EXPR *expr)
Definition: expr.c:4027
SCIP_EXPRCURV SCIPexprcurvMonomial(int nfactors, SCIP_Real *exponents, int *factoridxs, SCIP_EXPRCURV *factorcurv, SCIP_INTERVAL *factorbounds)
Definition: exprcurv.c:330
SCIP_EXPR * SCIPexpriterGetNext(SCIP_EXPRITER *iterator)
Definition: expriter.c:857
SCIP_EXPR * SCIPexpriterGetChildExprDFS(SCIP_EXPRITER *iterator)
Definition: expriter.c:720
struct SCIP_ExprhdlrData SCIP_EXPRHDLRDATA
Definition: type_expr.h:192
SCIP_EXPRHDLR * SCIPexprGetHdlr(SCIP_EXPR *expr)
Definition: expr.c:3831
void SCIPexprhdlrSetPrint(SCIP_EXPRHDLR *exprhdlr, SCIP_DECL_EXPRPRINT((*print)))
Definition: expr.c:396
void SCIPexprhdlrSetCopyFreeData(SCIP_EXPRHDLR *exprhdlr, SCIP_DECL_EXPRCOPYDATA((*copydata)), SCIP_DECL_EXPRFREEDATA((*freedata)))
Definition: expr.c:381
#define SCIP_DECL_EXPRCURVATURE(x)
Definition: type_expr.h:337
void SCIPexpriterSetStagesDFS(SCIP_EXPRITER *iterator, SCIP_EXPRITER_STAGE stopstages)
Definition: expriter.c:663
SCIP_Longint SCIPexprhdlrGetNIntevalCalls(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:690
#define SCIP_DECL_EXPRCOMPARE(x)
Definition: type_expr.h:407
void SCIPexprhdlrSetCompare(SCIP_EXPRHDLR *exprhdlr, SCIP_DECL_EXPRCOMPARE((*compare)))
Definition: expr.c:462
#define SCIP_DECL_EXPRSIMPLIFY(x)
Definition: type_expr.h:629
SCIP_Longint SCIPexprhdlrGetNReversepropCalls(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:710
unsigned int SCIPexprhdlrGetPrecedence(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:554
void SCIPexprhdlrSetCurvature(SCIP_EXPRHDLR *exprhdlr, SCIP_DECL_EXPRCURVATURE((*curvature)))
Definition: expr.c:418
void SCIPexprSetData(SCIP_EXPR *expr, SCIP_EXPRDATA *exprdata)
Definition: expr.c:3856
#define SCIP_DECL_SORTPTRCOMP(x)
Definition: type_misc.h:188
SCIP_Bool SCIPexprhdlrHasInitEstimates(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:624
void SCIPexprhdlrIncrementNDomainReductions(SCIP_EXPRHDLR *exprhdlr, int nreductions)
Definition: expr.c:750
type and macro definitions related to algebraic expressions
SCIP_EXPRITER_STAGE SCIPexpriterGetStageDFS(SCIP_EXPRITER *iterator)
Definition: expriter.c:695
void SCIPexpriterSetCurrentUserData(SCIP_EXPRITER *iterator, SCIP_EXPRITER_USERDATA userdata)
Definition: expriter.c:805
SCIP_Longint SCIPexprhdlrGetNBranchings(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:786
void SCIPexprGetQuadraticBilinTerm(SCIP_EXPR *expr, int termidx, SCIP_EXPR **expr1, SCIP_EXPR **expr2, SCIP_Real *coef, int *pos2, SCIP_EXPR **prodexpr)
Definition: expr.c:4157
#define SCIP_DECL_EXPRESTIMATE(x)
Definition: type_expr.h:572
#define SCIP_Real
Definition: def.h:186
void SCIPexprSetActivity(SCIP_EXPR *expr, SCIP_INTERVAL activity, SCIP_Longint activitytag)
Definition: expr.c:3990
SCIP_Real SCIPgetValueExprValue(SCIP_EXPR *expr)
Definition: expr_value.c:294
unsigned int SCIPexprhdlrGetNCreated(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:680
#define SCIP_Longint
Definition: def.h:171
SCIP_Real SCIPexprhdlrGetReversepropTime(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:720
void SCIPexprhdlrSetEstimate(SCIP_EXPRHDLR *exprhdlr, SCIP_DECL_EXPRINITESTIMATES((*initestimates)), SCIP_DECL_EXPRESTIMATE((*estimate)))
Definition: expr.c:521
unsigned int SCIP_EXPRITER_STAGE
Definition: type_expr.h:683
const char * SCIPexprhdlrGetDescription(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:544
SCIP_EXPRCURV SCIPexprcurvMultiply(SCIP_Real factor, SCIP_EXPRCURV curvature)
Definition: exprcurv.c:87
common defines and data types used in all packages of SCIP
SCIP_Bool SCIPexpriterIsEnd(SCIP_EXPRITER *iterator)
Definition: expriter.c:968
SCIP_Bool SCIPexprhdlrHasSimplify(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:634
#define SCIP_DECL_EXPRCOPYHDLR(x)
Definition: type_expr.h:207
void SCIPexprhdlrIncrementNBranchings(SCIP_EXPRHDLR *exprhdlr)
Definition: expr.c:796
int SCIPexprGetNUses(SCIP_EXPR *expr)
Definition: expr.c:3798
void SCIPexprhdlrSetSimplify(SCIP_EXPRHDLR *exprhdlr, SCIP_DECL_EXPRSIMPLIFY((*simplify)))
Definition: expr.c:499
void SCIPexprhdlrSetIntEval(SCIP_EXPRHDLR *exprhdlr, SCIP_DECL_EXPRINTEVAL((*inteval)))
Definition: expr.c:488
#define SCIP_DECL_EXPRCOPYDATA(x)
Definition: type_expr.h:246
#define SCIP_DECL_EXPRHASH(x)
Definition: type_expr.h:388
#define SCIP_DECL_EXPRBWFWDIFF(x)
Definition: type_expr.h:517