1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 2 /* */ 3 /* This file is part of the program and library */ 4 /* SCIP --- Solving Constraint Integer Programs */ 5 /* */ 6 /* Copyright (c) 2002-2023 Zuse Institute Berlin (ZIB) */ 7 /* */ 8 /* Licensed under the Apache License, Version 2.0 (the "License"); */ 9 /* you may not use this file except in compliance with the License. */ 10 /* You may obtain a copy of the License at */ 11 /* */ 12 /* http://www.apache.org/licenses/LICENSE-2.0 */ 13 /* */ 14 /* Unless required by applicable law or agreed to in writing, software */ 15 /* distributed under the License is distributed on an "AS IS" BASIS, */ 16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ 17 /* See the License for the specific language governing permissions and */ 18 /* limitations under the License. */ 19 /* */ 20 /* You should have received a copy of the Apache-2.0 license */ 21 /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */ 22 /* */ 23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 24 25 /**@file scip_nlp.h 26 * @ingroup PUBLICCOREAPI 27 * @brief public methods for nonlinear relaxation 28 * @author Thorsten Gellermann 29 * @author Stefan Vigerske 30 */ 31 32 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 33 34 #ifndef __SCIP_SCIP_NLP_H__ 35 #define __SCIP_SCIP_NLP_H__ 36 37 38 #include "scip/def.h" 39 #include "scip/type_lp.h" 40 #include "scip/type_nlp.h" 41 #include "scip/type_nlpi.h" 42 #include "scip/type_retcode.h" 43 #include "scip/type_scip.h" 44 #include "scip/type_sol.h" 45 #include "scip/type_var.h" 46 #include "scip/type_expr.h" 47 #include "scip/pub_nlp.h" 48 49 #ifdef __cplusplus 50 extern "C" { 51 #endif 52 53 /**@addtogroup PublicNLPMethods 54 * 55 * @{ 56 */ 57 58 /** returns whether the NLP relaxation has been enabled 59 * 60 * If the NLP relaxation is enabled, then SCIP will construct the NLP relaxation when the solving process is about to begin. 61 * To check whether an NLP is existing, use SCIPisNLPConstructed(). 62 * 63 * @pre This method can be called if SCIP is in one of the following stages: 64 * - \ref SCIP_STAGE_INITPRESOLVE 65 * - \ref SCIP_STAGE_PRESOLVING 66 * - \ref SCIP_STAGE_EXITPRESOLVE 67 * - \ref SCIP_STAGE_PRESOLVED 68 * - \ref SCIP_STAGE_INITSOLVE 69 * - \ref SCIP_STAGE_SOLVING 70 * 71 * @see SCIPenableNLP 72 */ 73 SCIP_EXPORT 74 SCIP_Bool SCIPisNLPEnabled( 75 SCIP* scip /**< SCIP data structure */ 76 ); 77 78 /** notifies SCIP that the NLP relaxation should be initialized in INITSOLVE 79 * 80 * This method is typically called by a constraint handler that handles constraints that have a nonlinear representation as nonlinear rows, e.g., cons_nonlinear. 81 * 82 * The function should be called before the branch-and-bound process is initialized, e.g., when presolve is exiting. 83 * 84 * @pre This method can be called if SCIP is in one of the following stages: 85 * - \ref SCIP_STAGE_INITPRESOLVE 86 * - \ref SCIP_STAGE_PRESOLVING 87 * - \ref SCIP_STAGE_EXITPRESOLVE 88 * - \ref SCIP_STAGE_PRESOLVED 89 */ 90 SCIP_EXPORT 91 void SCIPenableNLP( 92 SCIP* scip /**< SCIP data structure */ 93 ); 94 95 /** returns, whether an NLP has been constructed 96 * 97 * @pre This method can be called if SCIP is in one of the following stages: 98 * - \ref SCIP_STAGE_INITSOLVE 99 * - \ref SCIP_STAGE_SOLVING 100 */ 101 SCIP_EXPORT 102 SCIP_Bool SCIPisNLPConstructed( 103 SCIP* scip /**< SCIP data structure */ 104 ); 105 106 /** checks whether the NLP has a continuous variable in a nonlinear term 107 * 108 * @pre This method can be called if SCIP is in one of the following stages: 109 * - \ref SCIP_STAGE_INITSOLVE 110 * - \ref SCIP_STAGE_SOLVING 111 */ 112 SCIP_EXPORT 113 SCIP_RETCODE SCIPhasNLPContinuousNonlinearity( 114 SCIP* scip, /**< SCIP data structure */ 115 SCIP_Bool* result /**< buffer to store result */ 116 ); 117 118 /** gets current NLP variables along with the current number of NLP variables 119 * 120 * @pre This method can be called if SCIP is in one of the following stages: 121 * - \ref SCIP_STAGE_INITSOLVE 122 * - \ref SCIP_STAGE_SOLVING 123 */ 124 SCIP_EXPORT 125 SCIP_RETCODE SCIPgetNLPVarsData( 126 SCIP* scip, /**< SCIP data structure */ 127 SCIP_VAR*** vars, /**< pointer to store the array of NLP variables, or NULL */ 128 int* nvars /**< pointer to store the number of NLP variables, or NULL */ 129 ); 130 131 /** gets array with variables of the NLP 132 * 133 * @pre This method can be called if SCIP is in one of the following stages: 134 * - \ref SCIP_STAGE_INITSOLVE 135 * - \ref SCIP_STAGE_SOLVING 136 */ 137 SCIP_EXPORT 138 SCIP_VAR** SCIPgetNLPVars( 139 SCIP* scip /**< SCIP data structure */ 140 ); 141 142 /** gets current number of variables in NLP 143 * 144 * @pre This method can be called if SCIP is in one of the following stages: 145 * - \ref SCIP_STAGE_INITSOLVE 146 * - \ref SCIP_STAGE_SOLVING 147 */ 148 SCIP_EXPORT 149 int SCIPgetNNLPVars( 150 SCIP* scip /**< SCIP data structure */ 151 ); 152 153 /** computes for each variables the number of NLP rows in which the variable appears in the nonlinear part 154 * 155 * @pre This method can be called if SCIP is in one of the following stages: 156 * - \ref SCIP_STAGE_INITSOLVE 157 * - \ref SCIP_STAGE_SOLVING 158 */ 159 SCIP_EXPORT 160 SCIP_RETCODE SCIPgetNLPVarsNonlinearity( 161 SCIP* scip, /**< SCIP data structure */ 162 int* nlcount /**< an array of length at least SCIPnlpGetNVars() to store nonlinearity counts of variables */ 163 ); 164 165 /** returns dual solution values associated with lower bounds of NLP variables 166 * 167 * @pre This method can be called if SCIP is in one of the following stages: 168 * - \ref SCIP_STAGE_INITSOLVE 169 * - \ref SCIP_STAGE_SOLVING 170 */ 171 SCIP_EXPORT 172 SCIP_Real* SCIPgetNLPVarsLbDualsol( 173 SCIP* scip /**< SCIP data structure */ 174 ); 175 176 /** returns dual solution values associated with upper bounds of NLP variables 177 * 178 * @pre This method can be called if SCIP is in one of the following stages: 179 * - \ref SCIP_STAGE_INITSOLVE 180 * - \ref SCIP_STAGE_SOLVING 181 */ 182 SCIP_EXPORT 183 SCIP_Real* SCIPgetNLPVarsUbDualsol( 184 SCIP* scip /**< SCIP data structure */ 185 ); 186 187 /** gets current NLP nonlinear rows along with the current number of NLP nonlinear rows 188 * 189 * @pre This method can be called if SCIP is in one of the following stages: 190 * - \ref SCIP_STAGE_INITSOLVE 191 * - \ref SCIP_STAGE_SOLVING 192 */ 193 SCIP_EXPORT 194 SCIP_RETCODE SCIPgetNLPNlRowsData( 195 SCIP* scip, /**< SCIP data structure */ 196 SCIP_NLROW*** nlrows, /**< pointer to store the array of NLP nonlinear rows, or NULL */ 197 int* nnlrows /**< pointer to store the number of NLP nonlinear rows, or NULL */ 198 ); 199 200 /** gets array with nonlinear rows of the NLP 201 * 202 * @pre This method can be called if SCIP is in one of the following stages: 203 * - \ref SCIP_STAGE_INITSOLVE 204 * - \ref SCIP_STAGE_SOLVING 205 */ 206 SCIP_EXPORT 207 SCIP_NLROW** SCIPgetNLPNlRows( 208 SCIP* scip /**< SCIP data structure */ 209 ); 210 211 /** gets current number of nonlinear rows in NLP 212 * 213 * @pre This method can be called if SCIP is in one of the following stages: 214 * - \ref SCIP_STAGE_INITSOLVE 215 * - \ref SCIP_STAGE_SOLVING 216 */ 217 SCIP_EXPORT 218 int SCIPgetNNLPNlRows( 219 SCIP* scip /**< SCIP data structure */ 220 ); 221 222 /** gets statistics on convexity of rows in NLP 223 * 224 * Reports counts on the current number of linear rows, convex inequalities, nonconvex inequalities, and nonlinear equalities or ranged rows. 225 * - A nonlinear inequality with infinity left-hand-side is accounted as convex if its expression has been marked as convex. 226 * - A nonlinear inequality with infinity right-hand-side is accounted as convex if its expression has been marked as concave. 227 * - Other nonlinear rows are accounted as nonconvex. Note that convexity for a nonlinear row may just not have been detected. 228 * 229 * @pre This method can be called if SCIP is in one of the following stages: 230 * - \ref SCIP_STAGE_INITSOLVE 231 * - \ref SCIP_STAGE_SOLVING 232 * - \ref SCIP_STAGE_SOLVED 233 */ 234 SCIP_EXPORT 235 SCIP_RETCODE SCIPgetNLPNlRowsStat( 236 SCIP* scip, /**< SCIP data structure */ 237 int* nlinear, /**< buffer to store number of linear rows in NLP, or NULL */ 238 int* nconvexineq, /**< buffer to store number of convex inequalities in NLP, or NULL */ 239 int* nnonconvexineq, /**< buffer to store number of nonconvex inequalities in NLP, or NULL */ 240 int* nnonlineareq /**< buffer to store number of nonlinear equalities or ranged rows in NLP, or NULL */ 241 ); 242 243 /** adds a nonlinear row to the NLP. This row is captured by the NLP. 244 * 245 * @pre This method can be called if SCIP is in one of the following stages: 246 * - \ref SCIP_STAGE_INITSOLVE 247 * - \ref SCIP_STAGE_SOLVING 248 */ 249 SCIP_EXPORT 250 SCIP_RETCODE SCIPaddNlRow( 251 SCIP* scip, /**< SCIP data structure */ 252 SCIP_NLROW* nlrow /**< nonlinear row to add to NLP */ 253 ); 254 255 /** removes a nonlinear row from the NLP 256 * 257 * This row is released in the NLP. 258 * 259 * @pre This method can be called if SCIP is in one of the following stages: 260 * - \ref SCIP_STAGE_INITSOLVE 261 * - \ref SCIP_STAGE_SOLVING 262 * - \ref SCIP_STAGE_SOLVED 263 * - \ref SCIP_STAGE_EXITSOLVE 264 */ 265 SCIP_EXPORT 266 SCIP_RETCODE SCIPdelNlRow( 267 SCIP* scip, /**< SCIP data structure */ 268 SCIP_NLROW* nlrow /**< nonlinear row to add to NLP */ 269 ); 270 271 /** makes sure that the NLP of the current node is flushed 272 * 273 * @pre This method can be called if SCIP is in one of the following stages: 274 * - \ref SCIP_STAGE_INITSOLVE 275 * - \ref SCIP_STAGE_SOLVING 276 */ 277 SCIP_EXPORT 278 SCIP_RETCODE SCIPflushNLP( 279 SCIP* scip /**< SCIP data structure */ 280 ); 281 282 /** sets or clears initial primal guess for NLP solution (start point for NLP solver) 283 * 284 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 285 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 286 * 287 * @pre This method can be called if SCIP is in one of the following stages: 288 * - \ref SCIP_STAGE_INITSOLVE 289 * - \ref SCIP_STAGE_SOLVING 290 */ 291 SCIP_EXPORT 292 SCIP_RETCODE SCIPsetNLPInitialGuess( 293 SCIP* scip, /**< SCIP data structure */ 294 SCIP_Real* initialguess /**< values of initial guess (corresponding to variables from SCIPgetNLPVarsData), or NULL to use no start point */ 295 ); 296 297 /** sets initial primal guess for NLP solution (start point for NLP solver) 298 * 299 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 300 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 301 * 302 * @pre This method can be called if SCIP is in one of the following stages: 303 * - \ref SCIP_STAGE_INITSOLVE 304 * - \ref SCIP_STAGE_SOLVING 305 */ 306 SCIP_EXPORT 307 SCIP_RETCODE SCIPsetNLPInitialGuessSol( 308 SCIP* scip, /**< SCIP data structure */ 309 SCIP_SOL* sol /**< solution which values should be taken as initial guess, or NULL for LP solution */ 310 ); 311 312 /** solves the current NLP (or diving NLP if in diving mode) with given parameters 313 * 314 * Typical use is 315 * 316 * SCIP_NLPPARAM nlparam = { SCIP_NLPPARAM_DEFAULT(scip); } 317 * nlpparam.iterlimit = 42; 318 * SCIP_CALL( SCIPsolveNLPParam(scip, nlpparam) ); 319 * 320 * or, in one line: 321 * 322 * SCIP_CALL( SCIPsolveNLPParam(scip, (SCIP_NLPPARAM){ SCIP_NLPPARAM_DEFAULT(scip), .iterlimit = 42 }) ); 323 * 324 * To get the latter, also \ref SCIPsolveNLP can be used. 325 * 326 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 327 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 328 * 329 * @pre This method can be called if SCIP is in one of the following stages: 330 * - \ref SCIP_STAGE_INITSOLVE 331 * - \ref SCIP_STAGE_SOLVING 332 */ 333 SCIP_EXPORT 334 SCIP_RETCODE SCIPsolveNLPParam( 335 SCIP* scip, /**< SCIP data structure */ 336 SCIP_NLPPARAM param /**< NLP solve parameters */ 337 ); 338 339 /** solves the current NLP (or diving NLP if in diving mode) with non-default parameters given as optional arguments 340 * 341 * Typical use is 342 * 343 * SCIP_CALL( SCIPsolveNLP(scip) ); 344 * 345 * to solve with default parameters. 346 * Additionally, one or several values of SCIP_NLPPARAM can be set: 347 * 348 * SCIP_CALL( SCIPsolveNLP(scip, .iterlimit = 42, .verblevel = 1) ); //lint !e666 349 * 350 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 351 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 352 * 353 * @pre This method can be called if SCIP is in one of the following stages: 354 * - \ref SCIP_STAGE_INITSOLVE 355 * - \ref SCIP_STAGE_SOLVING 356 */ 357 /* the scip argument has been made part of the variadic arguments, since ISO C99 requires at least one argument for the "..." part and we want to allow leaving all parameters at default 358 * for the same reason, we have the .caller argument, so that macro SCIP_VARARGS_REST will have at least one arg to return 359 */ 360 #if !defined(_MSC_VER) || _MSC_VER >= 1800 361 #define SCIPsolveNLP(...) \ 362 SCIPsolveNLPParam(SCIP_VARARGS_FIRST((__VA_ARGS__, ignored)), \ 363 (SCIP_NLPPARAM){ SCIP_NLPPARAM_DEFAULT_INITS(SCIP_VARARGS_FIRST((__VA_ARGS__, ignored))), SCIP_VARARGS_REST(__VA_ARGS__, .caller = __FILE__) }) 364 #else 365 /* very old MSVC doesn't support C99's designated initializers, so have a version of SCIPsolveNLP() that just ignores given parameters 366 * (compilation of scip_nlp.c will print a warning) 367 */ 368 #define SCIPsolveNLP(...) \ 369 SCIPsolveNLPParam(SCIP_VARARGS_FIRST((__VA_ARGS__, ignored)), SCIP_NLPPARAM_DEFAULT_STATIC) 370 #endif 371 372 373 /** gets solution status of current NLP 374 * 375 * @pre This method can be called if SCIP is in one of the following stages: 376 * - \ref SCIP_STAGE_INITSOLVE 377 * - \ref SCIP_STAGE_SOLVING 378 */ 379 SCIP_EXPORT 380 SCIP_NLPSOLSTAT SCIPgetNLPSolstat( 381 SCIP* scip /**< SCIP data structure */ 382 ); 383 384 /** gets termination status of last NLP solve 385 * 386 * @pre This method can be called if SCIP is in one of the following stages: 387 * - \ref SCIP_STAGE_INITSOLVE 388 * - \ref SCIP_STAGE_SOLVING 389 */ 390 SCIP_EXPORT 391 SCIP_NLPTERMSTAT SCIPgetNLPTermstat( 392 SCIP* scip /**< SCIP data structure */ 393 ); 394 395 /** gives statistics (number of iterations, solving time, ...) of last NLP solve 396 * 397 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 398 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 399 * 400 * @pre This method can be called if SCIP is in one of the following stages: 401 * - \ref SCIP_STAGE_INITSOLVE 402 * - \ref SCIP_STAGE_SOLVING 403 */ 404 SCIP_EXPORT 405 SCIP_RETCODE SCIPgetNLPStatistics( 406 SCIP* scip, /**< SCIP data structure */ 407 SCIP_NLPSTATISTICS* statistics /**< pointer to store statistics */ 408 ); 409 410 /** gets objective value of current NLP 411 * 412 * @pre This method can be called if SCIP is in one of the following stages: 413 * - \ref SCIP_STAGE_INITSOLVE 414 * - \ref SCIP_STAGE_SOLVING 415 */ 416 SCIP_EXPORT 417 SCIP_Real SCIPgetNLPObjval( 418 SCIP* scip /**< SCIP data structure */ 419 ); 420 421 /** indicates whether a solution for the current NLP is available 422 * 423 * The solution may be optimal, feasible, or infeasible. 424 * Thus, returns whether the NLP solution status is at most \ref SCIP_NLPSOLSTAT_LOCINFEASIBLE. 425 * 426 * @pre This method can be called if SCIP is in one of the following stages: 427 * - \ref SCIP_STAGE_INITSOLVE 428 * - \ref SCIP_STAGE_SOLVING 429 */ 430 SCIP_EXPORT 431 SCIP_Bool SCIPhasNLPSolution( 432 SCIP* scip /**< SCIP data structure */ 433 ); 434 435 /** gets fractional variables of last NLP solution along with solution values and fractionalities 436 * 437 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 438 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 439 * 440 * @pre This method can be called if SCIP is in one of the following stages: 441 * - \ref SCIP_STAGE_INITSOLVE 442 * - \ref SCIP_STAGE_SOLVING 443 */ 444 SCIP_EXPORT 445 SCIP_RETCODE SCIPgetNLPFracVars( 446 SCIP* scip, /**< SCIP data structure */ 447 SCIP_VAR*** fracvars, /**< pointer to store the array of NLP fractional variables, or NULL */ 448 SCIP_Real** fracvarssol, /**< pointer to store the array of NLP fractional variables solution values, or NULL */ 449 SCIP_Real** fracvarsfrac, /**< pointer to store the array of NLP fractional variables fractionalities, or NULL */ 450 int* nfracvars, /**< pointer to store the number of NLP fractional variables , or NULL */ 451 int* npriofracvars /**< pointer to store the number of NLP fractional variables with maximal branching priority, or NULL */ 452 ); 453 454 /** writes current NLP to a file 455 * 456 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 457 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 458 * 459 * @pre This method can be called if SCIP is in one of the following stages: 460 * - \ref SCIP_STAGE_INITSOLVE 461 * - \ref SCIP_STAGE_SOLVING 462 */ 463 SCIP_EXPORT 464 SCIP_RETCODE SCIPwriteNLP( 465 SCIP* scip, /**< SCIP data structure */ 466 const char* filename /**< file name */ 467 ); 468 469 /** gets the NLP interface and problem used by the SCIP NLP 470 * 471 * @warning With the NLPI and its problem, all methods defined in \ref scip_nlpi.h and \ref pub_nlpi.h can be used. 472 * It needs to be ensured that the full internal state of the NLPI does not change or is recovered completely 473 * after the end of the method that uses the NLPI. In particular, if the NLP or its solution is manipulated 474 * (e.g. by calling one of the SCIPaddNlpi...() or the SCIPsolveNlpi() method), one has to check in advance 475 * whether the NLP is currently solved. If this is the case, one has to make sure that the internal solution 476 * status is recovered completely again. Additionally one has to resolve the NLP with 477 * SCIPsolveNlpi() in order to reinstall the internal solution status. 478 * 479 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 480 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 481 * 482 * @pre This method can be called if SCIP is in one of the following stages: 483 * - \ref SCIP_STAGE_INITSOLVE 484 * - \ref SCIP_STAGE_SOLVING 485 */ 486 SCIP_EXPORT 487 SCIP_RETCODE SCIPgetNLPI( 488 SCIP* scip, /**< SCIP data structure */ 489 SCIP_NLPI** nlpi, /**< pointer to store the NLP solver interface */ 490 SCIP_NLPIPROBLEM** nlpiproblem /**< pointer to store the NLP solver interface problem */ 491 ); 492 493 /**@} */ 494 495 /**@addtogroup PublicNLPDiveMethods 496 * 497 * @{ */ 498 499 /** initiates NLP diving 500 * 501 * Makes functions SCIPchgVarObjDiveNLP(), SCIPchgVarBoundsDiveNLP() and SCIPchgVarsBoundsDiveNLP() available. 502 * Further, SCIPsolveNLP() can be used to solve the diving NLP. 503 * 504 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 505 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 506 * 507 * @pre This method can be called if SCIP is in one of the following stages: 508 * - \ref SCIP_STAGE_INITSOLVE 509 * - \ref SCIP_STAGE_SOLVING 510 */ 511 SCIP_EXPORT 512 SCIP_RETCODE SCIPstartDiveNLP( 513 SCIP* scip /**< SCIP data structure */ 514 ); 515 516 /** ends NLP diving 517 * 518 * Resets changes made by SCIPchgVarObjDiveNLP(), SCIPchgVarBoundsDiveNLP(), and SCIPchgVarsBoundsDiveNLP(). 519 * 520 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 521 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 522 * 523 * @pre This method can be called if SCIP is in one of the following stages: 524 * - \ref SCIP_STAGE_INITSOLVE 525 * - \ref SCIP_STAGE_SOLVING 526 */ 527 SCIP_EXPORT 528 SCIP_RETCODE SCIPendDiveNLP( 529 SCIP* scip /**< SCIP data structure */ 530 ); 531 532 /** changes linear objective coefficient of a variable in diving NLP 533 * 534 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 535 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 536 * 537 * @pre This method can be called if SCIP is in one of the following stages: 538 * - \ref SCIP_STAGE_INITSOLVE 539 * - \ref SCIP_STAGE_SOLVING 540 */ 541 SCIP_EXPORT 542 SCIP_RETCODE SCIPchgVarObjDiveNLP( 543 SCIP* scip, /**< SCIP data structure */ 544 SCIP_VAR* var, /**< variable which coefficient to change */ 545 SCIP_Real coef /**< new value for coefficient */ 546 ); 547 548 /** changes bounds of a variable in diving NLP 549 * 550 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 551 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 552 * 553 * @pre This method can be called if SCIP is in one of the following stages: 554 * - \ref SCIP_STAGE_INITSOLVE 555 * - \ref SCIP_STAGE_SOLVING 556 */ 557 SCIP_EXPORT 558 SCIP_RETCODE SCIPchgVarBoundsDiveNLP( 559 SCIP* scip, /**< SCIP data structure */ 560 SCIP_VAR* var, /**< variable which bounds to change */ 561 SCIP_Real lb, /**< new lower bound */ 562 SCIP_Real ub /**< new upper bound */ 563 ); 564 565 /** changes bounds of a set of variables in diving NLP 566 * 567 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 568 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 569 * 570 * @pre This method can be called if SCIP is in one of the following stages: 571 * - \ref SCIP_STAGE_INITSOLVE 572 * - \ref SCIP_STAGE_SOLVING 573 */ 574 SCIP_EXPORT 575 SCIP_RETCODE SCIPchgVarsBoundsDiveNLP( 576 SCIP* scip, /**< SCIP data structure */ 577 int nvars, /**< number of variables which bounds to changes */ 578 SCIP_VAR** vars, /**< variables which bounds to change */ 579 SCIP_Real* lbs, /**< new lower bounds */ 580 SCIP_Real* ubs /**< new upper bounds */ 581 ); 582 583 /**@} */ 584 585 /**@addtogroup PublicNLRowMethods 586 * 587 * @{ 588 */ 589 590 /** creates and captures a nonlinear row 591 * 592 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 593 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 594 * 595 * @pre This method can be called if SCIP is in one of the following stages: 596 * - \ref SCIP_STAGE_PRESOLVED 597 * - \ref SCIP_STAGE_INITSOLVE 598 * - \ref SCIP_STAGE_SOLVING 599 */ 600 SCIP_EXPORT 601 SCIP_RETCODE SCIPcreateNlRow( 602 SCIP* scip, /**< SCIP data structure */ 603 SCIP_NLROW** nlrow, /**< buffer to store pointer to nonlinear row */ 604 const char* name, /**< name of nonlinear row */ 605 SCIP_Real constant, /**< constant */ 606 int nlinvars, /**< number of linear variables */ 607 SCIP_VAR** linvars, /**< linear variables, or NULL if nlinvars == 0 */ 608 SCIP_Real* lincoefs, /**< linear coefficients, or NULL if nlinvars == 0 */ 609 SCIP_EXPR* expr, /**< nonlinear expression, or NULL */ 610 SCIP_Real lhs, /**< left hand side */ 611 SCIP_Real rhs, /**< right hand side */ 612 SCIP_EXPRCURV curvature /**< curvature of the nonlinear row */ 613 ); 614 615 /** creates and captures a nonlinear row without any coefficients 616 * 617 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 618 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 619 * 620 * @pre This method can be called if SCIP is in one of the following stages: 621 * - \ref SCIP_STAGE_PRESOLVED 622 * - \ref SCIP_STAGE_INITSOLVE 623 * - \ref SCIP_STAGE_SOLVING 624 */ 625 SCIP_EXPORT 626 SCIP_RETCODE SCIPcreateEmptyNlRow( 627 SCIP* scip, /**< SCIP data structure */ 628 SCIP_NLROW** nlrow, /**< pointer to nonlinear row */ 629 const char* name, /**< name of nonlinear row */ 630 SCIP_Real lhs, /**< left hand side */ 631 SCIP_Real rhs /**< right hand side */ 632 ); 633 634 /** creates and captures a nonlinear row from a linear row 635 * 636 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 637 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 638 * 639 * @pre This method can be called if SCIP is in one of the following stages: 640 * - \ref SCIP_STAGE_PRESOLVED 641 * - \ref SCIP_STAGE_INITSOLVE 642 * - \ref SCIP_STAGE_SOLVING 643 */ 644 SCIP_EXPORT 645 SCIP_RETCODE SCIPcreateNlRowFromRow( 646 SCIP* scip, /**< SCIP data structure */ 647 SCIP_NLROW** nlrow, /**< pointer to nonlinear row */ 648 SCIP_ROW* row /**< the linear row to copy */ 649 ); 650 651 /** increases usage counter of a nonlinear row 652 * 653 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 654 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 655 * 656 * @pre This method can be called if SCIP is in one of the following stages: 657 * - \ref SCIP_STAGE_PRESOLVED 658 * - \ref SCIP_STAGE_INITSOLVE 659 * - \ref SCIP_STAGE_SOLVING 660 */ 661 SCIP_EXPORT 662 SCIP_RETCODE SCIPcaptureNlRow( 663 SCIP* scip, /**< SCIP data structure */ 664 SCIP_NLROW* nlrow /**< nonlinear row to capture */ 665 ); 666 667 /** decreases usage counter of a nonlinear row, and frees memory if necessary 668 * 669 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 670 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 671 * 672 * @pre This method can be called if SCIP is in one of the following stages: 673 * - \ref SCIP_STAGE_PRESOLVED 674 * - \ref SCIP_STAGE_INITSOLVE 675 * - \ref SCIP_STAGE_SOLVING 676 * - \ref SCIP_STAGE_EXITSOLVE 677 */ 678 SCIP_EXPORT 679 SCIP_RETCODE SCIPreleaseNlRow( 680 SCIP* scip, /**< SCIP data structure */ 681 SCIP_NLROW** nlrow /**< pointer to nonlinear row */ 682 ); 683 684 /** changes left hand side of a nonlinear row 685 * 686 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 687 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 688 * 689 * @pre This method can be called if SCIP is in one of the following stages: 690 * - \ref SCIP_STAGE_PRESOLVED 691 * - \ref SCIP_STAGE_INITSOLVE 692 * - \ref SCIP_STAGE_SOLVING 693 */ 694 SCIP_EXPORT 695 SCIP_RETCODE SCIPchgNlRowLhs( 696 SCIP* scip, /**< SCIP data structure */ 697 SCIP_NLROW* nlrow, /**< NLP nonlinear row */ 698 SCIP_Real lhs /**< new left hand side */ 699 ); 700 701 /** changes right hand side of a nonlinear row 702 * 703 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 704 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 705 * 706 * @pre This method can be called if SCIP is in one of the following stages: 707 * - \ref SCIP_STAGE_PRESOLVED 708 * - \ref SCIP_STAGE_INITSOLVE 709 * - \ref SCIP_STAGE_SOLVING 710 */ 711 SCIP_EXPORT 712 SCIP_RETCODE SCIPchgNlRowRhs( 713 SCIP* scip, /**< SCIP data structure */ 714 SCIP_NLROW* nlrow, /**< NLP nonlinear row */ 715 SCIP_Real rhs /**< new right hand side */ 716 ); 717 718 /** changes constant of a nonlinear row 719 * 720 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 721 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 722 * 723 * @pre This method can be called if SCIP is in one of the following stages: 724 * - \ref SCIP_STAGE_PRESOLVED 725 * - \ref SCIP_STAGE_INITSOLVE 726 * - \ref SCIP_STAGE_SOLVING 727 */ 728 SCIP_EXPORT 729 SCIP_RETCODE SCIPchgNlRowConstant( 730 SCIP* scip, /**< SCIP data structure */ 731 SCIP_NLROW* nlrow, /**< NLP row */ 732 SCIP_Real constant /**< new value for constant */ 733 ); 734 735 /** set curvature of a nonlinear row */ 736 SCIP_EXPORT 737 void SCIPsetNlRowCurvature( 738 SCIP* scip, /**< SCIP data structure */ 739 SCIP_NLROW* nlrow, /**< NLP row */ 740 SCIP_EXPRCURV curvature /**< curvature of NLP row */ 741 ); 742 743 /** adds variable with a linear coefficient to a nonlinear row 744 * 745 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 746 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 747 * 748 * @pre This method can be called if SCIP is in one of the following stages: 749 * - \ref SCIP_STAGE_PRESOLVED 750 * - \ref SCIP_STAGE_INITSOLVE 751 * - \ref SCIP_STAGE_SOLVING 752 */ 753 SCIP_EXPORT 754 SCIP_RETCODE SCIPaddLinearCoefToNlRow( 755 SCIP* scip, /**< SCIP data structure */ 756 SCIP_NLROW* nlrow, /**< NLP row */ 757 SCIP_VAR* var, /**< problem variable */ 758 SCIP_Real val /**< value of coefficient in linear part of row */ 759 ); 760 761 /** adds variables with linear coefficients to a row 762 * 763 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 764 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 765 * 766 * @pre This method can be called if SCIP is in one of the following stages: 767 * - \ref SCIP_STAGE_PRESOLVED 768 * - \ref SCIP_STAGE_INITSOLVE 769 * - \ref SCIP_STAGE_SOLVING 770 */ 771 SCIP_EXPORT 772 SCIP_RETCODE SCIPaddLinearCoefsToNlRow( 773 SCIP* scip, /**< SCIP data structure */ 774 SCIP_NLROW* nlrow, /**< NLP row */ 775 int nvars, /**< number of variables to add to the row */ 776 SCIP_VAR** vars, /**< problem variables to add */ 777 SCIP_Real* vals /**< values of coefficients in linear part of row */ 778 ); 779 780 /** changes linear coefficient of a variables in a nonlinear row 781 * 782 * Setting the coefficient to 0.0 means that it is removed from the row. 783 * The variable does not need to exists before. 784 * 785 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 786 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 787 * 788 * @pre This method can be called if SCIP is in one of the following stages: 789 * - \ref SCIP_STAGE_PRESOLVED 790 * - \ref SCIP_STAGE_INITSOLVE 791 * - \ref SCIP_STAGE_SOLVING 792 */ 793 SCIP_EXPORT 794 SCIP_RETCODE SCIPchgNlRowLinearCoef( 795 SCIP* scip, /**< SCIP data structure */ 796 SCIP_NLROW* nlrow, /**< NLP row */ 797 SCIP_VAR* var, /**< variable */ 798 SCIP_Real coef /**< new value of coefficient */ 799 ); 800 801 /** sets or deletes expression in a nonlinear row 802 * 803 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 804 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 805 * 806 * @pre This method can be called if SCIP is in one of the following stages: 807 * - \ref SCIP_STAGE_PRESOLVED 808 * - \ref SCIP_STAGE_INITSOLVE 809 * - \ref SCIP_STAGE_SOLVING 810 */ 811 SCIP_EXPORT 812 SCIP_RETCODE SCIPsetNlRowExpr( 813 SCIP* scip, /**< SCIP data structure */ 814 SCIP_NLROW* nlrow, /**< NLP row */ 815 SCIP_EXPR* expr /**< expression, or NULL */ 816 ); 817 818 /** recalculates the activity of a nonlinear row in the last NLP solution 819 * 820 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 821 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 822 * 823 * @pre This method can be called if SCIP is in one of the following stages: 824 * - \ref SCIP_STAGE_PRESOLVED 825 * - \ref SCIP_STAGE_INITSOLVE 826 * - \ref SCIP_STAGE_SOLVING 827 */ 828 SCIP_EXPORT 829 SCIP_RETCODE SCIPrecalcNlRowNLPActivity( 830 SCIP* scip, /**< SCIP data structure */ 831 SCIP_NLROW* nlrow /**< NLP nonlinear row */ 832 ); 833 834 /** returns the activity of a nonlinear row in the last NLP solution 835 * 836 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 837 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 838 * 839 * @pre This method can be called if SCIP is in one of the following stages: 840 * - \ref SCIP_STAGE_INITSOLVE 841 * - \ref SCIP_STAGE_SOLVING 842 */ 843 SCIP_EXPORT 844 SCIP_RETCODE SCIPgetNlRowNLPActivity( 845 SCIP* scip, /**< SCIP data structure */ 846 SCIP_NLROW* nlrow, /**< NLP nonlinear row */ 847 SCIP_Real* activity /**< pointer to store activity value */ 848 ); 849 850 /** gives the feasibility of a nonlinear row in the last NLP solution: negative value means infeasibility 851 * 852 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 853 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 854 * 855 * @pre This method can be called if SCIP is in one of the following stages: 856 * - \ref SCIP_STAGE_INITSOLVE 857 * - \ref SCIP_STAGE_SOLVING 858 */ 859 SCIP_EXPORT 860 SCIP_RETCODE SCIPgetNlRowNLPFeasibility( 861 SCIP* scip, /**< SCIP data structure */ 862 SCIP_NLROW* nlrow, /**< NLP nonlinear row */ 863 SCIP_Real* feasibility /**< pointer to store feasibility value */ 864 ); 865 866 /** recalculates the activity of a nonlinear row for the current pseudo solution 867 * 868 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 869 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 870 * 871 * @pre This method can be called if SCIP is in one of the following stages: 872 * - \ref SCIP_STAGE_INITSOLVE 873 * - \ref SCIP_STAGE_SOLVING 874 */ 875 SCIP_EXPORT 876 SCIP_RETCODE SCIPrecalcNlRowPseudoActivity( 877 SCIP* scip, /**< SCIP data structure */ 878 SCIP_NLROW* nlrow /**< NLP nonlinear row */ 879 ); 880 881 /** gives the activity of a nonlinear row for the current pseudo solution 882 * 883 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 884 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 885 * 886 * @pre This method can be called if SCIP is in one of the following stages: 887 * - \ref SCIP_STAGE_INITSOLVE 888 * - \ref SCIP_STAGE_SOLVING 889 */ 890 SCIP_EXPORT 891 SCIP_RETCODE SCIPgetNlRowPseudoActivity( 892 SCIP* scip, /**< SCIP data structure */ 893 SCIP_NLROW* nlrow, /**< NLP nonlinear row */ 894 SCIP_Real* pseudoactivity /**< pointer to store pseudo activity value */ 895 ); 896 897 /** gives the feasibility of a nonlinear row for the current pseudo solution: negative value means infeasibility 898 * 899 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 900 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 901 * 902 * @pre This method can be called if SCIP is in one of the following stages: 903 * - \ref SCIP_STAGE_INITSOLVE 904 * - \ref SCIP_STAGE_SOLVING 905 */ 906 SCIP_EXPORT 907 SCIP_RETCODE SCIPgetNlRowPseudoFeasibility( 908 SCIP* scip, /**< SCIP data structure */ 909 SCIP_NLROW* nlrow, /**< NLP nonlinear row */ 910 SCIP_Real* pseudofeasibility /**< pointer to store pseudo feasibility value */ 911 ); 912 913 /** recalculates the activity of a nonlinear row in the last NLP or pseudo solution 914 * 915 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 916 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 917 * 918 * @pre This method can be called if SCIP is in one of the following stages: 919 * - \ref SCIP_STAGE_INITSOLVE 920 * - \ref SCIP_STAGE_SOLVING 921 */ 922 SCIP_EXPORT 923 SCIP_RETCODE SCIPrecalcNlRowActivity( 924 SCIP* scip, /**< SCIP data structure */ 925 SCIP_NLROW* nlrow /**< NLP nonlinear row */ 926 ); 927 928 /** gives the activity of a nonlinear row in the last NLP or pseudo solution 929 * 930 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 931 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 932 * 933 * @pre This method can be called if SCIP is in one of the following stages: 934 * - \ref SCIP_STAGE_INITSOLVE 935 * - \ref SCIP_STAGE_SOLVING 936 */ 937 SCIP_EXPORT 938 SCIP_RETCODE SCIPgetNlRowActivity( 939 SCIP* scip, /**< SCIP data structure */ 940 SCIP_NLROW* nlrow, /**< NLP nonlinear row */ 941 SCIP_Real* activity /**< pointer to store activity value */ 942 ); 943 944 /** gives the feasibility of a nonlinear row in the last NLP or pseudo solution 945 * 946 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 947 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 948 * 949 * @pre This method can be called if SCIP is in one of the following stages: 950 * - \ref SCIP_STAGE_INITSOLVE 951 * - \ref SCIP_STAGE_SOLVING 952 */ 953 SCIP_EXPORT 954 SCIP_RETCODE SCIPgetNlRowFeasibility( 955 SCIP* scip, /**< SCIP data structure */ 956 SCIP_NLROW* nlrow, /**< NLP nonlinear row */ 957 SCIP_Real* feasibility /**< pointer to store feasibility value */ 958 ); 959 960 /** gives the activity of a nonlinear row for the given primal solution or NLP solution or pseudo solution 961 * 962 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 963 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 964 * 965 * @pre This method can be called if SCIP is in one of the following stages: 966 * - \ref SCIP_STAGE_INITSOLVE 967 * - \ref SCIP_STAGE_SOLVING 968 */ 969 SCIP_EXPORT 970 SCIP_RETCODE SCIPgetNlRowSolActivity( 971 SCIP* scip, /**< SCIP data structure */ 972 SCIP_NLROW* nlrow, /**< NLP nonlinear row */ 973 SCIP_SOL* sol, /**< primal CIP solution, or NULL for NLP solution of pseudo solution */ 974 SCIP_Real* activity /**< pointer to store activity value */ 975 ); 976 977 /** gives the feasibility of a nonlinear row for the given primal solution 978 * 979 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 980 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 981 * 982 * @pre This method can be called if SCIP is in one of the following stages: 983 * - \ref SCIP_STAGE_INITSOLVE 984 * - \ref SCIP_STAGE_SOLVING 985 */ 986 SCIP_EXPORT 987 SCIP_RETCODE SCIPgetNlRowSolFeasibility( 988 SCIP* scip, /**< SCIP data structure */ 989 SCIP_NLROW* nlrow, /**< NLP nonlinear row */ 990 SCIP_SOL* sol, /**< primal CIP solution */ 991 SCIP_Real* feasibility /**< pointer to store feasibility value */ 992 ); 993 994 /** gives the minimal and maximal activity of a nonlinear row w.r.t. the variable's bounds 995 * 996 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 997 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 998 * 999 * @pre This method can be called if SCIP is in one of the following stages: 1000 * - \ref SCIP_STAGE_PRESOLVED 1001 * - \ref SCIP_STAGE_INITSOLVE 1002 * - \ref SCIP_STAGE_SOLVING 1003 */ 1004 SCIP_EXPORT 1005 SCIP_RETCODE SCIPgetNlRowActivityBounds( 1006 SCIP* scip, /**< SCIP data structure */ 1007 SCIP_NLROW* nlrow, /**< NLP row */ 1008 SCIP_Real* minactivity, /**< buffer to store minimal activity, or NULL */ 1009 SCIP_Real* maxactivity /**< buffer to store maximal activity, or NULL */ 1010 ); 1011 1012 /** prints a nonlinear row to file stream 1013 * 1014 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 1015 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 1016 * 1017 * @pre This method can be called if SCIP is in one of the following stages: 1018 * - \ref SCIP_STAGE_PRESOLVED 1019 * - \ref SCIP_STAGE_INITSOLVE 1020 * - \ref SCIP_STAGE_SOLVING 1021 */ 1022 SCIP_EXPORT 1023 SCIP_RETCODE SCIPprintNlRow( 1024 SCIP* scip, /**< SCIP data structure */ 1025 SCIP_NLROW* nlrow, /**< NLP row */ 1026 FILE* file /**< output file (or NULL for standard output) */ 1027 ); 1028 1029 /**@} */ 1030 1031 #ifdef __cplusplus 1032 } 1033 #endif 1034 1035 #endif 1036