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 pub_nlp.h 17 * @ingroup PUBLICCOREAPI 18 * @brief public methods for NLP management 19 * @author Thorsten Gellermann 20 * @author Stefan Vigerske 21 */ 22 23 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 24 25 #ifndef __SCIP_PUB_NLP_H__ 26 #define __SCIP_PUB_NLP_H__ 27 28 #include <stdio.h> 29 30 #include "scip/def.h" 31 #include "scip/type_message.h" 32 #include "blockmemshell/memory.h" 33 #include "scip/type_set.h" 34 #include "scip/type_stat.h" 35 #include "scip/type_nlp.h" 36 #include "scip/type_var.h" 37 #include "scip/type_sol.h" 38 #include "nlpi/type_expr.h" 39 #include "nlpi/type_nlpi.h" 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 44 45 /**@addtogroup PublicNLPMethods 46 * 47 * @{ 48 */ 49 50 51 /**@addtogroup PublicExpressionTreeMethods 52 * 53 * @{ 54 */ 55 56 /** returns variables of expression tree */ 57 SCIP_EXPORT 58 SCIP_VAR** SCIPexprtreeGetVars( 59 SCIP_EXPRTREE* tree /**< expression tree */ 60 ); 61 62 /** stores array of variables in expression tree */ 63 SCIP_EXPORT 64 SCIP_RETCODE SCIPexprtreeSetVars( 65 SCIP_EXPRTREE* tree, /**< expression tree */ 66 int nvars, /**< number of variables */ 67 SCIP_VAR** vars /**< variables */ 68 ); 69 70 /** adds variables to the expression tree variables array */ 71 SCIP_EXPORT 72 SCIP_RETCODE SCIPexprtreeAddVars( 73 SCIP_EXPRTREE* tree, /**< expression tree */ 74 int nvars, /**< number of variables */ 75 SCIP_VAR** vars /**< variables */ 76 ); 77 78 /** prints an expression tree using variable names from variables array */ 79 SCIP_EXPORT 80 SCIP_RETCODE SCIPexprtreePrintWithNames( 81 SCIP_EXPRTREE* tree, /**< expression tree */ 82 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 83 FILE* file /**< file for printing, or NULL for stdout */ 84 ); 85 86 /** searches the variables array of an expression tree for a variable and returns its position, or -1 if not found 87 * Note that this is an O(n) operation! 88 */ 89 SCIP_EXPORT 90 int SCIPexprtreeFindVar( 91 SCIP_EXPRTREE* tree, /**< expression tree */ 92 SCIP_VAR* var /**< variable to search for */ 93 ); 94 95 /**@} */ 96 97 /**@addtogroup PublicNLRowMethods 98 * 99 * @{ 100 */ 101 102 /** gets constant */ 103 SCIP_EXPORT 104 SCIP_Real SCIPnlrowGetConstant( 105 SCIP_NLROW* nlrow /**< NLP row */ 106 ); 107 108 /** gets number of variables of linear part */ 109 SCIP_EXPORT 110 int SCIPnlrowGetNLinearVars( 111 SCIP_NLROW* nlrow /**< NLP row */ 112 ); 113 114 /** gets array with variables of linear part */ 115 SCIP_EXPORT 116 SCIP_VAR** SCIPnlrowGetLinearVars( 117 SCIP_NLROW* nlrow /**< NLP row */ 118 ); 119 120 /** gets array with coefficients in linear part */ 121 SCIP_EXPORT 122 SCIP_Real* SCIPnlrowGetLinearCoefs( 123 SCIP_NLROW* nlrow /**< NLP row */ 124 ); 125 126 /** gets number of quadratic variables in quadratic part */ 127 SCIP_EXPORT 128 int SCIPnlrowGetNQuadVars( 129 SCIP_NLROW* nlrow /**< NLP row */ 130 ); 131 132 /** gets quadratic variables in quadratic part */ 133 SCIP_EXPORT 134 SCIP_VAR** SCIPnlrowGetQuadVars( 135 SCIP_NLROW* nlrow /**< NLP row */ 136 ); 137 138 /** gives position of variable in quadvars array of row, or -1 if not found */ 139 SCIP_EXPORT 140 int SCIPnlrowSearchQuadVar( 141 SCIP_NLROW* nlrow, /**< nonlinear row */ 142 SCIP_VAR* var /**< variable to search for */ 143 ); 144 145 /** gets number of quadratic elements in quadratic part */ 146 SCIP_EXPORT 147 int SCIPnlrowGetNQuadElems( 148 SCIP_NLROW* nlrow /**< NLP row */ 149 ); 150 151 /** gets quadratic elements in quadratic part */ 152 SCIP_EXPORT 153 SCIP_QUADELEM* SCIPnlrowGetQuadElems( 154 SCIP_NLROW* nlrow /**< NLP row */ 155 ); 156 157 /** gets array with coefficients in linear part */ 158 SCIP_EXPORT 159 void SCIPnlrowGetQuadData( 160 SCIP_NLROW* nlrow, /**< NLP row */ 161 int* nquadvars, /**< buffer to store number of variables in quadratic term, or NULL if not of interest */ 162 SCIP_VAR*** quadvars, /**< buffer to store pointer to array of variables in quadratic term, or NULL if not of interest */ 163 int* nquadelems, /**< buffer to store number of entries in quadratic term, or NULL if not of interest */ 164 SCIP_QUADELEM** quadelems /**< buffer to store pointer to array of entries in quadratic term, or NULL if not of interest */ 165 ); 166 167 /** gets expression tree */ 168 SCIP_EXPORT 169 SCIP_EXPRTREE* SCIPnlrowGetExprtree( 170 SCIP_NLROW* nlrow /**< NLP row */ 171 ); 172 173 /** returns the left hand side of a nonlinear row */ 174 SCIP_EXPORT 175 SCIP_Real SCIPnlrowGetLhs( 176 SCIP_NLROW* nlrow /**< NLP row */ 177 ); 178 179 /** returns the right hand side of a nonlinear row */ 180 SCIP_EXPORT 181 SCIP_Real SCIPnlrowGetRhs( 182 SCIP_NLROW* nlrow /**< NLP row */ 183 ); 184 185 /** returns the curvature of a nonlinear row */ 186 SCIP_EXPORT 187 SCIP_EXPRCURV SCIPnlrowGetCurvature( 188 SCIP_NLROW* nlrow /**< NLP row */ 189 ); 190 191 /** sets the curvature of a nonlinear row */ 192 SCIP_EXPORT 193 void SCIPnlrowSetCurvature( 194 SCIP_NLROW* nlrow, /**< NLP row */ 195 SCIP_EXPRCURV curvature /**< curvature of NLP row */ 196 ); 197 198 /** returns the name of a nonlinear row */ 199 SCIP_EXPORT 200 const char* SCIPnlrowGetName( 201 SCIP_NLROW* nlrow /**< NLP row */ 202 ); 203 204 /** gets position of a nonlinear row in current NLP, or -1 if not in NLP */ 205 SCIP_EXPORT 206 int SCIPnlrowGetNLPPos( 207 SCIP_NLROW* nlrow /**< NLP row */ 208 ); 209 210 /** returns TRUE iff row is member of current NLP */ 211 SCIP_EXPORT 212 SCIP_Bool SCIPnlrowIsInNLP( 213 SCIP_NLROW* nlrow /**< NLP row */ 214 ); 215 216 /** gets the dual NLP solution of a nlrow 217 * for a ranged constraint, the dual value is positive if the right hand side is active and negative if the left hand side is active 218 */ 219 SCIP_EXPORT 220 SCIP_Real SCIPnlrowGetDualsol( 221 SCIP_NLROW* nlrow /**< NLP row */ 222 ); 223 224 /**@} */ 225 226 /**@} */ /* PublicNLPMethods */ 227 228 #ifdef __cplusplus 229 } 230 #endif 231 232 #endif /* __SCIP_PUB_NLP_H__ */ 233