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-2015 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_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 struct SCIP_ExprInt
28 {
29  char dummy; /*lint !e830*/
30 };
31 
32 /** gets name and version of expression interpreter */
33 const char* SCIPexprintGetName(
34  void
35  )
36 {
37  return "NONE";
38 } /*lint !e715*/
39 
40 /** gets descriptive text of expression interpreter */
41 const char* SCIPexprintGetDesc(
42  void
43  )
44 {
45  return "dummy expression interpreter which solely purpose it is to resolve linking symbols";
46 } /*lint !e715*/
47 
48 /** gets capabilities of expression interpreter (using bitflags) */
50  void
51  )
52 {
54 } /*lint !e715*/
55 
56 /** creates an expression interpreter object */
58  BMS_BLKMEM* blkmem, /**< block memory data structure */
59  SCIP_EXPRINT** exprint /**< buffer to store pointer to expression interpreter */
60  )
61 {
62  SCIPdebugMessage("SCIPexprintCreate()\n");
63  SCIPdebugMessage("Note that there is no expression interpreter linked to the binary.\n");
64 
65  SCIP_ALLOC( BMSallocMemory(exprint) );
66 
67  return SCIP_OKAY;
68 } /*lint !e715*/
69 
70 /** frees an expression interpreter object */
72  SCIP_EXPRINT** exprint /**< expression interpreter that should be freed */
73  )
74 {
75  BMSfreeMemory(exprint);
76 
77  return SCIP_OKAY;
78 } /*lint !e715*/
79 
80 /** compiles an expression tree and stores compiled data in expression tree */
82  SCIP_EXPRINT* exprint, /**< interpreter data structure */
83  SCIP_EXPRTREE* tree /**< expression tree */
84  )
85 {
86  return SCIP_OKAY;
87 } /*lint !e715*/
88 
89 
90 /** gives the capability to evaluate an expression by the expression interpreter
91  *
92  * In cases of user-given expressions, higher order derivatives may not be available for the user-expression,
93  * even if the expression interpreter could handle these. This method allows to recognize that, e.g., the
94  * Hessian for an expression is not available because it contains a user expression that does not provide
95  * Hessians.
96  */
98  SCIP_EXPRINT* exprint, /**< interpreter data structure */
99  SCIP_EXPRTREE* tree /**< expression tree */
100  )
101 {
103 }
104 
105 /** frees interpreter data */
107  SCIP_EXPRINTDATA** interpreterdata /**< interpreter data that should freed */
108  )
109 {
110  assert(interpreterdata != NULL);
111  assert(*interpreterdata == NULL);
112 
113  return SCIP_OKAY;
114 } /*lint !e715*/
115 
116 /** notify expression interpreter that a new parameterization is used
117  * this probably causes retaping by AD algorithms
118  */
120  SCIP_EXPRINT* exprint, /**< interpreter data structure */
121  SCIP_EXPRTREE* tree /**< expression tree */
122  )
123 {
124  return SCIP_OKAY;
125 } /*lint !e715*/
126 
127 /** evaluates an expression tree */
129  SCIP_EXPRINT* exprint, /**< interpreter data structure */
130  SCIP_EXPRTREE* tree, /**< expression tree */
131  SCIP_Real* varvals, /**< values of variables */
132  SCIP_Real* val /**< buffer to store value */
133  )
134 {
135  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
136  return SCIP_PLUGINNOTFOUND;
137 } /*lint !e715*/
138 
139 /** evaluates an expression tree on intervals */
141  SCIP_EXPRINT* exprint, /**< interpreter data structure */
142  SCIP_EXPRTREE* tree, /**< expression tree */
143  SCIP_Real infinity, /**< value for infinity */
144  SCIP_INTERVAL* varvals, /**< interval values of variables */
145  SCIP_INTERVAL* val /**< buffer to store interval value of expression */
146  )
147 {
148  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
149  return SCIP_PLUGINNOTFOUND;
150 } /*lint !e715*/
151 
152 /** computes value and gradient of an expression tree */
154  SCIP_EXPRINT* exprint, /**< interpreter data structure */
155  SCIP_EXPRTREE* tree, /**< expression tree */
156  SCIP_Real* varvals, /**< values of variables, can be NULL if new_varvals is FALSE */
157  SCIP_Bool new_varvals, /**< have variable values changed since last call to a point evaluation routine? */
158  SCIP_Real* val, /**< buffer to store expression value */
159  SCIP_Real* gradient /**< buffer to store expression gradient, need to have length at least SCIPexprtreeGetNVars(tree) */
160  )
161 {
162  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
163  return SCIP_PLUGINNOTFOUND;
164 } /*lint !e715*/
165 
166 /** computes interval value and interval gradient of an expression tree */
168  SCIP_EXPRINT* exprint, /**< interpreter data structure */
169  SCIP_EXPRTREE* tree, /**< expression tree */
170  SCIP_Real infinity, /**< value for infinity */
171  SCIP_INTERVAL* varvals, /**< interval values of variables, can be NULL if new_varvals is FALSE */
172  SCIP_Bool new_varvals, /**< have variable interval values changed since last call to an interval evaluation routine? */
173  SCIP_INTERVAL* val, /**< buffer to store expression interval value */
174  SCIP_INTERVAL* gradient /**< buffer to store expression interval gradient, need to have length at least SCIPexprtreeGetNVars(tree) */
175  )
176 {
177  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
178  return SCIP_PLUGINNOTFOUND;
179 } /*lint !e715*/
180 
181 /** gives sparsity pattern of hessian
182  * NOTE: this function might be replaced later by something nicer
183  * Since the AD code might need to do a forward sweep, you should pass variable values in here.
184  */
186  SCIP_EXPRINT* exprint, /**< interpreter data structure */
187  SCIP_EXPRTREE* tree, /**< expression tree */
188  SCIP_Real* varvals, /**< values of variables */
189  SCIP_Bool* sparsity /**< buffer to store sparsity pattern of Hessian, sparsity[i+n*j] indicates whether entry (i,j) is nonzero in the hessian */
190  )
191 {
192  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
193  return SCIP_PLUGINNOTFOUND;
194 } /*lint !e715*/
195 
196 /** computes value and dense hessian of an expression tree
197  * the full hessian is computed (lower left and upper right triangle)
198  */
200  SCIP_EXPRINT* exprint, /**< interpreter data structure */
201  SCIP_EXPRTREE* tree, /**< expression tree */
202  SCIP_Real* varvals, /**< values of variables, can be NULL if new_varvals is FALSE */
203  SCIP_Bool new_varvals, /**< have variable values changed since last call to an evaluation routine? */
204  SCIP_Real* val, /**< buffer to store function value */
205  SCIP_Real* hessian /**< buffer to store hessian values, need to have size at least n*n */
206  )
207 {
208  SCIPerrorMessage("No expression interpreter linked to SCIP, try recompiling with EXPRINT=cppad.\n");
209  return SCIP_PLUGINNOTFOUND;
210 } /*lint !e715*/
const char * SCIPexprintGetName(void)
methods to interpret (evaluate) an expression tree "fast"
#define NULL
Definition: lpi_spx.cpp:130
SCIP_RETCODE SCIPexprintHessianDense(SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree, SCIP_Real *varvals, SCIP_Bool new_varvals, SCIP_Real *val, SCIP_Real *hessian)
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
#define SCIPdebugMessage
Definition: pub_message.h:77
unsigned int SCIP_EXPRINTCAPABILITY
SCIP_RETCODE SCIPexprintCreate(BMS_BLKMEM *blkmem, SCIP_EXPRINT **exprint)
SCIP_RETCODE SCIPexprintFreeData(SCIP_EXPRINTDATA **interpreterdata)
SCIP_RETCODE SCIPexprintNewParametrization(SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree)
#define SCIPerrorMessage
Definition: pub_message.h:45
SCIP_RETCODE SCIPexprintEval(SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree, SCIP_Real *varvals, SCIP_Real *val)
SCIP_RETCODE SCIPexprintHessianSparsityDense(SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree, SCIP_Real *varvals, SCIP_Bool *sparsity)
SCIP_RETCODE SCIPexprintCompile(SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree)
SCIP_EXPRINTCAPABILITY SCIPexprintGetExprtreeCapability(SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree)
const char * SCIPexprintGetDesc(void)
struct SCIP_ExprTree SCIP_EXPRTREE
Definition: type_expr.h:92
#define SCIP_Bool
Definition: def.h:50
struct SCIP_ExprInt SCIP_EXPRINT
#define SCIP_EXPRINTCAPABILITY_NONE
SCIP_EXPRINTCAPABILITY SCIPexprintGetCapability(void)
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)
public methods for message output
#define SCIP_Real
Definition: def.h:124
SCIP_RETCODE SCIPexprintFree(SCIP_EXPRINT **exprint)
SCIP_RETCODE SCIPexprintGrad(SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree, SCIP_Real *varvals, SCIP_Bool new_varvals, SCIP_Real *val, SCIP_Real *gradient)
#define SCIP_ALLOC(x)
Definition: def.h:274
struct SCIP_ExprIntData SCIP_EXPRINTDATA
SCIP_RETCODE SCIPexprintEvalInt(SCIP_EXPRINT *exprint, SCIP_EXPRTREE *tree, SCIP_Real infinity, SCIP_INTERVAL *varvals, SCIP_INTERVAL *val)