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-2021 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file 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 }
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 }
42 
43 /** gets capabilities of expression interpreter (using bitflags) */
45  void
46  )
47 {
49 }
50 
51 /** creates an expression interpreter object */ /*lint -e{715}*/
53  BMS_BLKMEM* blkmem, /**< block memory data structure */
54  SCIP_EXPRINT** exprint /**< buffer to store pointer to expression interpreter */
55  )
56 { /*lint --e{715}*/
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 }
64 
65 /** frees an expression interpreter object */
67  SCIP_EXPRINT** exprint /**< expression interpreter that should be freed */
68  )
69 {
70  assert(exprint != NULL);
71  *exprint = NULL;
72 
73  return SCIP_OKAY;
74 }
75 
76 /** compiles an expression tree and stores compiled data in expression tree */ /*lint --e{715}*/
78  SCIP_EXPRINT* exprint, /**< interpreter data structure */
79  SCIP_EXPRTREE* tree /**< expression tree */
80  )
81 { /*lint --e{715}*/
82  return SCIP_OKAY;
83 }
84 
85 
86 /** gives the capability to evaluate an expression by the expression interpreter
87  *
88  * In cases of user-given expressions, higher order derivatives may not be available for the user-expression,
89  * even if the expression interpreter could handle these. This method allows to recognize that, e.g., the
90  * Hessian for an expression is not available because it contains a user expression that does not provide
91  * Hessians.
92  */ /*lint -e{715}*/
94  SCIP_EXPRINT* exprint, /**< interpreter data structure */
95  SCIP_EXPRTREE* tree /**< expression tree */
96  )
97 { /*lint --e{715}*/
99 }
100 
101 /** frees interpreter data */
103  SCIP_EXPRINTDATA** interpreterdata /**< interpreter data that should freed */
104  )
105 {
106  assert(interpreterdata != NULL);
107  assert(*interpreterdata == NULL);
108 
109  return SCIP_OKAY;
110 }
111 
112 /** notify expression interpreter that a new parameterization is used
113  * this probably causes retaping by AD algorithms
114  */ /*lint -e{715}*/
116  SCIP_EXPRINT* exprint, /**< interpreter data structure */
117  SCIP_EXPRTREE* tree /**< expression tree */
118  )
119 { /*lint --e{715}*/
120  return SCIP_OKAY;
121 }
122 
123 /** evaluates an expression tree */ /*lint -e{715}*/
125  SCIP_EXPRINT* exprint, /**< interpreter data structure */
126  SCIP_EXPRTREE* tree, /**< expression tree */
127  SCIP_Real* varvals, /**< values of variables */
128  SCIP_Real* val /**< buffer to store value */
129  )
130 { /*lint --e{715}*/
131  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
132  return SCIP_PLUGINNOTFOUND;
133 }
134 
135 /** evaluates an expression tree on intervals */ /*lint -e{715}*/
137  SCIP_EXPRINT* exprint, /**< interpreter data structure */
138  SCIP_EXPRTREE* tree, /**< expression tree */
139  SCIP_Real infinity, /**< value for infinity */
140  SCIP_INTERVAL* varvals, /**< interval values of variables */
141  SCIP_INTERVAL* val /**< buffer to store interval value of expression */
142  )
143 { /*lint --e{715}*/
144  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
145  return SCIP_PLUGINNOTFOUND;
146 }
147 
148 /** computes value and gradient of an expression tree */ /*lint -e{715}*/
150  SCIP_EXPRINT* exprint, /**< interpreter data structure */
151  SCIP_EXPRTREE* tree, /**< expression tree */
152  SCIP_Real* varvals, /**< values of variables, can be NULL if new_varvals is FALSE */
153  SCIP_Bool new_varvals, /**< have variable values changed since last call to a point evaluation routine? */
154  SCIP_Real* val, /**< buffer to store expression value */
155  SCIP_Real* gradient /**< buffer to store expression gradient, need to have length at least SCIPexprtreeGetNVars(tree) */
156  )
157 { /*lint --e{715}*/
158  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
159  return SCIP_PLUGINNOTFOUND;
160 }
161 
162 /** computes interval value and interval gradient of an expression tree */ /*lint -e{715}*/
164  SCIP_EXPRINT* exprint, /**< interpreter data structure */
165  SCIP_EXPRTREE* tree, /**< expression tree */
166  SCIP_Real infinity, /**< value for infinity */
167  SCIP_INTERVAL* varvals, /**< interval values of variables, can be NULL if new_varvals is FALSE */
168  SCIP_Bool new_varvals, /**< have variable interval values changed since last call to an interval evaluation routine? */
169  SCIP_INTERVAL* val, /**< buffer to store expression interval value */
170  SCIP_INTERVAL* gradient /**< buffer to store expression interval gradient, need to have length at least SCIPexprtreeGetNVars(tree) */
171  )
172 { /*lint --e{715}*/
173  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
174  return SCIP_PLUGINNOTFOUND;
175 }
176 
177 /** gives sparsity pattern of hessian
178  * NOTE: this function might be replaced later by something nicer
179  * Since the AD code might need to do a forward sweep, you should pass variable values in here.
180  */ /*lint -e{715}*/
182  SCIP_EXPRINT* exprint, /**< interpreter data structure */
183  SCIP_EXPRTREE* tree, /**< expression tree */
184  SCIP_Real* varvals, /**< values of variables */
185  SCIP_Bool* sparsity /**< buffer to store sparsity pattern of Hessian, sparsity[i+n*j] indicates whether entry (i,j) is nonzero in the hessian */
186  )
187 { /*lint --e{715}*/
188  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
189  return SCIP_PLUGINNOTFOUND;
190 }
191 
192 /** computes value and dense hessian of an expression tree
193  * the full hessian is computed (lower left and upper right triangle)
194  */ /*lint -e{715}*/
196  SCIP_EXPRINT* exprint, /**< interpreter data structure */
197  SCIP_EXPRTREE* tree, /**< expression tree */
198  SCIP_Real* varvals, /**< values of variables, can be NULL if new_varvals is FALSE */
199  SCIP_Bool new_varvals, /**< have variable values changed since last call to an evaluation routine? */
200  SCIP_Real* val, /**< buffer to store function value */
201  SCIP_Real* hessian /**< buffer to store hessian values, need to have size at least n*n */
202  )
203 { /*lint --e{715}*/
204  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
205  return SCIP_PLUGINNOTFOUND;
206 }
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:54
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:87
unsigned int SCIP_EXPRINTCAPABILITY
const char * SCIPexprintGetName(void)
#define SCIPerrorMessage
Definition: pub_message.h:55
SCIP_RETCODE SCIPexprintFree(SCIP_EXPRINT **exprint)
#define NULL
Definition: lpi_spx1.cpp:155
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:163
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:429
struct SCIP_ExprIntData SCIP_EXPRINTDATA
SCIP_RETCODE SCIPexprintCompile(SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree)