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 nlp.h 17 * @ingroup INTERNALAPI 18 * @brief internal 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_NLP_H__ 26 #define __SCIP_NLP_H__ 27 28 29 #include <stdio.h> 30 31 #include "scip/def.h" 32 #include "blockmemshell/memory.h" 33 #include "scip/type_event.h" 34 #include "scip/type_set.h" 35 #include "scip/type_stat.h" 36 #include "scip/type_misc.h" 37 #include "scip/type_lp.h" 38 #include "scip/type_var.h" 39 #include "scip/type_prob.h" 40 #include "scip/type_sol.h" 41 #include "scip/type_primal.h" 42 #include "scip/pub_nlp.h" 43 44 #ifdef __cplusplus 45 extern "C" { 46 #endif 47 48 /**@name Expressions and Expression tree methods */ 49 /**@{ */ 50 51 /** removes fixed variables from an expression tree, so that at exit all variables are active */ 52 SCIP_RETCODE SCIPexprtreeRemoveFixedVars( 53 SCIP_EXPRTREE* tree, /**< expression tree */ 54 SCIP_SET* set, /**< global SCIP settings */ 55 SCIP_Bool* changed, /**< buffer to store whether the tree was changed, i.e., whether there was a fixed variable */ 56 int* varpos, /**< array of length at least tree->nvars to store new indices of previously existing variables in expression tree, or -1 if variable was removed; set to NULL if not of interest */ 57 int* newvarsstart /**< buffer to store index in tree->vars array where new variables begin, or NULL if not of interest */ 58 ); 59 60 /**@} */ 61 62 /**@name Nonlinear row methods */ 63 /**@{ */ 64 65 /** create a new nonlinear row 66 * the new row is already captured 67 */ 68 SCIP_RETCODE SCIPnlrowCreate( 69 SCIP_NLROW** nlrow, /**< buffer to store pointer to nonlinear row */ 70 BMS_BLKMEM* blkmem, /**< block memory */ 71 SCIP_SET* set, /**< global SCIP settings */ 72 const char* name, /**< name of nonlinear row */ 73 SCIP_Real constant, /**< constant */ 74 int nlinvars, /**< number of linear variables */ 75 SCIP_VAR** linvars, /**< linear variables, or NULL if nlinvars == 0 */ 76 SCIP_Real* lincoefs, /**< linear coefficients, or NULL if nlinvars == 0 */ 77 int nquadvars, /**< number variables in quadratic terms */ 78 SCIP_VAR** quadvars, /**< variables in quadratic terms, or NULL if nquadvars == 0 */ 79 int nquadelems, /**< number of entries in quadratic term matrix */ 80 SCIP_QUADELEM* quadelems, /**< elements of quadratic term matrix, or NULL if nquadelems == 0 */ 81 SCIP_EXPRTREE* exprtree, /**< expression tree, or NULL */ 82 SCIP_Real lhs, /**< left hand side */ 83 SCIP_Real rhs, /**< right hand side */ 84 SCIP_EXPRCURV curvature /**< curvature of the nonlinear row */ 85 ); 86 87 /** create a nonlinear row that is a copy of a given row 88 * the new row is already captured 89 */ 90 SCIP_RETCODE SCIPnlrowCreateCopy( 91 SCIP_NLROW** nlrow, /**< buffer to store pointer to nonlinear row */ 92 BMS_BLKMEM* blkmem, /**< block memory */ 93 SCIP_SET* set, /**< global SCIP settings */ 94 SCIP_NLROW* sourcenlrow /**< nonlinear row to copy */ 95 ); 96 97 /** create a new nonlinear row from a linear row 98 * the new row is already captured 99 */ 100 SCIP_RETCODE SCIPnlrowCreateFromRow( 101 SCIP_NLROW** nlrow, /**< buffer to store pointer to nonlinear row */ 102 BMS_BLKMEM* blkmem, /**< block memory */ 103 SCIP_SET* set, /**< global SCIP settings */ 104 SCIP_ROW* row /**< the linear row to copy */ 105 ); 106 107 /** frees a nonlinear row */ 108 SCIP_RETCODE SCIPnlrowFree( 109 SCIP_NLROW** nlrow, /**< pointer to NLP row */ 110 BMS_BLKMEM* blkmem /**< block memory */ 111 ); 112 113 /** output nonlinear row to file stream */ 114 SCIP_RETCODE SCIPnlrowPrint( 115 SCIP_NLROW* nlrow, /**< NLP row */ 116 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 117 FILE* file /**< output file (or NULL for standard output) */ 118 ); 119 120 /** increases usage counter of NLP nonlinear row */ 121 void SCIPnlrowCapture( 122 SCIP_NLROW* nlrow /**< nonlinear row to capture */ 123 ); 124 125 /** decreases usage counter of NLP nonlinear row */ 126 SCIP_RETCODE SCIPnlrowRelease( 127 SCIP_NLROW** nlrow, /**< nonlinear row to free */ 128 BMS_BLKMEM* blkmem, /**< block memory */ 129 SCIP_SET* set /**< global SCIP settings */ 130 ); 131 132 /** ensures, that linear coefficient array of nonlinear row can store at least num entries */ 133 SCIP_RETCODE SCIPnlrowEnsureLinearSize( 134 SCIP_NLROW* nlrow, /**< NLP row */ 135 BMS_BLKMEM* blkmem, /**< block memory */ 136 SCIP_SET* set, /**< global SCIP settings */ 137 int num /**< minimum number of entries to store */ 138 ); 139 140 /** adds a previously non existing linear coefficient to an NLP nonlinear row */ 141 SCIP_RETCODE SCIPnlrowAddLinearCoef( 142 SCIP_NLROW* nlrow, /**< NLP nonlinear row */ 143 BMS_BLKMEM* blkmem, /**< block memory */ 144 SCIP_SET* set, /**< global SCIP settings */ 145 SCIP_STAT* stat, /**< problem statistics data */ 146 SCIP_NLP* nlp, /**< current NLP data */ 147 SCIP_VAR* var, /**< variable */ 148 SCIP_Real val /**< value of coefficient */ 149 ); 150 151 /** deletes linear coefficient from nonlinear row */ 152 SCIP_RETCODE SCIPnlrowDelLinearCoef( 153 SCIP_NLROW* nlrow, /**< nonlinear row to be changed */ 154 SCIP_SET* set, /**< global SCIP settings */ 155 SCIP_STAT* stat, /**< problem statistics data */ 156 SCIP_NLP* nlp, /**< current NLP data */ 157 SCIP_VAR* var /**< coefficient to be deleted */ 158 ); 159 160 /** changes or adds a linear coefficient to a nonlinear row */ 161 SCIP_RETCODE SCIPnlrowChgLinearCoef( 162 SCIP_NLROW* nlrow, /**< nonlinear row */ 163 BMS_BLKMEM* blkmem, /**< block memory */ 164 SCIP_SET* set, /**< global SCIP settings */ 165 SCIP_STAT* stat, /**< problem statistics data */ 166 SCIP_NLP* nlp, /**< current NLP data */ 167 SCIP_VAR* var, /**< variable */ 168 SCIP_Real coef /**< new value of coefficient */ 169 ); 170 171 /** ensures, that quadratic variables array of nonlinear row can store at least num entries */ 172 SCIP_RETCODE SCIPnlrowEnsureQuadVarsSize( 173 SCIP_NLROW* nlrow, /**< NLP row */ 174 BMS_BLKMEM* blkmem, /**< block memory */ 175 SCIP_SET* set, /**< global SCIP settings */ 176 int num /**< minimum number of entries to store */ 177 ); 178 179 /** adds variable to quadvars array of row */ 180 SCIP_RETCODE SCIPnlrowAddQuadVar( 181 SCIP_NLROW* nlrow, /**< nonlinear row */ 182 BMS_BLKMEM* blkmem, /**< block memory */ 183 SCIP_SET* set, /**< global SCIP settings */ 184 SCIP_VAR* var /**< variable to search for */ 185 ); 186 187 /** ensures, that quadratic elements array of nonlinear row can store at least num entries */ 188 SCIP_RETCODE SCIPnlrowEnsureQuadElementsSize( 189 SCIP_NLROW* nlrow, /**< NLP row */ 190 BMS_BLKMEM* blkmem, /**< block memory */ 191 SCIP_SET* set, /**< global SCIP settings */ 192 int num /**< minimum number of entries to store */ 193 ); 194 195 /** adds a previously non existing quadratic element to an NLP nonlinear row */ 196 SCIP_RETCODE SCIPnlrowAddQuadElement( 197 SCIP_NLROW* nlrow, /**< NLP nonlinear row */ 198 BMS_BLKMEM* blkmem, /**< block memory */ 199 SCIP_SET* set, /**< global SCIP settings */ 200 SCIP_STAT* stat, /**< problem statistics data */ 201 SCIP_NLP* nlp, /**< current NLP data */ 202 SCIP_QUADELEM elem /**< quadratic element to add */ 203 ); 204 205 /** deletes quadratic element from nonlinear row */ 206 SCIP_RETCODE SCIPnlrowDelQuadElement( 207 SCIP_NLROW* nlrow, /**< nonlinear row to be changed */ 208 SCIP_SET* set, /**< global SCIP settings */ 209 SCIP_STAT* stat, /**< problem statistics data */ 210 SCIP_NLP* nlp, /**< current NLP data */ 211 int idx1, /**< index of first variable in element */ 212 int idx2 /**< index of second variable in element */ 213 ); 214 215 /** changes or adds a quadratic element to a nonlinear row */ 216 SCIP_RETCODE SCIPnlrowChgQuadElem( 217 SCIP_NLROW* nlrow, /**< nonlinear row */ 218 BMS_BLKMEM* blkmem, /**< block memory */ 219 SCIP_SET* set, /**< global SCIP settings */ 220 SCIP_STAT* stat, /**< problem statistics data */ 221 SCIP_NLP* nlp, /**< current NLP data */ 222 SCIP_QUADELEM elem /**< new quadratic element */ 223 ); 224 225 /** replaces or deletes an expression tree in nonlinear row */ 226 SCIP_RETCODE SCIPnlrowChgExprtree( 227 SCIP_NLROW* nlrow, /**< nonlinear row */ 228 BMS_BLKMEM* blkmem, /**< block memory */ 229 SCIP_SET* set, /**< global SCIP settings */ 230 SCIP_STAT* stat, /**< problem statistics data */ 231 SCIP_NLP* nlp, /**< current NLP data */ 232 SCIP_EXPRTREE* exprtree /**< new expression tree, or NULL to delete current one */ 233 ); 234 235 /** changes a parameter in an expression of a nonlinear row */ 236 SCIP_RETCODE SCIPnlrowChgExprtreeParam( 237 SCIP_NLROW* nlrow, /**< nonlinear row */ 238 BMS_BLKMEM* blkmem, /**< block memory */ 239 SCIP_SET* set, /**< global SCIP settings */ 240 SCIP_STAT* stat, /**< problem statistics data */ 241 SCIP_NLP* nlp, /**< current NLP data */ 242 int paramidx, /**< index of parameter in expression tree's parameter array */ 243 SCIP_Real paramval /**< new value of parameter */ 244 ); 245 246 /** changes all parameters in an expression of a nonlinear row */ 247 SCIP_RETCODE SCIPnlrowChgExprtreeParams( 248 SCIP_NLROW* nlrow, /**< nonlinear row */ 249 BMS_BLKMEM* blkmem, /**< block memory */ 250 SCIP_SET* set, /**< global SCIP settings */ 251 SCIP_STAT* stat, /**< problem statistics data */ 252 SCIP_NLP* nlp, /**< current NLP data */ 253 SCIP_Real* paramvals /**< new values of parameters */ 254 ); 255 256 /** changes constant of nonlinear row */ 257 SCIP_RETCODE SCIPnlrowChgConstant( 258 SCIP_NLROW* nlrow, /**< nonlinear row */ 259 SCIP_SET* set, /**< global SCIP settings */ 260 SCIP_STAT* stat, /**< problem statistics data */ 261 SCIP_NLP* nlp, /**< current NLP data */ 262 SCIP_Real constant /**< new constant */ 263 ); 264 265 /** changes left hand side of nonlinear row */ 266 SCIP_RETCODE SCIPnlrowChgLhs( 267 SCIP_NLROW* nlrow, /**< nonlinear row */ 268 SCIP_SET* set, /**< global SCIP settings */ 269 SCIP_STAT* stat, /**< problem statistics data */ 270 SCIP_NLP* nlp, /**< current NLP data */ 271 SCIP_Real lhs /**< new left hand side */ 272 ); 273 274 /** changes right hand side of nonlinear row */ 275 SCIP_RETCODE SCIPnlrowChgRhs( 276 SCIP_NLROW* nlrow, /**< nonlinear row */ 277 SCIP_SET* set, /**< global SCIP settings */ 278 SCIP_STAT* stat, /**< problem statistics data */ 279 SCIP_NLP* nlp, /**< current NLP data */ 280 SCIP_Real rhs /**< new right hand side */ 281 ); 282 283 /** removes (or substitutes) all fixed, negated, aggregated, multi-aggregated variables from the linear, quadratic, and nonquadratic terms of a nonlinear row */ 284 SCIP_RETCODE SCIPnlrowRemoveFixedVars( 285 SCIP_NLROW* nlrow, /**< nonlinear row */ 286 BMS_BLKMEM* blkmem, /**< block memory */ 287 SCIP_SET* set, /**< global SCIP settings */ 288 SCIP_STAT* stat, /**< problem statistics data */ 289 SCIP_NLP* nlp /**< current NLP data */ 290 ); 291 292 /** recalculates the current activity of a nonlinear row in the current NLP solution */ 293 SCIP_RETCODE SCIPnlrowRecalcNLPActivity( 294 SCIP_NLROW* nlrow, /**< nonlinear row */ 295 SCIP_SET* set, /**< global SCIP settings */ 296 SCIP_STAT* stat, /**< problem statistics */ 297 SCIP_NLP* nlp /**< current NLP data */ 298 ); 299 300 /** gives the activity of a nonlinear row in the current NLP solution */ 301 SCIP_RETCODE SCIPnlrowGetNLPActivity( 302 SCIP_NLROW* nlrow, /**< nonlinear row */ 303 SCIP_SET* set, /**< global SCIP settings */ 304 SCIP_STAT* stat, /**< problem statistics */ 305 SCIP_NLP* nlp, /**< current NLP data */ 306 SCIP_Real* activity /**< buffer to store activity value */ 307 ); 308 309 /** gives the feasibility of a nonlinear row in the current NLP solution: negative value means infeasibility */ 310 SCIP_RETCODE SCIPnlrowGetNLPFeasibility( 311 SCIP_NLROW* nlrow, /**< nonlinear row */ 312 SCIP_SET* set, /**< global SCIP settings */ 313 SCIP_STAT* stat, /**< problem statistics */ 314 SCIP_NLP* nlp, /**< current NLP data */ 315 SCIP_Real* feasibility /**< buffer to store feasibility value */ 316 ); 317 318 /** calculates the current pseudo activity of a nonlinear row */ 319 SCIP_RETCODE SCIPnlrowRecalcPseudoActivity( 320 SCIP_NLROW* nlrow, /**< nonlinear row */ 321 SCIP_SET* set, /**< global SCIP settings */ 322 SCIP_STAT* stat /**< problem statistics */ 323 ); 324 325 /** returns the pseudo activity of a nonlinear row in the current pseudo solution */ 326 SCIP_RETCODE SCIPnlrowGetPseudoActivity( 327 SCIP_NLROW* nlrow, /**< nonlinear row */ 328 SCIP_SET* set, /**< global SCIP settings */ 329 SCIP_STAT* stat, /**< problem statistics */ 330 SCIP_Real* pseudoactivity /**< buffer to store pseudo activity value */ 331 ); 332 333 /** returns the pseudo feasibility of a nonlinear row in the current pseudo solution: negative value means infeasibility */ 334 SCIP_RETCODE SCIPnlrowGetPseudoFeasibility( 335 SCIP_NLROW* nlrow, /**< nonlinear row */ 336 SCIP_SET* set, /**< global SCIP settings */ 337 SCIP_STAT* stat, /**< problem statistics */ 338 SCIP_Real* pseudofeasibility /**< buffer to store pseudo feasibility value */ 339 ); 340 341 /** returns the activity of a nonlinear row for a given solution */ 342 SCIP_RETCODE SCIPnlrowGetSolActivity( 343 SCIP_NLROW* nlrow, /**< nonlinear row */ 344 SCIP_SET* set, /**< global SCIP settings */ 345 SCIP_STAT* stat, /**< problem statistics data */ 346 SCIP_SOL* sol, /**< primal CIP solution */ 347 SCIP_Real* activity /**< buffer to store activity value */ 348 ); 349 350 /** returns the feasibility of a nonlinear row for the given solution */ 351 SCIP_RETCODE SCIPnlrowGetSolFeasibility( 352 SCIP_NLROW* nlrow, /**< nonlinear row */ 353 SCIP_SET* set, /**< global SCIP settings */ 354 SCIP_STAT* stat, /**< problem statistics data */ 355 SCIP_SOL* sol, /**< primal CIP solution */ 356 SCIP_Real* feasibility /**< buffer to store feasibility value */ 357 ); 358 359 /** returns the minimal activity of a nonlinear row w.r.t. the variables' bounds */ 360 SCIP_RETCODE SCIPnlrowGetActivityBounds( 361 SCIP_NLROW* nlrow, /**< nonlinear row */ 362 SCIP_SET* set, /**< global SCIP settings */ 363 SCIP_STAT* stat, /**< problem statistics data */ 364 SCIP_Real* minactivity, /**< buffer to store minimal activity, or NULL */ 365 SCIP_Real* maxactivity /**< buffer to store maximal activity, or NULL */ 366 ); 367 368 /** returns whether the nonlinear row is redundant w.r.t. the variables' bounds */ 369 SCIP_RETCODE SCIPnlrowIsRedundant( 370 SCIP_NLROW* nlrow, /**< nonlinear row */ 371 SCIP_SET* set, /**< global SCIP settings */ 372 SCIP_STAT* stat, /**< problem statistics data */ 373 SCIP_Bool* isredundant /**< buffer to store whether row is redundant */ 374 ); 375 376 /**@} */ 377 378 /**@name NLP methods */ 379 /**@{ */ 380 381 /** includes event handler that is used by NLP */ 382 SCIP_RETCODE SCIPnlpInclude( 383 SCIP_SET* set, /**< global SCIP settings */ 384 BMS_BLKMEM* blkmem /**< block memory */ 385 ); 386 387 /** construct a new empty NLP */ 388 SCIP_RETCODE SCIPnlpCreate( 389 SCIP_NLP** nlp, /**< NLP handler, call by reference */ 390 BMS_BLKMEM* blkmem, /**< block memory */ 391 SCIP_SET* set, /**< global SCIP settings */ 392 SCIP_STAT* stat, /**< problem statistics */ 393 const char* name, /**< problem name */ 394 int nvars_estimate /**< an estimate on the number of variables that may be added to the NLP later */ 395 ); 396 397 /** frees NLP data object */ 398 SCIP_RETCODE SCIPnlpFree( 399 SCIP_NLP** nlp, /**< pointer to NLP data object */ 400 BMS_BLKMEM* blkmem, /**< block memory */ 401 SCIP_SET* set, /**< global SCIP settings */ 402 SCIP_EVENTQUEUE* eventqueue, /**< event queue */ 403 SCIP_LP* lp /**< SCIP LP, needed for releasing variables */ 404 ); 405 406 /** resets the NLP to the empty NLP by removing all variables and rows from NLP, 407 * releasing all rows, and flushing the changes to the NLP solver 408 */ 409 SCIP_RETCODE SCIPnlpReset( 410 SCIP_NLP* nlp, /**< NLP data */ 411 BMS_BLKMEM* blkmem, /**< block memory */ 412 SCIP_SET* set, /**< global SCIP settings */ 413 SCIP_EVENTQUEUE* eventqueue, /**< event queue */ 414 SCIP_LP* lp /**< SCIP LP, needed for releasing variables */ 415 ); 416 417 /** currently a dummy function that always returns TRUE */ 418 SCIP_Bool SCIPnlpHasCurrentNodeNLP( 419 SCIP_NLP* nlp /**< NLP data */ 420 ); 421 422 /** ensures, that variables array of NLP can store at least num entries */ 423 SCIP_RETCODE SCIPnlpEnsureVarsSize( 424 SCIP_NLP* nlp, /**< NLP data */ 425 BMS_BLKMEM* blkmem, /**< block memory */ 426 SCIP_SET* set, /**< global SCIP settings */ 427 int num /**< minimum number of entries to store */ 428 ); 429 430 /** adds a variable to the NLP and captures the variable */ 431 SCIP_RETCODE SCIPnlpAddVar( 432 SCIP_NLP* nlp, /**< NLP data */ 433 BMS_BLKMEM* blkmem, /**< block memory */ 434 SCIP_SET* set, /**< global SCIP settings */ 435 SCIP_VAR* var /**< variable */ 436 ); 437 438 /** adds a set of variables to the NLP and captures the variables */ 439 SCIP_RETCODE SCIPnlpAddVars( 440 SCIP_NLP* nlp, /**< NLP data */ 441 BMS_BLKMEM* blkmem, /**< block memory */ 442 SCIP_SET* set, /**< global SCIP settings */ 443 int nvars, /**< number of variables to add */ 444 SCIP_VAR** vars /**< variables to add */ 445 ); 446 447 /** deletes a variable from the NLP and releases the variable */ 448 SCIP_RETCODE SCIPnlpDelVar( 449 SCIP_NLP* nlp, /**< NLP data */ 450 BMS_BLKMEM* blkmem, /**< block memory */ 451 SCIP_SET* set, /**< global SCIP settings */ 452 SCIP_EVENTQUEUE* eventqueue, /**< event queue */ 453 SCIP_LP* lp, /**< SCIP LP, needed to release variable */ 454 SCIP_VAR* var /**< variable */ 455 ); 456 457 /** ensures, that nonlinear rows array of NLP can store at least num entries */ 458 SCIP_RETCODE SCIPnlpEnsureNlRowsSize( 459 SCIP_NLP* nlp, /**< NLP data */ 460 BMS_BLKMEM* blkmem, /**< block memory */ 461 SCIP_SET* set, /**< global SCIP settings */ 462 int num /**< minimum number of entries to store */ 463 ); 464 465 /** adds a nonlinear row to the NLP and captures it 466 * all variables of the row need to be present in the NLP */ 467 SCIP_RETCODE SCIPnlpAddNlRow( 468 SCIP_NLP* nlp, /**< NLP data */ 469 BMS_BLKMEM* blkmem, /**< block memory */ 470 SCIP_SET* set, /**< global SCIP settings */ 471 SCIP_STAT* stat, /**< problem statistics data */ 472 SCIP_NLROW* nlrow /**< nonlinear row */ 473 ); 474 475 /** adds nonlinear rows to the NLP and captures them 476 * all variables of the row need to be present in the NLP */ 477 SCIP_RETCODE SCIPnlpAddNlRows( 478 SCIP_NLP* nlp, /**< NLP data */ 479 BMS_BLKMEM* blkmem, /**< block memory */ 480 SCIP_SET* set, /**< global SCIP settings */ 481 SCIP_STAT* stat, /**< problem statistics data */ 482 int nnlrows, /**< number of rows to add */ 483 SCIP_NLROW** nlrows /**< rows to add */ 484 ); 485 486 /** deletes a nonlinear row from the NLP 487 * does nothing if nonlinear row is not in NLP */ 488 SCIP_RETCODE SCIPnlpDelNlRow( 489 SCIP_NLP* nlp, /**< NLP data */ 490 BMS_BLKMEM* blkmem, /**< block memory */ 491 SCIP_SET* set, /**< global SCIP settings */ 492 SCIP_NLROW* nlrow /**< nonlinear row */ 493 ); 494 495 /** applies all cached changes to the NLP solver */ 496 SCIP_RETCODE SCIPnlpFlush( 497 SCIP_NLP* nlp, /**< current NLP data */ 498 BMS_BLKMEM* blkmem, /**< block memory */ 499 SCIP_SET* set /**< global SCIP settings */ 500 ); 501 502 /** solves the NLP */ 503 SCIP_RETCODE SCIPnlpSolve( 504 SCIP_NLP* nlp, /**< NLP data */ 505 BMS_BLKMEM* blkmem, /**< block memory buffers */ 506 SCIP_SET* set, /**< global SCIP settings */ 507 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 508 SCIP_STAT* stat /**< problem statistics */ 509 ); 510 511 /** gets objective value of current NLP */ 512 SCIP_Real SCIPnlpGetObjval( 513 SCIP_NLP* nlp /**< current NLP data */ 514 ); 515 516 /** gives current pseudo objective value */ 517 SCIP_RETCODE SCIPnlpGetPseudoObjval( 518 SCIP_NLP* nlp, /**< current NLP data */ 519 SCIP_SET* set, /**< global SCIP settings */ 520 SCIP_STAT* stat, /**< problem statistics */ 521 SCIP_Real* pseudoobjval /**< buffer to store pseudo objective value */ 522 ); 523 524 /** gets fractional variables of last NLP solution along with solution values and fractionalities 525 */ 526 SCIP_RETCODE SCIPnlpGetFracVars( 527 SCIP_NLP* nlp, /**< NLP data structure */ 528 BMS_BLKMEM* blkmem, /**< block memory */ 529 SCIP_SET* set, /**< global SCIP settings */ 530 SCIP_STAT* stat, /**< problem statistics */ 531 SCIP_VAR*** fracvars, /**< pointer to store the array of NLP fractional variables, or NULL */ 532 SCIP_Real** fracvarssol, /**< pointer to store the array of NLP fractional variables solution values, or NULL */ 533 SCIP_Real** fracvarsfrac, /**< pointer to store the array of NLP fractional variables fractionalities, or NULL */ 534 int* nfracvars, /**< pointer to store the number of NLP fractional variables , or NULL */ 535 int* npriofracvars /**< pointer to store the number of NLP fractional variables with maximal branching priority, or NULL */ 536 ); 537 538 /** removes all redundant nonlinear rows */ 539 SCIP_RETCODE SCIPnlpRemoveRedundantNlRows( 540 SCIP_NLP* nlp, /**< current NLP data */ 541 BMS_BLKMEM* blkmem, /**< block memory buffers */ 542 SCIP_SET* set, /**< global SCIP settings */ 543 SCIP_STAT* stat /**< problem statistics */ 544 ); 545 546 /** set initial guess (approximate primal solution) for next solve 547 * 548 * array initguess must be NULL or have length at least SCIPnlpGetNVars() 549 */ 550 SCIP_RETCODE SCIPnlpSetInitialGuess( 551 SCIP_NLP* nlp, /**< current NLP data */ 552 BMS_BLKMEM* blkmem, /**< block memory buffers */ 553 SCIP_Real* initguess /**< new initial guess, or NULL to clear previous one */ 554 ); 555 556 /** writes NLP to a file */ 557 SCIP_RETCODE SCIPnlpWrite( 558 SCIP_NLP* nlp, /**< current NLP data */ 559 SCIP_SET* set, /**< global SCIP settings */ 560 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 561 const char* fname /**< file name */ 562 ); 563 564 /* 565 * NLP diving methods 566 */ 567 568 /** signals start of diving */ 569 SCIP_RETCODE SCIPnlpStartDive( 570 SCIP_NLP* nlp, /**< current NLP data */ 571 BMS_BLKMEM* blkmem, /**< block memory buffers */ 572 SCIP_SET* set /**< global SCIP settings */ 573 ); 574 575 /** resets the bound and objective changes made during diving and disables diving mode */ 576 SCIP_RETCODE SCIPnlpEndDive( 577 SCIP_NLP* nlp, /**< current NLP data */ 578 BMS_BLKMEM* blkmem, /**< block memory buffers */ 579 SCIP_SET* set /**< global SCIP settings */ 580 ); 581 582 /** changes coefficient of variable in diving NLP */ 583 SCIP_RETCODE SCIPnlpChgVarObjDive( 584 SCIP_NLP* nlp, /**< current NLP data */ 585 BMS_BLKMEM* blkmem, /**< block memory */ 586 SCIP_SET* set, /**< global SCIP settings */ 587 SCIP_STAT* stat, /**< problem statistics data */ 588 SCIP_VAR* var, /**< variable which coefficient to change */ 589 SCIP_Real coef /**< new linear coefficient of variable in objective */ 590 ); 591 592 /** changes bounds of variable in diving NLP */ 593 SCIP_RETCODE SCIPnlpChgVarBoundsDive( 594 SCIP_NLP* nlp, /**< current NLP data */ 595 SCIP_VAR* var, /**< variable which bounds to change */ 596 SCIP_Real lb, /**< new lower bound of variable */ 597 SCIP_Real ub /**< new upper bound of variable */ 598 ); 599 600 /** changes bounds of a set of variables in diving NLP */ 601 SCIP_RETCODE SCIPnlpChgVarsBoundsDive( 602 SCIP_NLP* nlp, /**< current NLP data */ 603 SCIP_SET* set, /**< global SCIP settings */ 604 int nvars, /**< number of variables which bounds to change */ 605 SCIP_VAR** vars, /**< variables which bounds to change */ 606 SCIP_Real* lbs, /**< new lower bounds of variables */ 607 SCIP_Real* ubs /**< new upper bounds of variables */ 608 ); 609 610 /** returns whether the objective function has been changed during diving */ 611 SCIP_Bool SCIPnlpIsDivingObjChanged( 612 SCIP_NLP* nlp /**< current NLP data */ 613 ); 614 615 /** solves diving NLP */ 616 SCIP_RETCODE SCIPnlpSolveDive( 617 SCIP_NLP* nlp, /**< current NLP data */ 618 BMS_BLKMEM* blkmem, /**< block memory buffers */ 619 SCIP_SET* set, /**< global SCIP settings */ 620 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 621 SCIP_STAT* stat /**< problem statistics */ 622 ); 623 624 /** gets array with variables of the NLP */ 625 SCIP_VAR** SCIPnlpGetVars( 626 SCIP_NLP* nlp /**< current NLP data */ 627 ); 628 629 /** gets current number of variables in NLP */ 630 int SCIPnlpGetNVars( 631 SCIP_NLP* nlp /**< current NLP data */ 632 ); 633 634 /** computes for each variables the number of NLP rows in which the variable appears in a nonlinear var */ 635 SCIP_RETCODE SCIPnlpGetVarsNonlinearity( 636 SCIP_NLP* nlp, /**< current NLP data */ 637 int* nlcount /**< an array of length at least SCIPnlpGetNVars() to store nonlinearity counts of variables */ 638 ); 639 640 /** indicates whether there exists a row that contains a continuous variable in a nonlinear term 641 * 642 * @note The method may have to touch every row and nonlinear term to compute its result. 643 */ 644 SCIP_Bool SCIPnlpHasContinuousNonlinearity( 645 SCIP_NLP* nlp /**< current NLP data */ 646 ); 647 648 /** gives dual solution values associated with lower bounds of NLP variables */ 649 SCIP_Real* SCIPnlpGetVarsLbDualsol( 650 SCIP_NLP* nlp /**< current NLP data */ 651 ); 652 653 /** gives dual solution values associated with upper bounds of NLP variables */ 654 SCIP_Real* SCIPnlpGetVarsUbDualsol( 655 SCIP_NLP* nlp /**< current NLP data */ 656 ); 657 658 /** gets array with nonlinear rows of the NLP */ 659 SCIP_NLROW** SCIPnlpGetNlRows( 660 SCIP_NLP* nlp /**< current NLP data */ 661 ); 662 663 /** gets current number of nonlinear rows in NLP */ 664 int SCIPnlpGetNNlRows( 665 SCIP_NLP* nlp /**< current NLP data */ 666 ); 667 668 /** gets the NLP solver interface */ 669 SCIP_NLPI* SCIPnlpGetNLPI( 670 SCIP_NLP* nlp /**< current NLP data */ 671 ); 672 673 /** gets the NLP problem in the solver interface */ 674 SCIP_NLPIPROBLEM* SCIPnlpGetNLPIProblem( 675 SCIP_NLP* nlp /**< current NLP data */ 676 ); 677 678 /** indicates whether NLP is currently in diving mode */ 679 SCIP_Bool SCIPnlpIsDiving( 680 SCIP_NLP* nlp /**< current NLP data */ 681 ); 682 683 /** gets solution status of current NLP */ 684 SCIP_NLPSOLSTAT SCIPnlpGetSolstat( 685 SCIP_NLP* nlp /**< current NLP data */ 686 ); 687 688 /** gets termination status of last NLP solve */ 689 SCIP_NLPTERMSTAT SCIPnlpGetTermstat( 690 SCIP_NLP* nlp /**< current NLP data */ 691 ); 692 693 /** gives statistics (number of iterations, solving time, ...) of last NLP solve */ 694 SCIP_RETCODE SCIPnlpGetStatistics( 695 SCIP_NLP* nlp, /**< pointer to NLP datastructure */ 696 SCIP_NLPSTATISTICS* statistics /**< pointer to store statistics */ 697 ); 698 699 /** indicates whether a feasible solution for the current NLP is available 700 * thus, returns whether the solution status <= feasible */ 701 SCIP_Bool SCIPnlpHasSolution( 702 SCIP_NLP* nlp /**< current NLP data */ 703 ); 704 705 /** gets integer parameter of NLP */ 706 SCIP_RETCODE SCIPnlpGetIntPar( 707 SCIP_NLP* nlp, /**< pointer to NLP datastructure */ 708 SCIP_NLPPARAM type, /**< parameter number */ 709 int* ival /**< pointer to store the parameter value */ 710 ); 711 712 /** sets integer parameter of NLP */ 713 SCIP_RETCODE SCIPnlpSetIntPar( 714 SCIP_NLP* nlp, /**< pointer to NLP datastructure */ 715 SCIP_NLPPARAM type, /**< parameter number */ 716 int ival /**< parameter value */ 717 ); 718 719 /** gets floating point parameter of NLP */ 720 SCIP_RETCODE SCIPnlpGetRealPar( 721 SCIP_NLP* nlp, /**< pointer to NLP datastructure */ 722 SCIP_NLPPARAM type, /**< parameter number */ 723 SCIP_Real* dval /**< pointer to store the parameter value */ 724 ); 725 726 /** sets floating point parameter of NLP */ 727 SCIP_RETCODE SCIPnlpSetRealPar( 728 SCIP_NLP* nlp, /**< pointer to NLP datastructure */ 729 SCIP_NLPPARAM type, /**< parameter number */ 730 SCIP_Real dval /**< parameter value */ 731 ); 732 733 /** gets string parameter of NLP */ 734 SCIP_RETCODE SCIPnlpGetStringPar( 735 SCIP_NLP* nlp, /**< pointer to NLP datastructure */ 736 SCIP_NLPPARAM type, /**< parameter number */ 737 const char** sval /**< pointer to store the parameter value */ 738 ); 739 740 /** sets string parameter of NLP */ 741 SCIP_RETCODE SCIPnlpSetStringPar( 742 SCIP_NLP* nlp, /**< pointer to NLP datastructure */ 743 SCIP_NLPPARAM type, /**< parameter number */ 744 const char* sval /**< parameter value */ 745 ); 746 747 /**@} */ 748 749 #ifdef __cplusplus 750 } 751 #endif 752 753 #endif /* __SCIP_NLP_H__ */ 754