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-2022 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 DEFPLUGINS_EXPRINT
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 "scip/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 sole 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  SCIP* scip, /**< SCIP data structure */
54  SCIP_EXPRINT** exprint /**< buffer to store pointer to expression interpreter */
55  )
56 {
57  *exprint = (SCIP_EXPRINT*)1u; /* some code checks that a non-NULL pointer is returned here, even though it may not point anywhere */
58 
59  return SCIP_OKAY;
60 } /*lint !e715*/
61 
62 /** frees an expression interpreter object */
64  SCIP* scip, /**< SCIP data structure */
65  SCIP_EXPRINT** exprint /**< expression interpreter that should be freed */
66  )
67 {
68  *exprint = NULL;
69 
70  return SCIP_OKAY;
71 } /*lint !e715*/
72 
73 /** compiles an expression and returns interpreter-specific data for expression
74  *
75  * can be called again with existing exprintdata if expression has been changed
76  *
77  * @attention *exprintdata needs to be initialized to NULL at first call
78  * @attention the expression is assumed to use varidx expressions instead of var expressions
79  */
81  SCIP* scip, /**< SCIP data structure */
82  SCIP_EXPRINT* exprint, /**< interpreter data structure */
83  SCIP_EXPR* expr, /**< expression */
84  SCIP_EXPRINTDATA** exprintdata /**< buffer to store pointer to compiled data */
85  )
86 {
87  return SCIP_OKAY;
88 } /*lint !e715*/
89 
90 /** frees interpreter data for expression */
92  SCIP* scip, /**< SCIP data structure */
93  SCIP_EXPRINT* exprint, /**< interpreter data structure */
94  SCIP_EXPR* expr, /**< expression */
95  SCIP_EXPRINTDATA** exprintdata /**< pointer to pointer to compiled data to be freed */
96  )
97 {
98  assert(exprintdata != NULL);
99  assert(*exprintdata == NULL);
100 
101  return SCIP_OKAY;
102 } /*lint !e715*/
103 
104 /** gives the capability to evaluate an expression by the expression interpreter
105  *
106  * In cases of user-given expressions, higher order derivatives may not be available for the user-expression,
107  * even if the expression interpreter could handle these. This method allows to recognize that, e.g., the
108  * Hessian for an expression is not available because it contains a user expression that does not provide
109  * Hessians.
110  */
112  SCIP* scip, /**< SCIP data structure */
113  SCIP_EXPRINT* exprint, /**< interpreter data structure */
114  SCIP_EXPR* expr, /**< expression */
115  SCIP_EXPRINTDATA* exprintdata /**< interpreter-specific data for expression */
116  )
117 {
119 } /*lint !e715*/
120 
121 /** evaluates an expression */
123  SCIP* scip, /**< SCIP data structure */
124  SCIP_EXPRINT* exprint, /**< interpreter data structure */
125  SCIP_EXPR* expr, /**< expression */
126  SCIP_EXPRINTDATA* exprintdata, /**< interpreter-specific data for expression */
127  SCIP_Real* varvals, /**< values of variables */
128  SCIP_Real* val /**< buffer to store value of expression */
129  )
130 {
131  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
132  return SCIP_PLUGINNOTFOUND;
133 } /*lint !e715*/
134 
135 /** computes value and gradient of an expression */
137  SCIP* scip, /**< SCIP data structure */
138  SCIP_EXPRINT* exprint, /**< interpreter data structure */
139  SCIP_EXPR* expr, /**< expression */
140  SCIP_EXPRINTDATA* exprintdata, /**< interpreter-specific data for expression */
141  SCIP_Real* varvals, /**< values of variables, can be NULL if new_varvals is FALSE */
142  SCIP_Bool new_varvals, /**< have variable values changed since last call to a point evaluation routine? */
143  SCIP_Real* val, /**< buffer to store expression value */
144  SCIP_Real* gradient /**< buffer to store expression gradient */
145  )
146 {
147  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
148  return SCIP_PLUGINNOTFOUND;
149 } /*lint !e715*/
150 
151 /** gives sparsity pattern of lower-triangular part of Hessian
152  *
153  * Since the AD code might need to do a forward sweep, variable values need to be passed in here.
154  *
155  * Result will have `(*colidxs)[i] <= (*rowidixs)[i]` for `i=0..*nnz`.
156  */
158  SCIP* scip, /**< SCIP data structure */
159  SCIP_EXPRINT* exprint, /**< interpreter data structure */
160  SCIP_EXPR* expr, /**< expression */
161  SCIP_EXPRINTDATA* exprintdata, /**< interpreter-specific data for expression */
162  SCIP_Real* varvals, /**< values of variables */
163  int** rowidxs, /**< buffer to return array with row indices of Hessian elements */
164  int** colidxs, /**< buffer to return array with column indices of Hessian elements */
165  int* nnz /**< buffer to return length of arrays */
166  )
167 {
168  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
169  return SCIP_PLUGINNOTFOUND;
170 } /*lint !e715*/
171 
172 /** computes value and Hessian of an expression
173  *
174  * Returned arrays `rowidxs` and `colidxs` and number of elements `nnz` are the same as given by SCIPexprintHessianSparsity().
175  * Returned array `hessianvals` will contain the corresponding Hessian elements.
176  */
178  SCIP* scip, /**< SCIP data structure */
179  SCIP_EXPRINT* exprint, /**< interpreter data structure */
180  SCIP_EXPR* expr, /**< expression */
181  SCIP_EXPRINTDATA* exprintdata, /**< interpreter-specific data for expression */
182  SCIP_Real* varvals, /**< values of variables, can be NULL if new_varvals is FALSE */
183  SCIP_Bool new_varvals, /**< have variable values changed since last call to an evaluation routine? */
184  SCIP_Real* val, /**< buffer to store function value */
185  int** rowidxs, /**< buffer to return array with row indices of Hessian elements */
186  int** colidxs, /**< buffer to return array with column indices of Hessian elements */
187  SCIP_Real** hessianvals, /**< buffer to return array with Hessian elements */
188  int* nnz /**< buffer to return length of arrays */
189  )
190 {
191  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
192  return SCIP_PLUGINNOTFOUND;
193 } /*lint !e715*/
const char * SCIPexprintGetName(void)
methods to interpret (evaluate) an expression "fast"
SCIP_RETCODE SCIPexprintCompile(SCIP *scip, SCIP_EXPRINT *exprint, SCIP_EXPR *expr, SCIP_EXPRINTDATA **exprintdata)
SCIP_RETCODE SCIPexprintFreeData(SCIP *scip, SCIP_EXPRINT *exprint, SCIP_EXPR *expr, SCIP_EXPRINTDATA **exprintdata)
SCIP_RETCODE SCIPexprintHessianSparsity(SCIP *scip, SCIP_EXPRINT *exprint, SCIP_EXPR *expr, SCIP_EXPRINTDATA *exprintdata, SCIP_Real *varvals, int **rowidxs, int **colidxs, int *nnz)
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
const char * SCIPexprintGetDesc(void)
SCIP_RETCODE SCIPexprintGrad(SCIP *scip, SCIP_EXPRINT *exprint, SCIP_EXPR *expr, SCIP_EXPRINTDATA *exprintdata, SCIP_Real *varvals, SCIP_Bool new_varvals, SCIP_Real *val, SCIP_Real *gradient)
unsigned int SCIP_EXPRINTCAPABILITY
#define SCIPerrorMessage
Definition: pub_message.h:55
#define NULL
Definition: lpi_spx1.cpp:155
SCIP_RETCODE SCIPexprintCreate(SCIP *scip, SCIP_EXPRINT **exprint)
SCIP_EXPRINTCAPABILITY SCIPexprintGetCapability(void)
SCIP_RETCODE SCIPexprintEval(SCIP *scip, SCIP_EXPRINT *exprint, SCIP_EXPR *expr, SCIP_EXPRINTDATA *exprintdata, SCIP_Real *varvals, SCIP_Real *val)
SCIP_EXPRINTCAPABILITY SCIPexprintGetExprCapability(SCIP *scip, SCIP_EXPRINT *exprint, SCIP_EXPR *expr, SCIP_EXPRINTDATA *exprintdata)
#define SCIP_Bool
Definition: def.h:84
SCIP_RETCODE SCIPexprintFree(SCIP *scip, SCIP_EXPRINT **exprint)
struct SCIP_ExprInt SCIP_EXPRINT
#define SCIP_EXPRINTCAPABILITY_NONE
SCIP_RETCODE SCIPexprintHessian(SCIP *scip, SCIP_EXPRINT *exprint, SCIP_EXPR *expr, SCIP_EXPRINTDATA *exprintdata, SCIP_Real *varvals, SCIP_Bool new_varvals, SCIP_Real *val, int **rowidxs, int **colidxs, SCIP_Real **hessianvals, int *nnz)
public methods for message output
#define SCIP_Real
Definition: def.h:177
struct SCIP_ExprIntData SCIP_EXPRINTDATA