Scippy

SCIP

Solving Constraint Integer Programs

exprinterpret_none.c
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-2019 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scip.zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file exprinterpret_none.c
17  * @brief function definitions for nonexisting expression interpreter to resolve linking references
18  * @ingroup EXPRINTS
19  * @author Stefan Vigerske
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #include "scip/pub_message.h"
25 #include "nlpi/exprinterpret.h"
26 
27 /** gets name and version of expression interpreter */
28 const char* SCIPexprintGetName(
29  void
30  )
31 {
32  return "NONE";
33 } /*lint !e715*/
34 
35 /** gets descriptive text of expression interpreter */
36 const char* SCIPexprintGetDesc(
37  void
38  )
39 {
40  return "dummy expression interpreter which solely purpose it is to resolve linking symbols";
41 } /*lint !e715*/
42 
43 /** gets capabilities of expression interpreter (using bitflags) */
45  void
46  )
47 {
49 } /*lint !e715*/
50 
51 /** creates an expression interpreter object */
53  BMS_BLKMEM* blkmem, /**< block memory data structure */
54  SCIP_EXPRINT** exprint /**< buffer to store pointer to expression interpreter */
55  )
56 {
57  SCIPdebugMessage("SCIPexprintCreate()\n");
58  SCIPdebugMessage("Note that there is no expression interpreter linked to the binary.\n");
59 
60  *exprint = (SCIP_EXPRINT*)1u; /* some code checks that a non-NULL pointer is returned here, even though it may not point anywhere */
61 
62  return SCIP_OKAY;
63 } /*lint !e715*/
64 
65 /** frees an expression interpreter object */
67  SCIP_EXPRINT** exprint /**< expression interpreter that should be freed */
68  )
69 {
70  *exprint = NULL;
71 
72  return SCIP_OKAY;
73 } /*lint !e715*/
74 
75 /** compiles an expression tree and stores compiled data in expression tree */
77  SCIP_EXPRINT* exprint, /**< interpreter data structure */
78  SCIP_EXPRTREE* tree /**< expression tree */
79  )
80 {
81  return SCIP_OKAY;
82 } /*lint !e715*/
83 
84 
85 /** gives the capability to evaluate an expression by the expression interpreter
86  *
87  * In cases of user-given expressions, higher order derivatives may not be available for the user-expression,
88  * even if the expression interpreter could handle these. This method allows to recognize that, e.g., the
89  * Hessian for an expression is not available because it contains a user expression that does not provide
90  * Hessians.
91  */
93  SCIP_EXPRINT* exprint, /**< interpreter data structure */
94  SCIP_EXPRTREE* tree /**< expression tree */
95  )
96 {
98 } /*lint !e715*/
99 
100 /** frees interpreter data */
102  SCIP_EXPRINTDATA** interpreterdata /**< interpreter data that should freed */
103  )
104 {
105  assert(interpreterdata != NULL);
106  assert(*interpreterdata == NULL);
107 
108  return SCIP_OKAY;
109 } /*lint !e715*/
110 
111 /** notify expression interpreter that a new parameterization is used
112  * this probably causes retaping by AD algorithms
113  */
115  SCIP_EXPRINT* exprint, /**< interpreter data structure */
116  SCIP_EXPRTREE* tree /**< expression tree */
117  )
118 {
119  return SCIP_OKAY;
120 } /*lint !e715*/
121 
122 /** evaluates an expression tree */
124  SCIP_EXPRINT* exprint, /**< interpreter data structure */
125  SCIP_EXPRTREE* tree, /**< expression tree */
126  SCIP_Real* varvals, /**< values of variables */
127  SCIP_Real* val /**< buffer to store value */
128  )
129 {
130  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
131  return SCIP_PLUGINNOTFOUND;
132 } /*lint !e715*/
133 
134 /** evaluates an expression tree on intervals */
136  SCIP_EXPRINT* exprint, /**< interpreter data structure */
137  SCIP_EXPRTREE* tree, /**< expression tree */
138  SCIP_Real infinity, /**< value for infinity */
139  SCIP_INTERVAL* varvals, /**< interval values of variables */
140  SCIP_INTERVAL* val /**< buffer to store interval value of expression */
141  )
142 {
143  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
144  return SCIP_PLUGINNOTFOUND;
145 } /*lint !e715*/
146 
147 /** computes value and gradient of an expression tree */
149  SCIP_EXPRINT* exprint, /**< interpreter data structure */
150  SCIP_EXPRTREE* tree, /**< expression tree */
151  SCIP_Real* varvals, /**< values of variables, can be NULL if new_varvals is FALSE */
152  SCIP_Bool new_varvals, /**< have variable values changed since last call to a point evaluation routine? */
153  SCIP_Real* val, /**< buffer to store expression value */
154  SCIP_Real* gradient /**< buffer to store expression gradient, need to have length at least SCIPexprtreeGetNVars(tree) */
155  )
156 {
157  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
158  return SCIP_PLUGINNOTFOUND;
159 } /*lint !e715*/
160 
161 /** computes interval value and interval gradient of an expression tree */
163  SCIP_EXPRINT* exprint, /**< interpreter data structure */
164  SCIP_EXPRTREE* tree, /**< expression tree */
165  SCIP_Real infinity, /**< value for infinity */
166  SCIP_INTERVAL* varvals, /**< interval values of variables, can be NULL if new_varvals is FALSE */
167  SCIP_Bool new_varvals, /**< have variable interval values changed since last call to an interval evaluation routine? */
168  SCIP_INTERVAL* val, /**< buffer to store expression interval value */
169  SCIP_INTERVAL* gradient /**< buffer to store expression interval gradient, need to have length at least SCIPexprtreeGetNVars(tree) */
170  )
171 {
172  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
173  return SCIP_PLUGINNOTFOUND;
174 } /*lint !e715*/
175 
176 /** gives sparsity pattern of hessian
177  * NOTE: this function might be replaced later by something nicer
178  * Since the AD code might need to do a forward sweep, you should pass variable values in here.
179  */
181  SCIP_EXPRINT* exprint, /**< interpreter data structure */
182  SCIP_EXPRTREE* tree, /**< expression tree */
183  SCIP_Real* varvals, /**< values of variables */
184  SCIP_Bool* sparsity /**< buffer to store sparsity pattern of Hessian, sparsity[i+n*j] indicates whether entry (i,j) is nonzero in the hessian */
185  )
186 {
187  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
188  return SCIP_PLUGINNOTFOUND;
189 } /*lint !e715*/
190 
191 /** computes value and dense hessian of an expression tree
192  * the full hessian is computed (lower left and upper right triangle)
193  */
195  SCIP_EXPRINT* exprint, /**< interpreter data structure */
196  SCIP_EXPRTREE* tree, /**< expression tree */
197  SCIP_Real* varvals, /**< values of variables, can be NULL if new_varvals is FALSE */
198  SCIP_Bool new_varvals, /**< have variable values changed since last call to an evaluation routine? */
199  SCIP_Real* val, /**< buffer to store function value */
200  SCIP_Real* hessian /**< buffer to store hessian values, need to have size at least n*n */
201  )
202 {
203  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
204  return SCIP_PLUGINNOTFOUND;
205 } /*lint !e715*/
#define NULL
Definition: def.h:253
SCIP_RETCODE SCIPexprintNewParametrization(SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree)
methods to interpret (evaluate) an expression tree "fast"
#define infinity
Definition: gastrans.c:71
SCIP_EXPRINTCAPABILITY SCIPexprintGetExprtreeCapability(SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree)
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_RETCODE SCIPexprintGrad(SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree, SCIP_Real *varvals, SCIP_Bool new_varvals, SCIP_Real *val, SCIP_Real *gradient)
SCIP_RETCODE SCIPexprintEvalInt(SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree, SCIP_Real infinity, SCIP_INTERVAL *varvals, SCIP_INTERVAL *val)
#define SCIPdebugMessage
Definition: pub_message.h:77
unsigned int SCIP_EXPRINTCAPABILITY
const char * SCIPexprintGetName(void)
#define SCIPerrorMessage
Definition: pub_message.h:45
SCIP_RETCODE SCIPexprintFree(SCIP_EXPRINT **exprint)
SCIP_RETCODE SCIPexprintCreate(BMS_BLKMEM *blkmem, SCIP_EXPRINT **exprint)
SCIP_RETCODE SCIPexprintEval(SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree, SCIP_Real *varvals, SCIP_Real *val)
#define SCIP_Bool
Definition: def.h:70
SCIP_RETCODE SCIPexprintFreeData(SCIP_EXPRINTDATA **interpreterdata)
SCIP_EXPRINTCAPABILITY SCIPexprintGetCapability(void)
#define SCIP_EXPRINTCAPABILITY_NONE
SCIP_RETCODE SCIPexprintHessianDense(SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree, SCIP_Real *varvals, SCIP_Bool new_varvals, SCIP_Real *val, SCIP_Real *hessian)
public methods for message output
#define SCIP_Real
Definition: def.h:164
SCIP_RETCODE SCIPexprintGradInt(SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree, SCIP_Real infinity, SCIP_INTERVAL *varvals, SCIP_Bool new_varvals, SCIP_INTERVAL *val, SCIP_INTERVAL *gradient)
SCIP_RETCODE SCIPexprintHessianSparsityDense(SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree, SCIP_Real *varvals, SCIP_Bool *sparsity)
const char * SCIPexprintGetDesc(void)
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:427
struct SCIP_ExprIntData SCIP_EXPRINTDATA
SCIP_RETCODE SCIPexprintCompile(SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree)