Scippy

SCIP

Solving Constraint Integer Programs

exprinterpret.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 exprinterpret.h
17  * @brief methods to interpret (evaluate) an expression tree "fast"
18  * @author Stefan Vigerske
19  * @author Thorsten Gellermann
20  * Realized similar to LPI: one implementation of an interpreter is linked in.
21  */
22 
23 /* @todo product Gradient times vector
24  @todo product Hessian times vector
25  @todo product Hessian of Lagrangian times vector
26  @todo sparse Hessian of expression tree
27  @todo sparse Hessian of Lagrangian (sets of expression trees and quadratic parts)?
28 */
29 
30 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
31 
32 #ifndef __SCIP_EXPRINTERPRET_H__
33 #define __SCIP_EXPRINTERPRET_H__
34 
35 #include "scip/def.h"
36 #include "blockmemshell/memory.h"
37 #include "nlpi/type_expr.h"
39 #include "scip/intervalarith.h"
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /** gets name and version of expression interpreter */
46 extern
47 const char* SCIPexprintGetName(void);
48 
49 /** gets descriptive text of expression interpreter */
50 extern
51 const char* SCIPexprintGetDesc(void);
52 
53 /** gets capabilities of expression interpreter (using bitflags) */
54 extern
56 
57 /** creates an expression interpreter object */
58 extern
60  BMS_BLKMEM* blkmem, /**< block memory data structure */
61  SCIP_EXPRINT** exprint /**< buffer to store pointer to expression interpreter */
62  );
63 
64 /** frees an expression interpreter object */
65 extern
67  SCIP_EXPRINT** exprint /**< expression interpreter that should be freed */
68  );
69 
70 /** compiles an expression tree and stores compiled data in expression tree */
71 extern
73  SCIP_EXPRINT* exprint, /**< interpreter data structure */
74  SCIP_EXPRTREE* tree /**< expression tree */
75  );
76 
77 /** frees interpreter data */
78 extern
80  SCIP_EXPRINTDATA** interpreterdata /**< interpreter data that should freed */
81  );
82 
83 /** notify expression interpreter that a new parameterization is used
84  * this probably causes retaping by AD algorithms
85  */
86 extern
88  SCIP_EXPRINT* exprint, /**< interpreter data structure */
89  SCIP_EXPRTREE* tree /**< expression tree */
90  );
91 
92 /** evaluates an expression tree */
93 extern
95  SCIP_EXPRINT* exprint, /**< interpreter data structure */
96  SCIP_EXPRTREE* tree, /**< expression tree */
97  SCIP_Real* varvals, /**< values of variables */
98  SCIP_Real* val /**< buffer to store value of expression */
99  );
100 
101 /** evaluates an expression tree on intervals */
102 extern
104  SCIP_EXPRINT* exprint, /**< interpreter data structure */
105  SCIP_EXPRTREE* tree, /**< expression tree */
106  SCIP_Real infinity, /**< value for infinity */
107  SCIP_INTERVAL* varvals, /**< interval values of variables */
108  SCIP_INTERVAL* val /**< buffer to store interval value of expression */
109  );
110 
111 /** computes value and gradient of an expression tree */
112 extern
114  SCIP_EXPRINT* exprint, /**< interpreter data structure */
115  SCIP_EXPRTREE* tree, /**< expression tree */
116  SCIP_Real* varvals, /**< values of variables, can be NULL if new_varvals is FALSE */
117  SCIP_Bool new_varvals, /**< have variable values changed since last call to a point evaluation routine? */
118  SCIP_Real* val, /**< buffer to store expression value */
119  SCIP_Real* gradient /**< buffer to store expression gradient, need to have length at least SCIPexprtreeGetNVars(tree) */
120  );
121 
122 /** computes interval value and interval gradient of an expression tree */
123 extern
125  SCIP_EXPRINT* exprint, /**< interpreter data structure */
126  SCIP_EXPRTREE* tree, /**< expression tree */
127  SCIP_Real infinity, /**< value for infinity */
128  SCIP_INTERVAL* varvals, /**< interval values of variables, can be NULL if new_varvals is FALSE */
129  SCIP_Bool new_varvals, /**< have variable interval values changed since last call to an interval evaluation routine? */
130  SCIP_INTERVAL* val, /**< buffer to store expression interval value */
131  SCIP_INTERVAL* gradient /**< buffer to store expression interval gradient, need to have length at least SCIPexprtreeGetNVars(tree) */
132  );
133 
134 /** gives sparsity pattern of hessian
135  * NOTE: this function might be replaced later by something nicer
136  * Since the AD code might need to do a forward sweep, you should pass variable values in here.
137  */
138 extern
140  SCIP_EXPRINT* exprint, /**< interpreter data structure */
141  SCIP_EXPRTREE* tree, /**< expression tree */
142  SCIP_Real* varvals, /**< values of variables */
143  SCIP_Bool* sparsity /**< buffer to store sparsity pattern of Hessian, sparsity[i+n*j] indicates whether entry (i,j) is nonzero in the hessian */
144  );
145 
146 /** computes value and dense hessian of an expression tree
147  * the full hessian is computed (lower left and upper right triangle)
148  */
149 extern
151  SCIP_EXPRINT* exprint, /**< interpreter data structure */
152  SCIP_EXPRTREE* tree, /**< expression tree */
153  SCIP_Real* varvals, /**< values of variables, can be NULL if new_varvals is FALSE */
154  SCIP_Bool new_varvals, /**< have variable values changed since last call to an evaluation routine? */
155  SCIP_Real* val, /**< buffer to store function value */
156  SCIP_Real* hessian /**< buffer to store hessian values, need to have size at least n*n */
157  );
158 
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 #endif /* __SCIP_EXPRINTERPRET_H__ */
164