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 paramset.c 26 * @ingroup OTHER_CFILES 27 * @brief methods for handling parameter settings 28 * @author Tobias Achterberg 29 * @author Timo Berthold 30 * @author Stefan Heinz 31 * @author Gerald Gamrath 32 * @author Marc Pfetsch 33 */ 34 35 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 36 37 #include <assert.h> 38 #include <string.h> 39 #if defined(_WIN32) || defined(_WIN64) 40 #else 41 #include <strings.h> /*lint --e{766}*/ 42 #endif 43 44 #include "scip/scip.h" 45 #include "scip/set.h" 46 #include "scip/paramset.h" 47 48 #include "scip/struct_paramset.h" 49 50 51 52 /* 53 * Parameter methods 54 */ 55 56 /** hash key retrieval function for parameters */ 57 static 58 SCIP_DECL_HASHGETKEY(hashGetKeyParam) 59 { /*lint --e{715}*/ 60 SCIP_PARAM* param; 61 62 param = (SCIP_PARAM*)elem; 63 assert(param != NULL); 64 65 return param->name; 66 } 67 68 /** tests whether parameter can be changed and issues an error message if it is fixed */ 69 static 70 SCIP_RETCODE paramTestFixed( 71 SCIP_PARAM* param, /**< parameter */ 72 SCIP_MESSAGEHDLR* messagehdlr /**< message handler */ 73 ) 74 { /*lint --e{715}*/ 75 assert(param != NULL); 76 assert(messagehdlr != NULL); 77 78 if( param->isfixed ) 79 { 80 SCIPerrorMessage("parameter <%s> is fixed and cannot be changed. Unfix it to allow changing the value.\n", param->name); 81 return SCIP_PARAMETERWRONGVAL; 82 } 83 84 return SCIP_OKAY; 85 } 86 87 /** tests parameter value according to the given feasible domain; issues an error message if value was invalid */ 88 static 89 SCIP_RETCODE paramTestBool( 90 SCIP_PARAM* param, /**< parameter */ 91 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 92 SCIP_Bool value /**< value to test */ 93 ) 94 { /*lint --e{715}*/ 95 assert(param != NULL); 96 assert(param->paramtype == SCIP_PARAMTYPE_BOOL); 97 assert(messagehdlr != NULL); 98 99 if( value != TRUE && value != FALSE ) 100 { 101 SCIPerrorMessage("Invalid value <%u> for bool parameter <%s>. Must be <0> (FALSE) or <1> (TRUE).\n", value, param->name); 102 return SCIP_PARAMETERWRONGVAL; 103 } 104 105 return SCIP_OKAY; 106 } 107 108 /** tests parameter value according to the given feasible domain; issues an error message if value was invalid */ 109 static 110 SCIP_RETCODE paramTestInt( 111 SCIP_PARAM* param, /**< parameter */ 112 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 113 int value /**< value to test */ 114 ) 115 { /*lint --e{715}*/ 116 assert(param != NULL); 117 assert(param->paramtype == SCIP_PARAMTYPE_INT); 118 assert(messagehdlr != NULL); 119 120 if( value < param->data.intparam.minvalue || value > param->data.intparam.maxvalue ) 121 { 122 SCIPerrorMessage("Invalid value <%d> for int parameter <%s>. Must be in range [%d,%d].\n", 123 value, param->name, param->data.intparam.minvalue, param->data.intparam.maxvalue); 124 return SCIP_PARAMETERWRONGVAL; 125 } 126 127 return SCIP_OKAY; 128 } 129 130 /** tests parameter value according to the given feasible domain; issues an error message if value was invalid */ 131 static 132 SCIP_RETCODE paramTestLongint( 133 SCIP_PARAM* param, /**< parameter */ 134 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 135 SCIP_Longint value /**< value to test */ 136 ) 137 { /*lint --e{715}*/ 138 assert(param != NULL); 139 assert(param->paramtype == SCIP_PARAMTYPE_LONGINT); 140 assert(messagehdlr != NULL); 141 142 if( value < param->data.longintparam.minvalue || value > param->data.longintparam.maxvalue ) 143 { 144 SCIPerrorMessage("Invalid value <%" SCIP_LONGINT_FORMAT "> for longint parameter <%s>. Must be in range [%" SCIP_LONGINT_FORMAT ",%" SCIP_LONGINT_FORMAT "].\n", 145 value, param->name, param->data.longintparam.minvalue, param->data.longintparam.maxvalue); 146 return SCIP_PARAMETERWRONGVAL; 147 } 148 149 return SCIP_OKAY; 150 } 151 152 /** tests parameter value according to the given feasible domain; issues an error message if value was invalid */ 153 static 154 SCIP_RETCODE paramTestReal( 155 SCIP_PARAM* param, /**< parameter */ 156 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 157 SCIP_Real value /**< value to test */ 158 ) 159 { /*lint --e{715}*/ 160 assert(param != NULL); 161 assert(param->paramtype == SCIP_PARAMTYPE_REAL); 162 assert(messagehdlr != NULL); 163 164 if( value < param->data.realparam.minvalue || value > param->data.realparam.maxvalue ) 165 { 166 SCIPerrorMessage("Invalid value <%.15g> for real parameter <%s>. Must be in range [%.15g,%.15g].\n", 167 value, param->name, param->data.realparam.minvalue, param->data.realparam.maxvalue); 168 return SCIP_PARAMETERWRONGVAL; 169 } 170 171 return SCIP_OKAY; 172 } 173 174 /** tests parameter value according to the given feasible domain; issues an error message if value was invalid */ 175 static 176 SCIP_RETCODE paramTestChar( 177 SCIP_PARAM* param, /**< parameter */ 178 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 179 char value /**< value to test */ 180 ) 181 { /*lint --e{715}*/ 182 assert(param != NULL); 183 assert(param->paramtype == SCIP_PARAMTYPE_CHAR); 184 assert(messagehdlr != NULL); 185 186 if( value == '\b' || value == '\f' || value == '\n' || value == '\r' || value == '\v' ) 187 { 188 SCIPerrorMessage("Invalid value <%d> for char parameter <%s>.\n", (int)value, param->name); 189 return SCIP_PARAMETERWRONGVAL; 190 } 191 192 if( param->data.charparam.allowedvalues != NULL ) 193 { 194 char* c; 195 196 c = param->data.charparam.allowedvalues; 197 while( *c != '\0' && *c != value ) 198 c++; 199 200 if( *c != value ) 201 { 202 SCIPerrorMessage("Invalid value <%c> for char parameter <%s>. Must be in set {%s}.\n", 203 value, param->name, param->data.charparam.allowedvalues); 204 return SCIP_PARAMETERWRONGVAL; 205 } 206 } 207 208 return SCIP_OKAY; 209 } 210 211 /** tests parameter value according to the given feasible domain; issues an error message if value was invalid */ 212 static 213 SCIP_RETCODE paramTestString( 214 SCIP_PARAM* param, /**< parameter */ 215 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 216 const char* value /**< value to test */ 217 ) 218 { /*lint --e{715}*/ 219 unsigned int i; 220 221 assert(param != NULL); 222 assert(param->paramtype == SCIP_PARAMTYPE_STRING); 223 assert(messagehdlr != NULL); 224 225 if( value == NULL ) 226 { 227 SCIPerrorMessage("Cannot assign a NULL string to a string parameter.\n"); 228 return SCIP_PARAMETERWRONGVAL; 229 } 230 231 for( i = 0; i < (unsigned int) strlen(value); ++i ) 232 { 233 if( value[i] == '\b' || value[i] == '\f' || value[i] == '\n' || value[i] == '\r' || value[i] == '\v' ) 234 { 235 SCIPerrorMessage("Invalid character <%d> in string parameter <%s> at position %u.\n", (int)value[i], param->name, i); 236 return SCIP_PARAMETERWRONGVAL; 237 } 238 } 239 240 return SCIP_OKAY; 241 } 242 243 /** writes the parameter to a file */ 244 static 245 SCIP_RETCODE paramWrite( 246 SCIP_PARAM* param, /**< parameter */ 247 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 248 FILE* file, /**< file stream to write parameter to, or NULL for stdout */ 249 SCIP_Bool comments, /**< should parameter descriptions be written as comments? */ 250 SCIP_Bool onlychanged /**< should only the parameters been written, that are changed from default? */ 251 ) 252 { 253 assert(param != NULL); 254 assert(messagehdlr != NULL); 255 256 /* write parameters at default values only, if the onlychanged flag is not set or if the parameter is fixed */ 257 if( onlychanged && SCIPparamIsDefault(param) && !SCIPparamIsFixed(param) ) 258 return SCIP_OKAY; 259 260 /* write parameter description, bounds, and defaults as comments */ 261 if( comments ) 262 { 263 SCIPmessageFPrintInfo(messagehdlr, file, "# %s\n", param->desc); 264 switch( param->paramtype ) 265 { 266 case SCIP_PARAMTYPE_BOOL: 267 SCIPmessageFPrintInfo(messagehdlr, file, "# [type: bool, advanced: %s, range: {TRUE,FALSE}, default: %s]\n", 268 SCIPparamIsAdvanced(param) ? "TRUE" : "FALSE", 269 param->data.boolparam.defaultvalue ? "TRUE" : "FALSE"); 270 break; 271 case SCIP_PARAMTYPE_INT: 272 SCIPmessageFPrintInfo(messagehdlr, file, "# [type: int, advanced: %s, range: [%d,%d], default: %d]\n", 273 SCIPparamIsAdvanced(param) ? "TRUE" : "FALSE", 274 param->data.intparam.minvalue, param->data.intparam.maxvalue, param->data.intparam.defaultvalue); 275 break; 276 case SCIP_PARAMTYPE_LONGINT: 277 SCIPmessageFPrintInfo(messagehdlr, file, "# [type: longint, advanced: %s, range: [%" SCIP_LONGINT_FORMAT ",%" SCIP_LONGINT_FORMAT "], default: %" SCIP_LONGINT_FORMAT "]\n", 278 SCIPparamIsAdvanced(param) ? "TRUE" : "FALSE", 279 param->data.longintparam.minvalue, param->data.longintparam.maxvalue, param->data.longintparam.defaultvalue); 280 break; 281 case SCIP_PARAMTYPE_REAL: 282 SCIPmessageFPrintInfo(messagehdlr, file, "# [type: real, advanced: %s, range: [%.15g,%.15g], default: %.15g]\n", 283 SCIPparamIsAdvanced(param) ? "TRUE" : "FALSE", 284 param->data.realparam.minvalue, param->data.realparam.maxvalue, param->data.realparam.defaultvalue); 285 break; 286 case SCIP_PARAMTYPE_CHAR: 287 SCIPmessageFPrintInfo(messagehdlr, file, "# [type: char, advanced: %s, range: {%s}, default: %c]\n", 288 SCIPparamIsAdvanced(param) ? "TRUE" : "FALSE", 289 param->data.charparam.allowedvalues != NULL ? param->data.charparam.allowedvalues : "all chars", 290 param->data.charparam.defaultvalue); 291 break; 292 case SCIP_PARAMTYPE_STRING: 293 SCIPmessageFPrintInfo(messagehdlr, file, "# [type: string, advanced: %s, default: \"%s\"]\n", 294 SCIPparamIsAdvanced(param) ? "TRUE" : "FALSE", 295 param->data.stringparam.defaultvalue); 296 break; 297 default: 298 SCIPerrorMessage("unknown parameter type\n"); 299 return SCIP_INVALIDDATA; 300 } 301 } 302 303 /* write parameter value */ 304 SCIPmessageFPrintInfo(messagehdlr, file, "%s = ", param->name); 305 switch( param->paramtype ) 306 { 307 case SCIP_PARAMTYPE_BOOL: 308 SCIPmessageFPrintInfo(messagehdlr, file, "%s", SCIPparamGetBool(param) ? "TRUE" : "FALSE"); 309 break; 310 case SCIP_PARAMTYPE_INT: 311 SCIPmessageFPrintInfo(messagehdlr, file, "%d", SCIPparamGetInt(param)); 312 break; 313 case SCIP_PARAMTYPE_LONGINT: 314 SCIPmessageFPrintInfo(messagehdlr, file, "%" SCIP_LONGINT_FORMAT "", SCIPparamGetLongint(param)); 315 break; 316 case SCIP_PARAMTYPE_REAL: 317 SCIPmessageFPrintInfo(messagehdlr, file, "%.15g", SCIPparamGetReal(param)); 318 break; 319 case SCIP_PARAMTYPE_CHAR: 320 SCIPmessageFPrintInfo(messagehdlr, file, "%c", SCIPparamGetChar(param)); 321 break; 322 case SCIP_PARAMTYPE_STRING: 323 SCIPmessageFPrintInfo(messagehdlr, file, "\"%s\"", SCIPparamGetString(param)); 324 break; 325 default: 326 SCIPerrorMessage("unknown parameter type\n"); 327 return SCIP_INVALIDDATA; 328 } 329 330 /* write "fix" after value if parameter is fixed */ 331 if( SCIPparamIsFixed(param) ) 332 SCIPmessageFPrintInfo(messagehdlr, file, " fix"); 333 334 SCIPmessageFPrintInfo(messagehdlr, file, "\n"); 335 336 if( comments ) 337 SCIPmessageFPrintInfo(messagehdlr, file, "\n"); 338 339 return SCIP_OKAY; 340 } 341 342 /** if a bool parameter exits with the given parameter name it is set to the new value */ 343 static 344 SCIP_RETCODE paramSetBool( 345 SCIP_PARAMSET* paramset, /**< parameter set */ 346 SCIP_SET* set, /**< global SCIP settings */ 347 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 348 const char* paramname, /**< parameter name */ 349 SCIP_Bool value, /**< new value of the parameter */ 350 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 351 ) 352 { 353 SCIP_PARAM* param; 354 355 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)paramname); 356 if( param != NULL ) 357 { 358 assert(SCIPparamGetType(param) == SCIP_PARAMTYPE_BOOL); 359 360 if( SCIPparamIsFixed(param) ) 361 { 362 SCIPsetDebugMsg(set, "hard coded parameter <%s> is fixed and is thus not changed.\n", param->name); 363 364 return SCIP_OKAY; 365 } 366 SCIP_CALL( SCIPparamSetBool(param, set, messagehdlr, value, FALSE, quiet) ); 367 } 368 #ifndef NDEBUG 369 else 370 { 371 SCIPmessagePrintWarning(messagehdlr, "unknown hard coded bool parameter <%s>\n", paramname); 372 } 373 #endif 374 375 return SCIP_OKAY; 376 } 377 378 /** if an char parameter exits with the given parameter name it is set to the new value */ 379 static 380 SCIP_RETCODE paramSetChar( 381 SCIP_PARAMSET* paramset, /**< parameter set */ 382 SCIP_SET* set, /**< global SCIP settings */ 383 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 384 const char* paramname, /**< parameter name */ 385 char value, /**< new value of the parameter */ 386 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 387 ) 388 { 389 SCIP_PARAM* param; 390 391 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)paramname); 392 if( param != NULL ) 393 { 394 assert(SCIPparamGetType(param) == SCIP_PARAMTYPE_CHAR); 395 396 if( SCIPparamIsFixed(param) ) 397 { 398 SCIPsetDebugMsg(set, "hard coded parameter <%s> is fixed and is thus not changed.\n", param->name); 399 400 return SCIP_OKAY; 401 } 402 SCIP_CALL( SCIPparamSetChar(param, set, messagehdlr, value, FALSE, quiet) ); 403 } 404 #ifndef NDEBUG 405 else 406 { 407 SCIPmessagePrintWarning(messagehdlr, "unknown hard coded char parameter <%s>\n", paramname); 408 } 409 #endif 410 411 return SCIP_OKAY; 412 } 413 414 /** if an integer parameter exits with the given parameter name it is set to the new value */ 415 static 416 SCIP_RETCODE paramSetInt( 417 SCIP_PARAMSET* paramset, /**< parameter set */ 418 SCIP_SET* set, /**< global SCIP settings */ 419 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 420 const char* paramname, /**< parameter name */ 421 int value, /**< new value of the parameter */ 422 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 423 ) 424 { 425 SCIP_PARAM* param; 426 427 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)paramname); 428 if( param != NULL ) 429 { 430 assert(SCIPparamGetType(param) == SCIP_PARAMTYPE_INT); 431 432 if( SCIPparamIsFixed(param) ) 433 { 434 SCIPsetDebugMsg(set, "hard coded parameter <%s> is fixed and is thus not changed.\n", param->name); 435 436 return SCIP_OKAY; 437 } 438 SCIP_CALL( SCIPparamSetInt(param, set, messagehdlr, value, FALSE, quiet) ); 439 } 440 #ifndef NDEBUG 441 else 442 { 443 SCIPmessagePrintWarning(messagehdlr, "unknown hard coded int parameter <%s>\n", paramname); 444 } 445 #endif 446 447 return SCIP_OKAY; 448 } 449 450 /** if a long integer parameter exits with the given parameter name it is set to the new value */ 451 static 452 SCIP_RETCODE paramSetLongint( 453 SCIP_PARAMSET* paramset, /**< parameter set */ 454 SCIP_SET* set, /**< global SCIP settings */ 455 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 456 const char* paramname, /**< parameter name */ 457 SCIP_Longint value, /**< new value of the parameter */ 458 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 459 ) 460 { 461 SCIP_PARAM* param; 462 463 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)paramname); 464 if( param != NULL ) 465 { 466 assert(SCIPparamGetType(param) == SCIP_PARAMTYPE_LONGINT); 467 468 if( SCIPparamIsFixed(param) ) 469 { 470 SCIPsetDebugMsg(set, "hard coded parameter <%s> is fixed and is thus not changed.\n", param->name); 471 472 return SCIP_OKAY; 473 } 474 SCIP_CALL( SCIPparamSetLongint(param, set, messagehdlr, value, FALSE, quiet) ); 475 } 476 #ifndef NDEBUG 477 else 478 { 479 SCIPmessagePrintWarning(messagehdlr, "unknown hard coded longint parameter <%s>\n", paramname); 480 } 481 #endif 482 483 return SCIP_OKAY; 484 } 485 486 /** if a real parameter exits with the given parameter name it is set to the new value */ 487 static 488 SCIP_RETCODE paramSetReal( 489 SCIP_PARAMSET* paramset, /**< parameter set */ 490 SCIP_SET* set, /**< global SCIP settings */ 491 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 492 const char* paramname, /**< parameter name */ 493 SCIP_Real value, /**< new value of the parameter */ 494 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 495 ) 496 { 497 SCIP_PARAM* param; 498 499 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)paramname); 500 if( param != NULL ) 501 { 502 assert(SCIPparamGetType(param) == SCIP_PARAMTYPE_REAL); 503 504 if( SCIPparamIsFixed(param) ) 505 { 506 SCIPsetDebugMsg(set, "hard coded parameter <%s> is fixed and is thus not changed.\n", param->name); 507 508 return SCIP_OKAY; 509 } 510 SCIP_CALL( SCIPparamSetReal(param, set, messagehdlr, value, FALSE, quiet) ); 511 } 512 #ifndef NDEBUG 513 else 514 { 515 SCIPmessagePrintWarning(messagehdlr, "unknown hard coded real parameter <%s>\n", paramname); 516 } 517 #endif 518 519 return SCIP_OKAY; 520 } 521 522 /** copies value of source Bool parameter to target Bool parameter*/ 523 static 524 SCIP_RETCODE paramCopyBool( 525 SCIP_PARAM* sourceparam, /**< source Bool parameter */ 526 SCIP_PARAM* targetparam, /**< target Bool parameter */ 527 SCIP_SET* set, /**< global SCIP settings of target SCIP */ 528 SCIP_MESSAGEHDLR* messagehdlr /**< message handler of target SCIP */ 529 ) 530 { 531 SCIP_Bool value; 532 533 assert(sourceparam != NULL); 534 assert(targetparam != NULL); 535 536 /* get value of source parameter and copy it to target parameter */ 537 value = SCIPparamGetBool(sourceparam); 538 SCIP_CALL( SCIPparamSetBool(targetparam, set, messagehdlr, value, FALSE, TRUE) ); 539 540 return SCIP_OKAY; 541 } 542 543 /** copies value of source int parameter to target int parameter*/ 544 static 545 SCIP_RETCODE paramCopyInt( 546 SCIP_PARAM* sourceparam, /**< source int parameter */ 547 SCIP_PARAM* targetparam, /**< target int parameter */ 548 SCIP_SET* set, /**< global SCIP settings of target SCIP */ 549 SCIP_MESSAGEHDLR* messagehdlr /**< message handler of target SCIP */ 550 ) 551 { 552 int value; 553 554 assert(sourceparam != NULL); 555 assert(targetparam != NULL); 556 557 /* get value of source parameter and copy it to target parameter */ 558 value = SCIPparamGetInt(sourceparam); 559 SCIP_CALL( SCIPparamSetInt(targetparam, set, messagehdlr, value, FALSE, TRUE) ); 560 561 return SCIP_OKAY; 562 } 563 564 /** copies value of source longint parameter to target longint parameter*/ 565 static 566 SCIP_RETCODE paramCopyLongint( 567 SCIP_PARAM* sourceparam, /**< source longint parameter */ 568 SCIP_PARAM* targetparam, /**< target longint parameter */ 569 SCIP_SET* set, /**< global SCIP settings of target SCIP */ 570 SCIP_MESSAGEHDLR* messagehdlr /**< message handler of target SCIP */ 571 ) 572 { 573 SCIP_Longint value; 574 575 assert(sourceparam != NULL); 576 assert(targetparam != NULL); 577 578 /* get value of source parameter and copy it to target parameter */ 579 value = SCIPparamGetLongint(sourceparam); 580 SCIP_CALL( SCIPparamSetLongint(targetparam, set, messagehdlr, value, FALSE, TRUE) ); 581 582 return SCIP_OKAY; 583 } 584 585 /** copies value of source real parameter to target real parameter*/ 586 static 587 SCIP_RETCODE paramCopyReal( 588 SCIP_PARAM* sourceparam, /**< source real parameter */ 589 SCIP_PARAM* targetparam, /**< target real parameter */ 590 SCIP_SET* set, /**< global SCIP settings of target SCIP */ 591 SCIP_MESSAGEHDLR* messagehdlr /**< message handler of target SCIP */ 592 ) 593 { 594 SCIP_Real value; 595 596 assert(sourceparam != NULL); 597 assert(targetparam != NULL); 598 599 /* get value of source parameter and copy it to target parameter */ 600 value = SCIPparamGetReal(sourceparam); 601 SCIP_CALL( SCIPparamSetReal(targetparam, set, messagehdlr, value, FALSE, TRUE) ); 602 603 return SCIP_OKAY; 604 } 605 606 /** copies value of source char parameter to target char parameter*/ 607 static 608 SCIP_RETCODE paramCopyChar( 609 SCIP_PARAM* sourceparam, /**< source char parameter */ 610 SCIP_PARAM* targetparam, /**< target char parameter */ 611 SCIP_SET* set, /**< global SCIP settings of target SCIP */ 612 SCIP_MESSAGEHDLR* messagehdlr /**< message handler of target SCIP */ 613 ) 614 { 615 char value; 616 617 assert(sourceparam != NULL); 618 assert(targetparam != NULL); 619 620 /* get value of source parameter and copy it to target parameter */ 621 value = SCIPparamGetChar(sourceparam); 622 SCIP_CALL( SCIPparamSetChar(targetparam, set, messagehdlr, value, FALSE, TRUE) ); 623 624 return SCIP_OKAY; 625 } 626 627 /** copies value of source string parameter to target string parameter*/ 628 static 629 SCIP_RETCODE paramCopyString( 630 SCIP_PARAM* sourceparam, /**< source string parameter */ 631 SCIP_PARAM* targetparam, /**< target string parameter */ 632 SCIP_SET* set, /**< global SCIP settings of target SCIP */ 633 SCIP_MESSAGEHDLR* messagehdlr /**< message handler of target SCIP */ 634 ) 635 { 636 char* value; 637 638 assert(sourceparam != NULL); 639 assert(targetparam != NULL); 640 641 /* get value of source parameter and copy it to target parameter */ 642 value = SCIPparamGetString(sourceparam); 643 SCIP_CALL( SCIPparamSetString(targetparam, set, messagehdlr, value, FALSE, TRUE) ); 644 645 return SCIP_OKAY; 646 } 647 648 /** returns type of parameter */ 649 SCIP_PARAMTYPE SCIPparamGetType( 650 SCIP_PARAM* param /**< parameter */ 651 ) 652 { 653 assert(param != NULL); 654 655 return param->paramtype; 656 } 657 658 /** returns name of parameter */ 659 const char* SCIPparamGetName( 660 SCIP_PARAM* param /**< parameter */ 661 ) 662 { 663 assert(param != NULL); 664 665 return param->name; 666 } 667 668 /** returns description of parameter */ 669 const char* SCIPparamGetDesc( 670 SCIP_PARAM* param /**< parameter */ 671 ) 672 { 673 assert(param != NULL); 674 675 return param->desc; 676 } 677 678 /** returns locally defined parameter specific data */ 679 SCIP_PARAMDATA* SCIPparamGetData( 680 SCIP_PARAM* param /**< parameter */ 681 ) 682 { 683 assert(param != NULL); 684 685 return param->paramdata; 686 } 687 688 /** returns whether parameter is advanced */ 689 SCIP_Bool SCIPparamIsAdvanced( 690 SCIP_PARAM* param /**< parameter */ 691 ) 692 { 693 assert(param != NULL); 694 695 return param->isadvanced; 696 } 697 698 /** returns whether parameter is fixed */ 699 SCIP_Bool SCIPparamIsFixed( 700 SCIP_PARAM* param /**< parameter */ 701 ) 702 { 703 assert(param != NULL); 704 705 return param->isfixed; 706 } 707 708 /** returns value of SCIP_Bool parameter */ 709 SCIP_Bool SCIPparamGetBool( 710 SCIP_PARAM* param /**< parameter */ 711 ) 712 { 713 assert(param != NULL); 714 assert(param->paramtype == SCIP_PARAMTYPE_BOOL); 715 716 if( param->data.boolparam.valueptr != NULL ) 717 return *param->data.boolparam.valueptr; 718 else 719 return param->data.boolparam.curvalue; 720 } 721 722 /** returns default value of SCIP_Bool parameter */ 723 SCIP_Bool SCIPparamGetBoolDefault( 724 SCIP_PARAM* param /**< parameter */ 725 ) 726 { 727 assert(param != NULL); 728 assert(param->paramtype == SCIP_PARAMTYPE_BOOL); 729 730 return param->data.boolparam.defaultvalue; 731 } 732 733 /** returns value of int parameter */ 734 int SCIPparamGetInt( 735 SCIP_PARAM* param /**< parameter */ 736 ) 737 { 738 assert(param != NULL); 739 assert(param->paramtype == SCIP_PARAMTYPE_INT); 740 741 if( param->data.intparam.valueptr != NULL ) 742 return *param->data.intparam.valueptr; 743 else 744 return param->data.intparam.curvalue; 745 } 746 747 /** returns minimal value of int parameter */ 748 int SCIPparamGetIntMin( 749 SCIP_PARAM* param /**< parameter */ 750 ) 751 { 752 assert(param != NULL); 753 assert(param->paramtype == SCIP_PARAMTYPE_INT); 754 755 return param->data.intparam.minvalue; 756 } 757 758 /** returns maximal value of int parameter */ 759 int SCIPparamGetIntMax( 760 SCIP_PARAM* param /**< parameter */ 761 ) 762 { 763 assert(param != NULL); 764 assert(param->paramtype == SCIP_PARAMTYPE_INT); 765 766 return param->data.intparam.maxvalue; 767 } 768 769 /** returns default value of int parameter */ 770 int SCIPparamGetIntDefault( 771 SCIP_PARAM* param /**< parameter */ 772 ) 773 { 774 assert(param != NULL); 775 assert(param->paramtype == SCIP_PARAMTYPE_INT); 776 777 return param->data.intparam.defaultvalue; 778 } 779 780 /** returns value of SCIP_Longint parameter */ 781 SCIP_Longint SCIPparamGetLongint( 782 SCIP_PARAM* param /**< parameter */ 783 ) 784 { 785 assert(param != NULL); 786 assert(param->paramtype == SCIP_PARAMTYPE_LONGINT); 787 788 if( param->data.longintparam.valueptr != NULL ) 789 return *param->data.longintparam.valueptr; 790 else 791 return param->data.longintparam.curvalue; 792 } 793 794 /** returns minimal value of longint parameter */ 795 SCIP_Longint SCIPparamGetLongintMin( 796 SCIP_PARAM* param /**< parameter */ 797 ) 798 { 799 assert(param != NULL); 800 assert(param->paramtype == SCIP_PARAMTYPE_LONGINT); 801 802 return param->data.longintparam.minvalue; 803 } 804 805 /** returns maximal value of longint parameter */ 806 SCIP_Longint SCIPparamGetLongintMax( 807 SCIP_PARAM* param /**< parameter */ 808 ) 809 { 810 assert(param != NULL); 811 assert(param->paramtype == SCIP_PARAMTYPE_LONGINT); 812 813 return param->data.longintparam.maxvalue; 814 } 815 816 /** returns default value of SCIP_Longint parameter */ 817 SCIP_Longint SCIPparamGetLongintDefault( 818 SCIP_PARAM* param /**< parameter */ 819 ) 820 { 821 assert(param != NULL); 822 assert(param->paramtype == SCIP_PARAMTYPE_LONGINT); 823 824 return param->data.longintparam.defaultvalue; 825 } 826 827 /** returns value of SCIP_Real parameter */ 828 SCIP_Real SCIPparamGetReal( 829 SCIP_PARAM* param /**< parameter */ 830 ) 831 { 832 assert(param != NULL); 833 assert(param->paramtype == SCIP_PARAMTYPE_REAL); 834 835 if( param->data.realparam.valueptr != NULL ) 836 return *param->data.realparam.valueptr; 837 else 838 return param->data.realparam.curvalue; 839 } 840 841 /** returns minimal value of real parameter */ 842 SCIP_Real SCIPparamGetRealMin( 843 SCIP_PARAM* param /**< parameter */ 844 ) 845 { 846 assert(param != NULL); 847 assert(param->paramtype == SCIP_PARAMTYPE_REAL); 848 849 return param->data.realparam.minvalue; 850 } 851 852 /** returns maximal value of real parameter */ 853 SCIP_Real SCIPparamGetRealMax( 854 SCIP_PARAM* param /**< parameter */ 855 ) 856 { 857 assert(param != NULL); 858 assert(param->paramtype == SCIP_PARAMTYPE_REAL); 859 860 return param->data.realparam.maxvalue; 861 } 862 863 /** returns default value of SCIP_Real parameter */ 864 SCIP_Real SCIPparamGetRealDefault( 865 SCIP_PARAM* param /**< parameter */ 866 ) 867 { 868 assert(param != NULL); 869 assert(param->paramtype == SCIP_PARAMTYPE_REAL); 870 871 return param->data.realparam.defaultvalue; 872 } 873 874 /** returns value of char parameter */ 875 char SCIPparamGetChar( 876 SCIP_PARAM* param /**< parameter */ 877 ) 878 { 879 assert(param != NULL); 880 assert(param->paramtype == SCIP_PARAMTYPE_CHAR); 881 882 if( param->data.charparam.valueptr != NULL ) 883 return *param->data.charparam.valueptr; 884 else 885 return param->data.charparam.curvalue; 886 } 887 888 /** returns allowed values of char parameter, or NULL if everything is allowed */ 889 char* SCIPparamGetCharAllowedValues( 890 SCIP_PARAM* param /**< parameter */ 891 ) 892 { 893 assert(param != NULL); 894 assert(param->paramtype == SCIP_PARAMTYPE_CHAR); 895 896 return param->data.charparam.allowedvalues; 897 } 898 899 /** returns default value of char parameter */ 900 char SCIPparamGetCharDefault( 901 SCIP_PARAM* param /**< parameter */ 902 ) 903 { 904 assert(param != NULL); 905 assert(param->paramtype == SCIP_PARAMTYPE_CHAR); 906 907 return param->data.charparam.defaultvalue; 908 } 909 910 /** returns value of string parameter */ 911 char* SCIPparamGetString( 912 SCIP_PARAM* param /**< parameter */ 913 ) 914 { 915 assert(param != NULL); 916 assert(param->paramtype == SCIP_PARAMTYPE_STRING); 917 918 if( param->data.stringparam.valueptr != NULL ) 919 return *param->data.stringparam.valueptr; 920 else 921 return param->data.stringparam.curvalue; 922 } 923 924 /** returns default value of String parameter */ 925 char* SCIPparamGetStringDefault( 926 SCIP_PARAM* param /**< parameter */ 927 ) 928 { 929 assert(param != NULL); 930 assert(param->paramtype == SCIP_PARAMTYPE_STRING); 931 932 return param->data.stringparam.defaultvalue; 933 } 934 935 /** returns whether the parameter is on its default setting */ 936 SCIP_Bool SCIPparamIsDefault( 937 SCIP_PARAM* param /**< parameter */ 938 ) 939 { 940 assert(param != NULL); 941 942 switch( param->paramtype ) 943 { 944 case SCIP_PARAMTYPE_BOOL: 945 return (SCIPparamGetBool(param) == SCIPparamGetBoolDefault(param)); 946 947 case SCIP_PARAMTYPE_INT: 948 return (SCIPparamGetInt(param) == SCIPparamGetIntDefault(param)); 949 950 case SCIP_PARAMTYPE_LONGINT: 951 return (SCIPparamGetLongint(param) == SCIPparamGetLongintDefault(param)); 952 953 case SCIP_PARAMTYPE_REAL: 954 return EPSZ(SCIPparamGetReal(param) - SCIPparamGetRealDefault(param), 1e-16); 955 956 case SCIP_PARAMTYPE_CHAR: 957 return (SCIPparamGetChar(param) == SCIPparamGetCharDefault(param)); 958 959 case SCIP_PARAMTYPE_STRING: 960 return (strcmp(SCIPparamGetString(param), SCIPparamGetStringDefault(param)) == 0); 961 962 default: 963 SCIPerrorMessage("unknown parameter type\n"); 964 SCIPABORT(); 965 return FALSE; /*lint !e527*/ 966 } 967 } 968 969 /** creates a parameter with name and description, does not set the type specific parameter values themselves */ 970 static 971 SCIP_RETCODE paramCreate( 972 SCIP_PARAM** param, /**< pointer to the parameter */ 973 BMS_BLKMEM* blkmem, /**< block memory */ 974 const char* name, /**< name of the parameter */ 975 const char* desc, /**< description of the parameter */ 976 SCIP_DECL_PARAMCHGD ((*paramchgd)), /**< change information method of parameter */ 977 SCIP_PARAMDATA* paramdata, /**< locally defined parameter specific data */ 978 SCIP_Bool isadvanced /**< is the parameter advanced? */ 979 ) 980 { 981 assert(param != NULL); 982 assert(name != NULL); 983 assert(desc != NULL); 984 985 SCIP_ALLOC( BMSallocBlockMemory(blkmem, param) ); 986 987 SCIP_ALLOC( BMSduplicateMemoryArray(&(*param)->name, name, strlen(name)+1) ); 988 SCIP_ALLOC( BMSduplicateMemoryArray(&(*param)->desc, desc, strlen(desc)+1) ); 989 990 (*param)->paramchgd = paramchgd; 991 (*param)->paramdata = paramdata; 992 (*param)->isadvanced = isadvanced; 993 (*param)->isfixed = FALSE; 994 995 return SCIP_OKAY; 996 } 997 998 /** creates a SCIP_Bool parameter, and sets its value to default */ 999 static 1000 SCIP_RETCODE paramCreateBool( 1001 SCIP_PARAM** param, /**< pointer to the parameter */ 1002 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 1003 BMS_BLKMEM* blkmem, /**< block memory */ 1004 const char* name, /**< name of the parameter */ 1005 const char* desc, /**< description of the parameter */ 1006 SCIP_Bool* valueptr, /**< pointer to store the current parameter value, or NULL */ 1007 SCIP_Bool isadvanced, /**< is this parameter an advanced parameter? */ 1008 SCIP_Bool defaultvalue, /**< default value of the parameter */ 1009 SCIP_DECL_PARAMCHGD ((*paramchgd)), /**< change information method of parameter */ 1010 SCIP_PARAMDATA* paramdata /**< locally defined parameter specific data */ 1011 ) 1012 { 1013 assert(param != NULL); 1014 assert(name != NULL); 1015 1016 SCIP_CALL( paramCreate(param, blkmem, name, desc, paramchgd, paramdata, isadvanced) ); 1017 1018 (*param)->paramtype = SCIP_PARAMTYPE_BOOL; 1019 (*param)->data.boolparam.valueptr = valueptr; 1020 (*param)->data.boolparam.defaultvalue = defaultvalue; 1021 1022 SCIP_CALL( SCIPparamSetBool(*param, NULL, messagehdlr, defaultvalue, TRUE, TRUE) ); 1023 1024 return SCIP_OKAY; 1025 } 1026 1027 /** creates a int parameter, and sets its value to default */ 1028 static 1029 SCIP_RETCODE paramCreateInt( 1030 SCIP_PARAM** param, /**< pointer to the parameter */ 1031 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 1032 BMS_BLKMEM* blkmem, /**< block memory */ 1033 const char* name, /**< name of the parameter */ 1034 const char* desc, /**< description of the parameter */ 1035 int* valueptr, /**< pointer to store the current parameter value, or NULL */ 1036 SCIP_Bool isadvanced, /**< is this parameter an advanced parameter? */ 1037 int defaultvalue, /**< default value of the parameter */ 1038 int minvalue, /**< minimum value for parameter */ 1039 int maxvalue, /**< maximum value for parameter */ 1040 SCIP_DECL_PARAMCHGD ((*paramchgd)), /**< change information method of parameter */ 1041 SCIP_PARAMDATA* paramdata /**< locally defined parameter specific data */ 1042 ) 1043 { 1044 assert(param != NULL); 1045 assert(name != NULL); 1046 1047 SCIP_CALL( paramCreate(param, blkmem, name, desc, paramchgd, paramdata, isadvanced) ); 1048 1049 (*param)->paramtype = SCIP_PARAMTYPE_INT; 1050 (*param)->data.intparam.valueptr = valueptr; 1051 (*param)->data.intparam.defaultvalue = defaultvalue; 1052 (*param)->data.intparam.minvalue = minvalue; 1053 (*param)->data.intparam.maxvalue = maxvalue; 1054 1055 SCIP_CALL( SCIPparamSetInt(*param, NULL, messagehdlr, defaultvalue, TRUE, TRUE) ); 1056 1057 return SCIP_OKAY; 1058 } 1059 1060 /** creates a SCIP_Longint parameter, and sets its value to default */ 1061 static 1062 SCIP_RETCODE paramCreateLongint( 1063 SCIP_PARAM** param, /**< pointer to the parameter */ 1064 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 1065 BMS_BLKMEM* blkmem, /**< block memory */ 1066 const char* name, /**< name of the parameter */ 1067 const char* desc, /**< description of the parameter */ 1068 SCIP_Longint* valueptr, /**< pointer to store the current parameter value, or NULL */ 1069 SCIP_Bool isadvanced, /**< is this parameter an advanced parameter? */ 1070 SCIP_Longint defaultvalue, /**< default value of the parameter */ 1071 SCIP_Longint minvalue, /**< minimum value for parameter */ 1072 SCIP_Longint maxvalue, /**< maximum value for parameter */ 1073 SCIP_DECL_PARAMCHGD ((*paramchgd)), /**< change information method of parameter */ 1074 SCIP_PARAMDATA* paramdata /**< locally defined parameter specific data */ 1075 ) 1076 { 1077 assert(param != NULL); 1078 assert(name != NULL); 1079 1080 SCIP_CALL( paramCreate(param, blkmem, name, desc, paramchgd, paramdata, isadvanced) ); 1081 1082 (*param)->paramtype = SCIP_PARAMTYPE_LONGINT; 1083 (*param)->data.longintparam.valueptr = valueptr; 1084 (*param)->data.longintparam.defaultvalue = defaultvalue; 1085 (*param)->data.longintparam.minvalue = minvalue; 1086 (*param)->data.longintparam.maxvalue = maxvalue; 1087 1088 SCIP_CALL( SCIPparamSetLongint(*param, NULL, messagehdlr, defaultvalue, TRUE, TRUE) ); 1089 1090 return SCIP_OKAY; 1091 } 1092 1093 /** creates a SCIP_Real parameter, and sets its value to default */ 1094 static 1095 SCIP_RETCODE paramCreateReal( 1096 SCIP_PARAM** param, /**< pointer to the parameter */ 1097 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 1098 BMS_BLKMEM* blkmem, /**< block memory */ 1099 const char* name, /**< name of the parameter */ 1100 const char* desc, /**< description of the parameter */ 1101 SCIP_Real* valueptr, /**< pointer to store the current parameter value, or NULL */ 1102 SCIP_Bool isadvanced, /**< is this parameter an advanced parameter? */ 1103 SCIP_Real defaultvalue, /**< default value of the parameter */ 1104 SCIP_Real minvalue, /**< minimum value for parameter */ 1105 SCIP_Real maxvalue, /**< maximum value for parameter */ 1106 SCIP_DECL_PARAMCHGD ((*paramchgd)), /**< change information method of parameter */ 1107 SCIP_PARAMDATA* paramdata /**< locally defined parameter specific data */ 1108 ) 1109 { 1110 assert(param != NULL); 1111 assert(name != NULL); 1112 1113 SCIP_CALL( paramCreate(param, blkmem, name, desc, paramchgd, paramdata, isadvanced) ); 1114 1115 (*param)->paramtype = SCIP_PARAMTYPE_REAL; 1116 (*param)->data.realparam.valueptr = valueptr; 1117 (*param)->data.realparam.defaultvalue = defaultvalue; 1118 (*param)->data.realparam.minvalue = minvalue; 1119 (*param)->data.realparam.maxvalue = maxvalue; 1120 1121 SCIP_CALL( SCIPparamSetReal(*param, NULL, messagehdlr, defaultvalue, TRUE, TRUE) ); 1122 1123 return SCIP_OKAY; 1124 } 1125 1126 /** creates a char parameter, and sets its value to default */ 1127 static 1128 SCIP_RETCODE paramCreateChar( 1129 SCIP_PARAM** param, /**< pointer to the parameter */ 1130 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 1131 BMS_BLKMEM* blkmem, /**< block memory */ 1132 const char* name, /**< name of the parameter */ 1133 const char* desc, /**< description of the parameter */ 1134 char* valueptr, /**< pointer to store the current parameter value, or NULL */ 1135 SCIP_Bool isadvanced, /**< is this parameter an advanced parameter? */ 1136 char defaultvalue, /**< default value of the parameter */ 1137 const char* allowedvalues, /**< array with possible parameter values, or NULL if not restricted */ 1138 SCIP_DECL_PARAMCHGD ((*paramchgd)), /**< change information method of parameter */ 1139 SCIP_PARAMDATA* paramdata /**< locally defined parameter specific data */ 1140 ) 1141 { 1142 assert(param != NULL); 1143 assert(name != NULL); 1144 1145 SCIP_CALL( paramCreate(param, blkmem, name, desc, paramchgd, paramdata, isadvanced) ); 1146 1147 (*param)->paramtype = SCIP_PARAMTYPE_CHAR; 1148 (*param)->data.charparam.valueptr = valueptr; 1149 (*param)->data.charparam.defaultvalue = defaultvalue; 1150 if( allowedvalues != NULL ) 1151 { 1152 SCIP_ALLOC( BMSduplicateMemoryArray(&(*param)->data.charparam.allowedvalues, allowedvalues, strlen(allowedvalues)+1) ); 1153 } 1154 else 1155 (*param)->data.charparam.allowedvalues = NULL; 1156 1157 SCIP_CALL( SCIPparamSetChar(*param, NULL, messagehdlr, defaultvalue, TRUE, TRUE) ); 1158 1159 return SCIP_OKAY; 1160 } 1161 1162 /** creates a string parameter, and sets its value to default */ 1163 static 1164 SCIP_RETCODE paramCreateString( 1165 SCIP_PARAM** param, /**< pointer to the parameter */ 1166 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 1167 BMS_BLKMEM* blkmem, /**< block memory */ 1168 const char* name, /**< name of the parameter */ 1169 const char* desc, /**< description of the parameter */ 1170 char** valueptr, /**< pointer to store the current parameter value, or NULL */ 1171 SCIP_Bool isadvanced, /**< is this parameter an advanced parameter? */ 1172 const char* defaultvalue, /**< default value of the parameter */ 1173 SCIP_DECL_PARAMCHGD ((*paramchgd)), /**< change information method of parameter */ 1174 SCIP_PARAMDATA* paramdata /**< locally defined parameter specific data */ 1175 ) 1176 { 1177 assert(param != NULL); 1178 assert(name != NULL); 1179 assert(valueptr == NULL || *valueptr == NULL); 1180 assert(defaultvalue != NULL); 1181 1182 SCIP_CALL( paramCreate(param, blkmem, name, desc, paramchgd, paramdata, isadvanced) ); 1183 1184 (*param)->paramtype = SCIP_PARAMTYPE_STRING; 1185 (*param)->data.stringparam.valueptr = valueptr; 1186 SCIP_ALLOC( BMSduplicateMemoryArray(&(*param)->data.stringparam.defaultvalue, defaultvalue, strlen(defaultvalue)+1) ); 1187 (*param)->data.stringparam.curvalue = NULL; 1188 1189 SCIP_CALL( SCIPparamSetString(*param, NULL, messagehdlr, defaultvalue, TRUE, TRUE) ); 1190 1191 return SCIP_OKAY; 1192 } 1193 1194 /** frees a single parameter */ 1195 static 1196 void paramFree( 1197 SCIP_PARAM** param, /**< pointer to the parameter */ 1198 BMS_BLKMEM* blkmem /**< block memory */ 1199 ) 1200 { 1201 assert(param != NULL); 1202 assert(*param != NULL); 1203 1204 switch( (*param)->paramtype ) 1205 { 1206 case SCIP_PARAMTYPE_BOOL: 1207 case SCIP_PARAMTYPE_INT: 1208 case SCIP_PARAMTYPE_LONGINT: 1209 case SCIP_PARAMTYPE_REAL: 1210 break; 1211 case SCIP_PARAMTYPE_CHAR: 1212 BMSfreeMemoryArrayNull(&(*param)->data.charparam.allowedvalues); 1213 break; 1214 case SCIP_PARAMTYPE_STRING: 1215 BMSfreeMemoryArray(&(*param)->data.stringparam.defaultvalue); 1216 if( (*param)->data.stringparam.valueptr == NULL ) 1217 { 1218 BMSfreeMemoryArray(&(*param)->data.stringparam.curvalue); 1219 } 1220 else 1221 { 1222 BMSfreeMemoryArray((*param)->data.stringparam.valueptr); 1223 } 1224 break; 1225 default: 1226 SCIPerrorMessage("invalid parameter type\n"); 1227 /* just continuing the function in this case seems save */ 1228 SCIPABORT(); 1229 } 1230 1231 BMSfreeMemoryArray(&(*param)->name); 1232 BMSfreeMemoryArray(&(*param)->desc); 1233 BMSfreeBlockMemory(blkmem, param); 1234 } 1235 1236 /** sets SCIP_Bool parameter according to the value of the given string */ 1237 static 1238 SCIP_RETCODE paramParseBool( 1239 SCIP_PARAM* param, /**< parameter */ 1240 SCIP_SET* set, /**< global SCIP settings */ 1241 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 1242 char* valuestr /**< value in string format (may be modified during parse) */ 1243 ) 1244 { 1245 assert(param != NULL); 1246 assert(param->paramtype == SCIP_PARAMTYPE_BOOL); 1247 assert(set != NULL); 1248 assert(valuestr != NULL); 1249 1250 if( strcasecmp(valuestr, "TRUE") == 0 ) 1251 { 1252 SCIP_CALL( SCIPparamSetBool(param, set, messagehdlr, TRUE, FALSE, TRUE) ); 1253 } 1254 else if( strcasecmp(valuestr, "FALSE") == 0 ) 1255 { 1256 SCIP_CALL( SCIPparamSetBool(param, set, messagehdlr, FALSE, FALSE, TRUE) ); 1257 } 1258 else 1259 { 1260 SCIPerrorMessage("invalid parameter value <%s> for SCIP_Bool parameter <%s>\n", valuestr, param->name); 1261 return SCIP_READERROR; 1262 } 1263 1264 return SCIP_OKAY; 1265 } 1266 1267 /** sets int parameter according to the value of the given string */ 1268 static 1269 SCIP_RETCODE paramParseInt( 1270 SCIP_PARAM* param, /**< parameter */ 1271 SCIP_SET* set, /**< global SCIP settings */ 1272 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 1273 char* valuestr /**< value in string format (may be modified during parse) */ 1274 ) 1275 { 1276 int value; 1277 1278 assert(param != NULL); 1279 assert(param->paramtype == SCIP_PARAMTYPE_INT); 1280 assert(set != NULL); 1281 assert(valuestr != NULL); 1282 1283 /* coverity[secure_coding] */ 1284 if( sscanf(valuestr, "%d", &value) == 1 ) 1285 { 1286 SCIP_CALL( SCIPparamSetInt(param, set, messagehdlr, value, FALSE, TRUE) ); 1287 } 1288 else 1289 { 1290 SCIPerrorMessage("invalid parameter value <%s> for int parameter <%s>\n", valuestr, param->name); 1291 return SCIP_READERROR; 1292 } 1293 1294 return SCIP_OKAY; 1295 } 1296 1297 /** sets SCIP_Longint parameter according to the value of the given string */ 1298 static 1299 SCIP_RETCODE paramParseLongint( 1300 SCIP_PARAM* param, /**< parameter */ 1301 SCIP_SET* set, /**< global SCIP settings */ 1302 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 1303 char* valuestr /**< value in string format (may be modified during parse) */ 1304 ) 1305 { 1306 SCIP_Longint value; 1307 1308 assert(param != NULL); 1309 assert(param->paramtype == SCIP_PARAMTYPE_LONGINT); 1310 assert(set != NULL); 1311 assert(valuestr != NULL); 1312 1313 /* coverity[secure_coding] */ 1314 if( sscanf(valuestr, "%" SCIP_LONGINT_FORMAT, &value) == 1 ) 1315 { 1316 SCIP_CALL( SCIPparamSetLongint(param, set, messagehdlr, value, FALSE, TRUE) ); 1317 } 1318 else 1319 { 1320 SCIPerrorMessage("invalid parameter value <%s> for SCIP_Longint parameter <%s>\n", valuestr, param->name); 1321 return SCIP_READERROR; 1322 } 1323 1324 return SCIP_OKAY; 1325 } 1326 1327 /** sets SCIP_Real parameter according to the value of the given string */ 1328 static 1329 SCIP_RETCODE paramParseReal( 1330 SCIP_PARAM* param, /**< parameter */ 1331 SCIP_SET* set, /**< global SCIP settings */ 1332 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 1333 char* valuestr /**< value in string format (may be modified during parse) */ 1334 ) 1335 { 1336 SCIP_Real value; 1337 1338 assert(param != NULL); 1339 assert(param->paramtype == SCIP_PARAMTYPE_REAL); 1340 assert(set != NULL); 1341 assert(valuestr != NULL); 1342 1343 /* coverity[secure_coding] */ 1344 if( sscanf(valuestr, "%" SCIP_REAL_FORMAT, &value) == 1 ) 1345 { 1346 SCIP_CALL( SCIPparamSetReal(param, set, messagehdlr, value, FALSE, TRUE) ); 1347 } 1348 else 1349 { 1350 SCIPerrorMessage("invalid parameter value <%s> for SCIP_Real parameter <%s>\n", valuestr, param->name); 1351 return SCIP_READERROR; 1352 } 1353 1354 return SCIP_OKAY; 1355 } 1356 1357 /** sets Char parameter according to the value of the given string */ 1358 static 1359 SCIP_RETCODE paramParseChar( 1360 SCIP_PARAM* param, /**< parameter */ 1361 SCIP_SET* set, /**< global SCIP settings */ 1362 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 1363 char* valuestr /**< value in string format (may be modified during parse) */ 1364 ) 1365 { 1366 char value; 1367 1368 assert(param != NULL); 1369 assert(param->paramtype == SCIP_PARAMTYPE_CHAR); 1370 assert(set != NULL); 1371 assert(valuestr != NULL); 1372 1373 /* coverity[secure_coding] */ 1374 if( sscanf(valuestr, "%c", &value) == 1 ) 1375 { 1376 SCIP_CALL( SCIPparamSetChar(param, set, messagehdlr, value, FALSE, TRUE) ); 1377 } 1378 else 1379 { 1380 SCIPerrorMessage("invalid parameter value <%s> for char parameter <%s>\n", valuestr, param->name); 1381 return SCIP_READERROR; 1382 } 1383 1384 return SCIP_OKAY; 1385 } 1386 1387 /** sets string parameter according to the value of the given string */ 1388 static 1389 SCIP_RETCODE paramParseString( 1390 SCIP_PARAM* param, /**< parameter */ 1391 SCIP_SET* set, /**< global SCIP settings */ 1392 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 1393 char* valuestr /**< value in string format (may be modified during parse) */ 1394 ) 1395 { 1396 unsigned int len; 1397 1398 assert(param != NULL); 1399 assert(param->paramtype == SCIP_PARAMTYPE_STRING); 1400 assert(set != NULL); 1401 assert(valuestr != NULL); 1402 1403 /* check for quotes */ 1404 len = (unsigned int) strlen(valuestr); 1405 if( len <= 1 || valuestr[0] != '"' || valuestr[len-1] != '"' ) 1406 { 1407 SCIPerrorMessage("invalid parameter value <%s> for string parameter <%s> (string has to be in double quotes)\n", 1408 valuestr, param->name); 1409 return SCIP_READERROR; 1410 } 1411 1412 /* remove the quotes */ 1413 valuestr[len-1] = '\0'; 1414 valuestr++; 1415 SCIP_CALL( SCIPparamSetString(param, set, messagehdlr, valuestr, FALSE, TRUE) ); 1416 1417 return SCIP_OKAY; 1418 } 1419 1420 1421 /* 1422 * Parameter set methods 1423 */ 1424 1425 /** creates parameter set */ 1426 SCIP_RETCODE SCIPparamsetCreate( 1427 SCIP_PARAMSET** paramset, /**< pointer to store the parameter set */ 1428 BMS_BLKMEM* blkmem /**< block memory */ 1429 ) 1430 { 1431 assert(paramset != NULL); 1432 1433 SCIP_ALLOC( BMSallocMemory(paramset) ); 1434 1435 SCIP_CALL( SCIPhashtableCreate(&(*paramset)->hashtable, blkmem, SCIP_HASHSIZE_PARAMS, 1436 hashGetKeyParam, SCIPhashKeyEqString, SCIPhashKeyValString, NULL) ); 1437 1438 (*paramset)->params = NULL; 1439 (*paramset)->nparams = 0; 1440 (*paramset)->paramssize = 0; 1441 1442 return SCIP_OKAY; 1443 } 1444 1445 /** frees parameter set */ 1446 void SCIPparamsetFree( 1447 SCIP_PARAMSET** paramset, /**< pointer to the parameter set */ 1448 BMS_BLKMEM* blkmem /**< block memory */ 1449 ) 1450 { 1451 int i; 1452 1453 assert(paramset != NULL); 1454 assert(*paramset != NULL); 1455 assert((*paramset)->paramssize == 0 || (*paramset)->params != NULL); 1456 assert((*paramset)->paramssize >= (*paramset)->nparams); 1457 1458 for( i = (*paramset)->nparams - 1; i >= 0; --i ) 1459 { 1460 paramFree(&(*paramset)->params[i], blkmem); 1461 } 1462 1463 SCIPhashtableFree(&(*paramset)->hashtable); 1464 1465 BMSfreeMemoryArrayNull(&(*paramset)->params); 1466 BMSfreeMemory(paramset); 1467 } 1468 1469 /** adds parameter to the parameter set */ 1470 static 1471 SCIP_RETCODE paramsetAdd( 1472 SCIP_PARAMSET* paramset, /**< parameter set */ 1473 SCIP_PARAM* param /**< parameter to add */ 1474 ) 1475 { 1476 assert(paramset != NULL); 1477 assert(param != NULL); 1478 1479 /* insert the parameter name to the hash table */ 1480 SCIP_CALL( SCIPhashtableSafeInsert(paramset->hashtable, (void*)param) ); 1481 1482 /* ensure, that there is enough space in the params array */ 1483 if( paramset->nparams >= paramset->paramssize ) 1484 { 1485 paramset->paramssize *= 2; 1486 paramset->paramssize = MAX(paramset->paramssize, paramset->nparams+1); 1487 SCIP_ALLOC( BMSreallocMemoryArray(¶mset->params, paramset->paramssize) ); 1488 } 1489 assert(paramset->nparams < paramset->paramssize); 1490 1491 /* insert parameter in the params array */ 1492 paramset->params[paramset->nparams] = param; 1493 paramset->nparams++; 1494 1495 return SCIP_OKAY; 1496 } 1497 1498 /** creates a SCIP_Bool parameter, sets it to its default value, and adds it to the parameter set */ 1499 SCIP_RETCODE SCIPparamsetAddBool( 1500 SCIP_PARAMSET* paramset, /**< parameter set */ 1501 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 1502 BMS_BLKMEM* blkmem, /**< block memory */ 1503 const char* name, /**< name of the parameter */ 1504 const char* desc, /**< description of the parameter */ 1505 SCIP_Bool* valueptr, /**< pointer to store the current parameter value, or NULL */ 1506 SCIP_Bool isadvanced, /**< is this parameter an advanced parameter? */ 1507 SCIP_Bool defaultvalue, /**< default value of the parameter */ 1508 SCIP_DECL_PARAMCHGD ((*paramchgd)), /**< change information method of parameter */ 1509 SCIP_PARAMDATA* paramdata /**< locally defined parameter specific data */ 1510 ) 1511 { 1512 SCIP_PARAM* param; 1513 1514 assert(paramset != NULL); 1515 1516 /* create the parameter */ 1517 SCIP_CALL( paramCreateBool(¶m, messagehdlr, blkmem, name, desc, valueptr, isadvanced, defaultvalue, paramchgd, paramdata) ); 1518 1519 /* add parameter to the parameter set */ 1520 SCIP_CALL( paramsetAdd(paramset, param) ); 1521 1522 return SCIP_OKAY; 1523 } 1524 1525 /** creates a int parameter, sets it to its default value, and adds it to the parameter set */ 1526 SCIP_RETCODE SCIPparamsetAddInt( 1527 SCIP_PARAMSET* paramset, /**< parameter set */ 1528 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 1529 BMS_BLKMEM* blkmem, /**< block memory */ 1530 const char* name, /**< name of the parameter */ 1531 const char* desc, /**< description of the parameter */ 1532 int* valueptr, /**< pointer to store the current parameter value, or NULL */ 1533 SCIP_Bool isadvanced, /**< is this parameter an advanced parameter? */ 1534 int defaultvalue, /**< default value of the parameter */ 1535 int minvalue, /**< minimum value for parameter */ 1536 int maxvalue, /**< maximum value for parameter */ 1537 SCIP_DECL_PARAMCHGD ((*paramchgd)), /**< change information method of parameter */ 1538 SCIP_PARAMDATA* paramdata /**< locally defined parameter specific data */ 1539 ) 1540 { 1541 SCIP_PARAM* param; 1542 1543 assert(paramset != NULL); 1544 1545 /* create the parameter */ 1546 SCIP_CALL( paramCreateInt(¶m, messagehdlr, blkmem, name, desc, valueptr, isadvanced, defaultvalue, minvalue, maxvalue, 1547 paramchgd, paramdata) ); 1548 1549 /* add parameter to the parameter set */ 1550 SCIP_CALL( paramsetAdd(paramset, param) ); 1551 1552 return SCIP_OKAY; 1553 } 1554 1555 /** creates a SCIP_Longint parameter, sets it to its default value, and adds it to the parameter set */ 1556 SCIP_RETCODE SCIPparamsetAddLongint( 1557 SCIP_PARAMSET* paramset, /**< parameter set */ 1558 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 1559 BMS_BLKMEM* blkmem, /**< block memory */ 1560 const char* name, /**< name of the parameter */ 1561 const char* desc, /**< description of the parameter */ 1562 SCIP_Longint* valueptr, /**< pointer to store the current parameter value, or NULL */ 1563 SCIP_Bool isadvanced, /**< is this parameter an advanced parameter? */ 1564 SCIP_Longint defaultvalue, /**< default value of the parameter */ 1565 SCIP_Longint minvalue, /**< minimum value for parameter */ 1566 SCIP_Longint maxvalue, /**< maximum value for parameter */ 1567 SCIP_DECL_PARAMCHGD ((*paramchgd)), /**< change information method of parameter */ 1568 SCIP_PARAMDATA* paramdata /**< locally defined parameter specific data */ 1569 ) 1570 { 1571 SCIP_PARAM* param; 1572 1573 assert(paramset != NULL); 1574 1575 /* create the parameter */ 1576 SCIP_CALL( paramCreateLongint(¶m, messagehdlr, blkmem, name, desc, valueptr, isadvanced, defaultvalue, minvalue, maxvalue, 1577 paramchgd, paramdata) ); 1578 1579 /* add parameter to the parameter set */ 1580 SCIP_CALL( paramsetAdd(paramset, param) ); 1581 1582 return SCIP_OKAY; 1583 } 1584 1585 /** creates a SCIP_Real parameter, sets it to its default value, and adds it to the parameter set */ 1586 SCIP_RETCODE SCIPparamsetAddReal( 1587 SCIP_PARAMSET* paramset, /**< parameter set */ 1588 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 1589 BMS_BLKMEM* blkmem, /**< block memory */ 1590 const char* name, /**< name of the parameter */ 1591 const char* desc, /**< description of the parameter */ 1592 SCIP_Real* valueptr, /**< pointer to store the current parameter value, or NULL */ 1593 SCIP_Bool isadvanced, /**< is this parameter an advanced parameter? */ 1594 SCIP_Real defaultvalue, /**< default value of the parameter */ 1595 SCIP_Real minvalue, /**< minimum value for parameter */ 1596 SCIP_Real maxvalue, /**< maximum value for parameter */ 1597 SCIP_DECL_PARAMCHGD ((*paramchgd)), /**< change information method of parameter */ 1598 SCIP_PARAMDATA* paramdata /**< locally defined parameter specific data */ 1599 ) 1600 { 1601 SCIP_PARAM* param; 1602 1603 assert(paramset != NULL); 1604 1605 /* create the parameter */ 1606 SCIP_CALL( paramCreateReal(¶m, messagehdlr, blkmem, name, desc, valueptr, isadvanced, defaultvalue, minvalue, maxvalue, 1607 paramchgd, paramdata) ); 1608 1609 /* add parameter to the parameter set */ 1610 SCIP_CALL( paramsetAdd(paramset, param) ); 1611 1612 return SCIP_OKAY; 1613 } 1614 1615 /** creates a char parameter, sets it to its default value, and adds it to the parameter set */ 1616 SCIP_RETCODE SCIPparamsetAddChar( 1617 SCIP_PARAMSET* paramset, /**< parameter set */ 1618 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 1619 BMS_BLKMEM* blkmem, /**< block memory */ 1620 const char* name, /**< name of the parameter */ 1621 const char* desc, /**< description of the parameter */ 1622 char* valueptr, /**< pointer to store the current parameter value, or NULL */ 1623 SCIP_Bool isadvanced, /**< is this parameter an advanced parameter? */ 1624 char defaultvalue, /**< default value of the parameter */ 1625 const char* allowedvalues, /**< array with possible parameter values, or NULL if not restricted */ 1626 SCIP_DECL_PARAMCHGD ((*paramchgd)), /**< change information method of parameter */ 1627 SCIP_PARAMDATA* paramdata /**< locally defined parameter specific data */ 1628 ) 1629 { 1630 SCIP_PARAM* param; 1631 1632 assert(paramset != NULL); 1633 1634 /* create the parameter */ 1635 SCIP_CALL( paramCreateChar(¶m, messagehdlr, blkmem, name, desc, valueptr, isadvanced, defaultvalue, allowedvalues, 1636 paramchgd, paramdata) ); 1637 1638 /* add parameter to the parameter set */ 1639 SCIP_CALL( paramsetAdd(paramset, param) ); 1640 1641 return SCIP_OKAY; 1642 } 1643 1644 /** creates a string parameter, sets it to its default value, and adds it to the parameter set */ 1645 SCIP_RETCODE SCIPparamsetAddString( 1646 SCIP_PARAMSET* paramset, /**< parameter set */ 1647 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 1648 BMS_BLKMEM* blkmem, /**< block memory */ 1649 const char* name, /**< name of the parameter */ 1650 const char* desc, /**< description of the parameter */ 1651 char** valueptr, /**< pointer to store the current parameter value, or NULL */ 1652 SCIP_Bool isadvanced, /**< is this parameter an advanced parameter? */ 1653 const char* defaultvalue, /**< default value of the parameter */ 1654 SCIP_DECL_PARAMCHGD ((*paramchgd)), /**< change information method of parameter */ 1655 SCIP_PARAMDATA* paramdata /**< locally defined parameter specific data */ 1656 ) 1657 { 1658 SCIP_PARAM* param; 1659 1660 assert(paramset != NULL); 1661 1662 /* create the parameter */ 1663 SCIP_CALL( paramCreateString(¶m, messagehdlr, blkmem, name, desc, valueptr, isadvanced, defaultvalue, paramchgd, paramdata) ); 1664 1665 /* add parameter to the parameter set */ 1666 SCIP_CALL( paramsetAdd(paramset, param) ); 1667 1668 return SCIP_OKAY; 1669 } 1670 1671 /** returns the name of the given parameter type */ 1672 static 1673 const char* paramtypeGetName( 1674 SCIP_PARAMTYPE paramtype /**< type of parameter */ 1675 ) 1676 { 1677 static const char* paramtypename[] = { 1678 "Bool", /* SCIP_PARAMTYPE_BOOL = 0 */ 1679 "int", /* SCIP_PARAMTYPE_INT = 1 */ 1680 "Longint", /* SCIP_PARAMTYPE_LONGINT = 2 */ 1681 "Real", /* SCIP_PARAMTYPE_REAL = 3 */ 1682 "char", /* SCIP_PARAMTYPE_CHAR = 4 */ 1683 "string" /* SCIP_PARAMTYPE_STRING = 5 */ 1684 }; 1685 1686 return paramtypename[(int)paramtype]; 1687 } 1688 1689 /** returns whether an existing parameter is fixed */ 1690 SCIP_Bool SCIPparamsetIsFixed( 1691 SCIP_PARAMSET* paramset, /**< parameter set */ 1692 const char* name /**< name of the parameter */ 1693 ) 1694 { 1695 SCIP_PARAM* param; 1696 1697 assert(paramset != NULL); 1698 1699 /* retrieve parameter from hash table */ 1700 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 1701 if( param == NULL ) 1702 { 1703 SCIPerrorMessage("parameter <%s> unknown\n", name); 1704 SCIPABORT(); 1705 return FALSE; /*lint !e527*/ 1706 } 1707 1708 return SCIPparamIsFixed(param); 1709 } 1710 1711 /** returns the pointer to an existing SCIP parameter */ 1712 SCIP_PARAM* SCIPparamsetGetParam( 1713 SCIP_PARAMSET* paramset, /**< parameter set */ 1714 const char* name /**< name of the parameter */ 1715 ) 1716 { 1717 assert(paramset != NULL); 1718 1719 /* retrieve parameter from hash table and return it */ 1720 return (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 1721 } 1722 1723 /** gets the value of an existing SCIP_Bool parameter */ 1724 SCIP_RETCODE SCIPparamsetGetBool( 1725 SCIP_PARAMSET* paramset, /**< parameter set */ 1726 const char* name, /**< name of the parameter */ 1727 SCIP_Bool* value /**< pointer to store the parameter */ 1728 ) 1729 { 1730 SCIP_PARAM* param; 1731 1732 assert(paramset != NULL); 1733 assert(value != NULL); 1734 1735 /* retrieve parameter from hash table */ 1736 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 1737 if( param == NULL ) 1738 { 1739 SCIPerrorMessage("parameter <%s> unknown\n", name); 1740 return SCIP_PARAMETERUNKNOWN; 1741 } 1742 if( param->paramtype != SCIP_PARAMTYPE_BOOL ) 1743 { 1744 SCIPerrorMessage("wrong parameter type - parameter <%s> has type <%s> instead of <%s>\n", 1745 name, paramtypeGetName(param->paramtype), paramtypeGetName(SCIP_PARAMTYPE_BOOL)); 1746 return SCIP_PARAMETERWRONGTYPE; 1747 } 1748 1749 /* get the parameter's current value */ 1750 *value = SCIPparamGetBool(param); 1751 1752 return SCIP_OKAY; 1753 } 1754 1755 /** gets the value of an existing int parameter */ 1756 SCIP_RETCODE SCIPparamsetGetInt( 1757 SCIP_PARAMSET* paramset, /**< parameter set */ 1758 const char* name, /**< name of the parameter */ 1759 int* value /**< pointer to store the parameter */ 1760 ) 1761 { 1762 SCIP_PARAM* param; 1763 1764 assert(paramset != NULL); 1765 assert(value != NULL); 1766 1767 /* retrieve parameter from hash table */ 1768 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 1769 if( param == NULL ) 1770 { 1771 SCIPerrorMessage("parameter <%s> unknown\n", name); 1772 return SCIP_PARAMETERUNKNOWN; 1773 } 1774 if( param->paramtype != SCIP_PARAMTYPE_INT ) 1775 { 1776 SCIPerrorMessage("wrong parameter type - parameter <%s> has type <%s> instead of <%s>\n", 1777 name, paramtypeGetName(param->paramtype), paramtypeGetName(SCIP_PARAMTYPE_INT)); 1778 return SCIP_PARAMETERWRONGTYPE; 1779 } 1780 1781 /* get the parameter's current value */ 1782 *value = SCIPparamGetInt(param); 1783 1784 return SCIP_OKAY; 1785 } 1786 1787 /** gets the value of an existing SCIP_Longint parameter */ 1788 SCIP_RETCODE SCIPparamsetGetLongint( 1789 SCIP_PARAMSET* paramset, /**< parameter set */ 1790 const char* name, /**< name of the parameter */ 1791 SCIP_Longint* value /**< pointer to store the parameter */ 1792 ) 1793 { 1794 SCIP_PARAM* param; 1795 1796 assert(paramset != NULL); 1797 assert(value != NULL); 1798 1799 /* retrieve parameter from hash table */ 1800 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 1801 if( param == NULL ) 1802 { 1803 SCIPerrorMessage("parameter <%s> unknown\n", name); 1804 return SCIP_PARAMETERUNKNOWN; 1805 } 1806 if( param->paramtype != SCIP_PARAMTYPE_LONGINT ) 1807 { 1808 SCIPerrorMessage("wrong parameter type - parameter <%s> has type <%s> instead of <%s>\n", 1809 name, paramtypeGetName(param->paramtype), paramtypeGetName(SCIP_PARAMTYPE_LONGINT)); 1810 return SCIP_PARAMETERWRONGTYPE; 1811 } 1812 1813 /* get the parameter's current value */ 1814 *value = SCIPparamGetLongint(param); 1815 1816 return SCIP_OKAY; 1817 } 1818 1819 /** gets the value of an existing SCIP_Real parameter */ 1820 SCIP_RETCODE SCIPparamsetGetReal( 1821 SCIP_PARAMSET* paramset, /**< parameter set */ 1822 const char* name, /**< name of the parameter */ 1823 SCIP_Real* value /**< pointer to store the parameter */ 1824 ) 1825 { 1826 SCIP_PARAM* param; 1827 1828 assert(paramset != NULL); 1829 assert(value != NULL); 1830 1831 /* retrieve parameter from hash table */ 1832 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 1833 if( param == NULL ) 1834 { 1835 SCIPerrorMessage("parameter <%s> unknown\n", name); 1836 return SCIP_PARAMETERUNKNOWN; 1837 } 1838 if( param->paramtype != SCIP_PARAMTYPE_REAL ) 1839 { 1840 SCIPerrorMessage("wrong parameter type - parameter <%s> has type <%s> instead of <%s>\n", 1841 name, paramtypeGetName(param->paramtype), paramtypeGetName(SCIP_PARAMTYPE_REAL)); 1842 return SCIP_PARAMETERWRONGTYPE; 1843 } 1844 1845 /* get the parameter's current value */ 1846 *value = SCIPparamGetReal(param); 1847 1848 return SCIP_OKAY; 1849 } 1850 1851 /** gets the value of an existing char parameter */ 1852 SCIP_RETCODE SCIPparamsetGetChar( 1853 SCIP_PARAMSET* paramset, /**< parameter set */ 1854 const char* name, /**< name of the parameter */ 1855 char* value /**< pointer to store the parameter */ 1856 ) 1857 { 1858 SCIP_PARAM* param; 1859 1860 assert(paramset != NULL); 1861 assert(value != NULL); 1862 1863 /* retrieve parameter from hash table */ 1864 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 1865 if( param == NULL ) 1866 { 1867 SCIPerrorMessage("parameter <%s> unknown\n", name); 1868 return SCIP_PARAMETERUNKNOWN; 1869 } 1870 if( param->paramtype != SCIP_PARAMTYPE_CHAR ) 1871 { 1872 SCIPerrorMessage("wrong parameter type - parameter <%s> has type <%s> instead of <%s>\n", 1873 name, paramtypeGetName(param->paramtype), paramtypeGetName(SCIP_PARAMTYPE_CHAR)); 1874 return SCIP_PARAMETERWRONGTYPE; 1875 } 1876 1877 /* get the parameter's current value */ 1878 *value = SCIPparamGetChar(param); 1879 1880 return SCIP_OKAY; 1881 } 1882 1883 /** gets the value of an existing string parameter */ 1884 SCIP_RETCODE SCIPparamsetGetString( 1885 SCIP_PARAMSET* paramset, /**< parameter set */ 1886 const char* name, /**< name of the parameter */ 1887 char** value /**< pointer to store the parameter */ 1888 ) 1889 { 1890 SCIP_PARAM* param; 1891 1892 assert(paramset != NULL); 1893 assert(value != NULL); 1894 1895 /* retrieve parameter from hash table */ 1896 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 1897 if( param == NULL ) 1898 { 1899 SCIPerrorMessage("parameter <%s> unknown\n", name); 1900 return SCIP_PARAMETERUNKNOWN; 1901 } 1902 if( param->paramtype != SCIP_PARAMTYPE_STRING ) 1903 { 1904 SCIPerrorMessage("wrong parameter type - parameter <%s> has type <%s> instead of <%s>\n", 1905 name, paramtypeGetName(param->paramtype), paramtypeGetName(SCIP_PARAMTYPE_STRING)); 1906 return SCIP_PARAMETERWRONGTYPE; 1907 } 1908 1909 /* get the parameter's current value */ 1910 *value = SCIPparamGetString(param); 1911 1912 return SCIP_OKAY; 1913 } 1914 1915 /** changes the fixing status of an existing parameter */ 1916 SCIP_RETCODE SCIPparamsetFix( 1917 SCIP_PARAMSET* paramset, /**< parameter set */ 1918 const char* name, /**< name of the parameter */ 1919 SCIP_Bool fixed /**< new fixing status of the parameter */ 1920 ) 1921 { 1922 SCIP_PARAM* param; 1923 1924 assert(paramset != NULL); 1925 1926 /* retrieve parameter from hash table */ 1927 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 1928 if( param == NULL ) 1929 { 1930 SCIPerrorMessage("parameter <%s> unknown\n", name); 1931 return SCIP_PARAMETERUNKNOWN; 1932 } 1933 1934 SCIPparamSetFixed(param, fixed); 1935 1936 return SCIP_OKAY; 1937 } 1938 1939 /** changes the value of an existing SCIP_Bool parameter */ 1940 SCIP_RETCODE SCIPparamsetSetBool( 1941 SCIP_PARAMSET* paramset, /**< parameter set */ 1942 SCIP_SET* set, /**< global SCIP settings */ 1943 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 1944 const char* name, /**< name of the parameter */ 1945 SCIP_Bool value /**< new value of the parameter */ 1946 ) 1947 { 1948 SCIP_PARAM* param; 1949 1950 assert(paramset != NULL); 1951 assert(set != NULL); 1952 1953 /* retrieve parameter from hash table */ 1954 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 1955 if( param == NULL ) 1956 { 1957 SCIPerrorMessage("parameter <%s> unknown\n", name); 1958 return SCIP_PARAMETERUNKNOWN; 1959 } 1960 if( param->paramtype != SCIP_PARAMTYPE_BOOL ) 1961 { 1962 SCIPerrorMessage("wrong parameter type - parameter <%s> has type <%s> instead of <%s>\n", 1963 name, paramtypeGetName(param->paramtype), paramtypeGetName(SCIP_PARAMTYPE_BOOL)); 1964 return SCIP_PARAMETERWRONGTYPE; 1965 } 1966 1967 /* set the parameter's current value */ 1968 SCIP_CALL( SCIPparamSetBool(param, set, messagehdlr, value, FALSE, TRUE) ); 1969 1970 return SCIP_OKAY; 1971 } 1972 1973 /** changes the value of an existing int parameter */ 1974 SCIP_RETCODE SCIPparamsetSetInt( 1975 SCIP_PARAMSET* paramset, /**< parameter set */ 1976 SCIP_SET* set, /**< global SCIP settings */ 1977 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 1978 const char* name, /**< name of the parameter */ 1979 int value /**< new value of the parameter */ 1980 ) 1981 { 1982 SCIP_PARAM* param; 1983 1984 assert(paramset != NULL); 1985 assert(set != NULL); 1986 1987 /* retrieve parameter from hash table */ 1988 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 1989 if( param == NULL ) 1990 { 1991 SCIPerrorMessage("parameter <%s> unknown\n", name); 1992 return SCIP_PARAMETERUNKNOWN; 1993 } 1994 if( param->paramtype != SCIP_PARAMTYPE_INT ) 1995 { 1996 SCIPerrorMessage("wrong parameter type - parameter <%s> has type <%s> instead of <%s>\n", 1997 name, paramtypeGetName(param->paramtype), paramtypeGetName(SCIP_PARAMTYPE_INT)); 1998 return SCIP_PARAMETERWRONGTYPE; 1999 } 2000 2001 /* set the parameter's current value */ 2002 SCIP_CALL( SCIPparamSetInt(param, set, messagehdlr, value, FALSE, TRUE) ); 2003 2004 return SCIP_OKAY; 2005 } 2006 2007 /** changes the value of an existing SCIP_Longint parameter */ 2008 SCIP_RETCODE SCIPparamsetSetLongint( 2009 SCIP_PARAMSET* paramset, /**< parameter set */ 2010 SCIP_SET* set, /**< global SCIP settings */ 2011 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 2012 const char* name, /**< name of the parameter */ 2013 SCIP_Longint value /**< new value of the parameter */ 2014 ) 2015 { 2016 SCIP_PARAM* param; 2017 2018 assert(paramset != NULL); 2019 assert(set != NULL); 2020 2021 /* retrieve parameter from hash table */ 2022 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 2023 if( param == NULL ) 2024 { 2025 SCIPerrorMessage("parameter <%s> unknown\n", name); 2026 return SCIP_PARAMETERUNKNOWN; 2027 } 2028 if( param->paramtype != SCIP_PARAMTYPE_LONGINT ) 2029 { 2030 SCIPerrorMessage("wrong parameter type - parameter <%s> has type <%s> instead of <%s>\n", 2031 name, paramtypeGetName(param->paramtype), paramtypeGetName(SCIP_PARAMTYPE_LONGINT)); 2032 return SCIP_PARAMETERWRONGTYPE; 2033 } 2034 2035 /* set the parameter's current value */ 2036 SCIP_CALL( SCIPparamSetLongint(param, set, messagehdlr, value, FALSE, TRUE) ); 2037 2038 return SCIP_OKAY; 2039 } 2040 2041 /** changes the value of an existing SCIP_Real parameter */ 2042 SCIP_RETCODE SCIPparamsetSetReal( 2043 SCIP_PARAMSET* paramset, /**< parameter set */ 2044 SCIP_SET* set, /**< global SCIP settings */ 2045 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 2046 const char* name, /**< name of the parameter */ 2047 SCIP_Real value /**< new value of the parameter */ 2048 ) 2049 { 2050 SCIP_PARAM* param; 2051 2052 assert(paramset != NULL); 2053 assert(set != NULL); 2054 2055 /* retrieve parameter from hash table */ 2056 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 2057 if( param == NULL ) 2058 { 2059 SCIPerrorMessage("parameter <%s> unknown\n", name); 2060 return SCIP_PARAMETERUNKNOWN; 2061 } 2062 if( param->paramtype != SCIP_PARAMTYPE_REAL ) 2063 { 2064 SCIPerrorMessage("wrong parameter type - parameter <%s> has type <%s> instead of <%s>\n", 2065 name, paramtypeGetName(param->paramtype), paramtypeGetName(SCIP_PARAMTYPE_REAL)); 2066 return SCIP_PARAMETERWRONGTYPE; 2067 } 2068 2069 /* set the parameter's current value */ 2070 SCIP_CALL( SCIPparamSetReal(param, set, messagehdlr, value, FALSE, TRUE) ); 2071 2072 return SCIP_OKAY; 2073 } 2074 2075 /** changes the value of an existing char parameter */ 2076 SCIP_RETCODE SCIPparamsetSetChar( 2077 SCIP_PARAMSET* paramset, /**< parameter set */ 2078 SCIP_SET* set, /**< global SCIP settings */ 2079 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 2080 const char* name, /**< name of the parameter */ 2081 char value /**< new value of the parameter */ 2082 ) 2083 { 2084 SCIP_PARAM* param; 2085 2086 assert(paramset != NULL); 2087 assert(set != NULL); 2088 2089 /* retrieve parameter from hash table */ 2090 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 2091 if( param == NULL ) 2092 { 2093 SCIPerrorMessage("parameter <%s> unknown\n", name); 2094 return SCIP_PARAMETERUNKNOWN; 2095 } 2096 if( param->paramtype != SCIP_PARAMTYPE_CHAR ) 2097 { 2098 SCIPerrorMessage("wrong parameter type - parameter <%s> has type <%s> instead of <%s>\n", 2099 name, paramtypeGetName(param->paramtype), paramtypeGetName(SCIP_PARAMTYPE_CHAR)); 2100 return SCIP_PARAMETERWRONGTYPE; 2101 } 2102 2103 /* set the parameter's current value */ 2104 SCIP_CALL( SCIPparamSetChar(param, set, messagehdlr, value, FALSE, TRUE) ); 2105 2106 return SCIP_OKAY; 2107 } 2108 2109 /** changes the value of an existing string parameter */ 2110 SCIP_RETCODE SCIPparamsetSetString( 2111 SCIP_PARAMSET* paramset, /**< parameter set */ 2112 SCIP_SET* set, /**< global SCIP settings */ 2113 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 2114 const char* name, /**< name of the parameter */ 2115 const char* value /**< new value of the parameter */ 2116 ) 2117 { 2118 SCIP_PARAM* param; 2119 2120 assert(paramset != NULL); 2121 assert(set != NULL); 2122 2123 /* retrieve parameter from hash table */ 2124 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 2125 if( param == NULL ) 2126 { 2127 SCIPerrorMessage("parameter <%s> unknown\n", name); 2128 return SCIP_PARAMETERUNKNOWN; 2129 } 2130 if( param->paramtype != SCIP_PARAMTYPE_STRING ) 2131 { 2132 SCIPerrorMessage("wrong parameter type - parameter <%s> has type <%s> instead of <%s>\n", 2133 name, paramtypeGetName(param->paramtype), paramtypeGetName(SCIP_PARAMTYPE_STRING)); 2134 return SCIP_PARAMETERWRONGTYPE; 2135 } 2136 2137 /* set the parameter's current value */ 2138 SCIP_CALL( SCIPparamSetString(param, set, messagehdlr, value, FALSE, TRUE) ); 2139 2140 return SCIP_OKAY; 2141 } 2142 2143 /** changes the value of an existing parameter */ 2144 SCIP_RETCODE SCIPparamsetSet( 2145 SCIP_PARAMSET* paramset, /**< parameter set */ 2146 SCIP_SET* set, /**< global SCIP settings */ 2147 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 2148 const char* name, /**< name of the parameter */ 2149 const char* value, /**< new value of the parameter as string */ 2150 SCIP_Bool fix /**< whether to fix parameter */ 2151 ) 2152 { 2153 SCIP_PARAM* param; 2154 2155 assert(paramset != NULL); 2156 assert(paramset->hashtable != NULL); 2157 assert(name != NULL); 2158 assert(value != NULL); 2159 2160 /* retrieve parameter from hash table */ 2161 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 2162 if( param == NULL ) 2163 { 2164 SCIPmessagePrintWarning(messagehdlr, "unknown parameter <%s>\n", name); 2165 return SCIP_OKAY; 2166 } 2167 2168 SCIPparamSetFixed(param, FALSE); 2169 2170 /* set parameter's value */ 2171 switch( param->paramtype ) 2172 { 2173 case SCIP_PARAMTYPE_BOOL: 2174 SCIP_CALL( paramParseBool(param, set, messagehdlr, (char*)value) ); 2175 break; 2176 case SCIP_PARAMTYPE_INT: 2177 SCIP_CALL( paramParseInt(param, set, messagehdlr, (char*)value) ); 2178 break; 2179 case SCIP_PARAMTYPE_LONGINT: 2180 SCIP_CALL( paramParseLongint(param, set, messagehdlr, (char*)value) ); 2181 break; 2182 case SCIP_PARAMTYPE_REAL: 2183 SCIP_CALL( paramParseReal(param, set, messagehdlr, (char*)value) ); 2184 break; 2185 case SCIP_PARAMTYPE_CHAR: 2186 SCIP_CALL( paramParseChar(param, set, messagehdlr, (char*)value) ); 2187 break; 2188 case SCIP_PARAMTYPE_STRING: 2189 SCIP_CALL( paramParseString(param, set, messagehdlr, (char*)value) ); 2190 break; 2191 default: 2192 SCIPerrorMessage("unknown parameter type\n"); 2193 return SCIP_INVALIDDATA; 2194 } 2195 2196 if( fix ) 2197 SCIPparamSetFixed(param, TRUE); 2198 2199 return SCIP_OKAY; 2200 } 2201 2202 /** changes the default value of an existing SCIP_Bool parameter */ 2203 SCIP_RETCODE SCIPparamsetSetDefaultBool( 2204 SCIP_PARAMSET* paramset, /**< parameter set */ 2205 const char* name, /**< name of the parameter */ 2206 SCIP_Bool defaultvalue /**< new default value of the parameter */ 2207 ) 2208 { 2209 SCIP_PARAM* param; 2210 2211 assert(paramset != NULL); 2212 2213 /* retrieve parameter from hash table */ 2214 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 2215 if( param == NULL ) 2216 { 2217 SCIPerrorMessage("parameter <%s> unknown\n", name); 2218 return SCIP_PARAMETERUNKNOWN; 2219 } 2220 if( param->paramtype != SCIP_PARAMTYPE_BOOL ) 2221 { 2222 SCIPerrorMessage("wrong parameter type - parameter <%s> has type <%s> instead of <%s>\n", 2223 name, paramtypeGetName(param->paramtype), paramtypeGetName(SCIP_PARAMTYPE_BOOL)); 2224 return SCIP_PARAMETERWRONGTYPE; 2225 } 2226 2227 /* set the parameter's default value */ 2228 SCIPparamSetDefaultBool(param, defaultvalue); 2229 2230 return SCIP_OKAY; 2231 } 2232 2233 /** changes the default value of an existing int parameter */ 2234 SCIP_RETCODE SCIPparamsetSetDefaultInt( 2235 SCIP_PARAMSET* paramset, /**< parameter set */ 2236 const char* name, /**< name of the parameter */ 2237 int defaultvalue /**< new default value of the parameter */ 2238 ) 2239 { 2240 SCIP_PARAM* param; 2241 2242 assert(paramset != NULL); 2243 2244 /* retrieve parameter from hash table */ 2245 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 2246 if( param == NULL ) 2247 { 2248 SCIPerrorMessage("parameter <%s> unknown\n", name); 2249 return SCIP_PARAMETERUNKNOWN; 2250 } 2251 if( param->paramtype != SCIP_PARAMTYPE_INT ) 2252 { 2253 SCIPerrorMessage("wrong parameter type - parameter <%s> has type <%s> instead of <%s>\n", 2254 name, paramtypeGetName(param->paramtype), paramtypeGetName(SCIP_PARAMTYPE_INT)); 2255 return SCIP_PARAMETERWRONGTYPE; 2256 } 2257 2258 /* set the parameter's default value */ 2259 SCIPparamSetDefaultInt(param, defaultvalue); 2260 2261 return SCIP_OKAY; 2262 } 2263 2264 /** changes the default value of an existing SCIP_Longint parameter */ 2265 SCIP_RETCODE SCIPparamsetSetDefaultLongint( 2266 SCIP_PARAMSET* paramset, /**< parameter set */ 2267 const char* name, /**< name of the parameter */ 2268 SCIP_Longint defaultvalue /**< new default value of the parameter */ 2269 ) 2270 { 2271 SCIP_PARAM* param; 2272 2273 assert(paramset != NULL); 2274 2275 /* retrieve parameter from hash table */ 2276 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 2277 if( param == NULL ) 2278 { 2279 SCIPerrorMessage("parameter <%s> unknown\n", name); 2280 return SCIP_PARAMETERUNKNOWN; 2281 } 2282 if( param->paramtype != SCIP_PARAMTYPE_LONGINT ) 2283 { 2284 SCIPerrorMessage("wrong parameter type - parameter <%s> has type <%s> instead of <%s>\n", 2285 name, paramtypeGetName(param->paramtype), paramtypeGetName(SCIP_PARAMTYPE_LONGINT)); 2286 return SCIP_PARAMETERWRONGTYPE; 2287 } 2288 2289 /* set the parameter's default value */ 2290 SCIPparamSetDefaultLongint(param, defaultvalue); 2291 2292 return SCIP_OKAY; 2293 } 2294 2295 /** changes the default value of an existing SCIP_Real parameter */ 2296 SCIP_RETCODE SCIPparamsetSetDefaultReal( 2297 SCIP_PARAMSET* paramset, /**< parameter set */ 2298 const char* name, /**< name of the parameter */ 2299 SCIP_Real defaultvalue /**< new default value of the parameter */ 2300 ) 2301 { 2302 SCIP_PARAM* param; 2303 2304 assert(paramset != NULL); 2305 2306 /* retrieve parameter from hash table */ 2307 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 2308 if( param == NULL ) 2309 { 2310 SCIPerrorMessage("parameter <%s> unknown\n", name); 2311 return SCIP_PARAMETERUNKNOWN; 2312 } 2313 if( param->paramtype != SCIP_PARAMTYPE_REAL ) 2314 { 2315 SCIPerrorMessage("wrong parameter type - parameter <%s> has type <%s> instead of <%s>\n", 2316 name, paramtypeGetName(param->paramtype), paramtypeGetName(SCIP_PARAMTYPE_REAL)); 2317 return SCIP_PARAMETERWRONGTYPE; 2318 } 2319 2320 /* set the parameter's default value */ 2321 SCIPparamSetDefaultReal(param, defaultvalue); 2322 2323 return SCIP_OKAY; 2324 } 2325 2326 /** changes the default value of an existing char parameter */ 2327 SCIP_RETCODE SCIPparamsetSetDefaultChar( 2328 SCIP_PARAMSET* paramset, /**< parameter set */ 2329 const char* name, /**< name of the parameter */ 2330 char defaultvalue /**< new default value of the parameter */ 2331 ) 2332 { 2333 SCIP_PARAM* param; 2334 2335 assert(paramset != NULL); 2336 2337 /* retrieve parameter from hash table */ 2338 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 2339 if( param == NULL ) 2340 { 2341 SCIPerrorMessage("parameter <%s> unknown\n", name); 2342 return SCIP_PARAMETERUNKNOWN; 2343 } 2344 if( param->paramtype != SCIP_PARAMTYPE_CHAR ) 2345 { 2346 SCIPerrorMessage("wrong parameter type - parameter <%s> has type <%s> instead of <%s>\n", 2347 name, paramtypeGetName(param->paramtype), paramtypeGetName(SCIP_PARAMTYPE_CHAR)); 2348 return SCIP_PARAMETERWRONGTYPE; 2349 } 2350 2351 /* set the parameter's default value */ 2352 SCIPparamSetDefaultChar(param, defaultvalue); 2353 2354 return SCIP_OKAY; 2355 } 2356 2357 /** changes the default value of an existing string parameter */ 2358 SCIP_RETCODE SCIPparamsetSetDefaultString( 2359 SCIP_PARAMSET* paramset, /**< parameter set */ 2360 const char* name, /**< name of the parameter */ 2361 const char* defaultvalue /**< new default value of the parameter */ 2362 ) 2363 { 2364 SCIP_PARAM* param; 2365 2366 assert(paramset != NULL); 2367 2368 /* retrieve parameter from hash table */ 2369 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)name); 2370 if( param == NULL ) 2371 { 2372 SCIPerrorMessage("parameter <%s> unknown\n", name); 2373 return SCIP_PARAMETERUNKNOWN; 2374 } 2375 if( param->paramtype != SCIP_PARAMTYPE_STRING ) 2376 { 2377 SCIPerrorMessage("wrong parameter type - parameter <%s> has type <%s> instead of <%s>\n", 2378 name, paramtypeGetName(param->paramtype), paramtypeGetName(SCIP_PARAMTYPE_STRING)); 2379 return SCIP_PARAMETERWRONGTYPE; 2380 } 2381 2382 /* set the parameter's default value */ 2383 SCIPparamSetDefaultString(param, defaultvalue); 2384 2385 return SCIP_OKAY; 2386 } 2387 2388 /** parses emphasis settings */ 2389 static 2390 SCIP_RETCODE emphasisParse( 2391 SCIP_PARAMSET* paramset, /**< parameter set */ 2392 SCIP_SET* set, /**< global SCIP settings */ 2393 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 2394 char* line /**< line to parse (is modified during parse, but not freed) */ 2395 ) 2396 { 2397 SCIP_PARAMSETTING paramsetting; 2398 SCIP_Bool globalemphasis = FALSE; 2399 char* paramname; 2400 char* paramvaluestr; 2401 2402 assert( paramset != NULL ); 2403 assert( line != NULL ); 2404 2405 /* find the start of the parameter name */ 2406 while ( *line == ' ' || *line == '\t' || *line == '\r' ) 2407 line++; 2408 if ( *line == '\0' || *line == '\n' || *line == '#' ) 2409 return SCIP_OKAY; 2410 paramname = line; 2411 2412 /* find the end of the parameter name */ 2413 while ( *line != ' ' && *line != '\t' && *line != '\r' && *line != '\n' && *line != '#' && *line != '\0' && *line != '=' && *line != ':' ) 2414 line++; 2415 *line = '\0'; 2416 ++line; 2417 2418 /* check for global emphasis settings */ 2419 if ( strcmp(paramname, "default") == 0 ) 2420 { 2421 SCIP_CALL( SCIPparamsetSetEmphasis(paramset, set, messagehdlr, SCIP_PARAMEMPHASIS_DEFAULT, FALSE) ); 2422 globalemphasis = TRUE; 2423 } 2424 else if ( strcmp(paramname, "counter") == 0 ) 2425 { 2426 SCIP_CALL( SCIPparamsetSetEmphasis(paramset, set, messagehdlr, SCIP_PARAMEMPHASIS_COUNTER, FALSE) ); 2427 globalemphasis = TRUE; 2428 } 2429 else if ( strcmp(paramname, "cpsolver") == 0 ) 2430 { 2431 SCIP_CALL( SCIPparamsetSetEmphasis(paramset, set, messagehdlr, SCIP_PARAMEMPHASIS_CPSOLVER, FALSE) ); 2432 globalemphasis = TRUE; 2433 } 2434 else if ( strcmp(paramname, "easycip") == 0 ) 2435 { 2436 SCIP_CALL( SCIPparamsetSetEmphasis(paramset, set, messagehdlr, SCIP_PARAMEMPHASIS_EASYCIP, FALSE) ); 2437 globalemphasis = TRUE; 2438 } 2439 else if ( strcmp(paramname, "feasibility") == 0 ) 2440 { 2441 SCIP_CALL( SCIPparamsetSetEmphasis(paramset, set, messagehdlr, SCIP_PARAMEMPHASIS_FEASIBILITY, FALSE) ); 2442 globalemphasis = TRUE; 2443 } 2444 else if ( strcmp(paramname, "hardlp") == 0 ) 2445 { 2446 SCIP_CALL( SCIPparamsetSetEmphasis(paramset, set, messagehdlr, SCIP_PARAMEMPHASIS_HARDLP, FALSE) ); 2447 globalemphasis = TRUE; 2448 } 2449 else if ( strcmp(paramname, "optimality") == 0 ) 2450 { 2451 SCIP_CALL( SCIPparamsetSetEmphasis(paramset, set, messagehdlr, SCIP_PARAMEMPHASIS_OPTIMALITY, FALSE) ); 2452 globalemphasis = TRUE; 2453 } 2454 else if ( strcmp(paramname, "numerics") == 0 ) 2455 { 2456 SCIP_CALL( SCIPparamsetSetEmphasis(paramset, set, messagehdlr, SCIP_PARAMEMPHASIS_NUMERICS, FALSE) ); 2457 globalemphasis = TRUE; 2458 } 2459 else if ( strcmp(paramname, "benchmark") == 0 ) 2460 { 2461 SCIP_CALL( SCIPparamsetSetEmphasis(paramset, set, messagehdlr, SCIP_PARAMEMPHASIS_BENCHMARK, FALSE) ); 2462 globalemphasis = TRUE; 2463 } 2464 2465 /* check whether rest of line is clean */ 2466 if ( globalemphasis ) 2467 { 2468 /* check, if the rest of the line is clean */ 2469 while ( *line == ' ' || *line == '\t' || *line == '\r' ) 2470 ++line; 2471 if ( *line != '\0' && *line != '\n' && *line != '#' ) 2472 { 2473 SCIPerrorMessage("additional characters after global emphasis setting: %s.\n", line); 2474 return SCIP_READERROR; 2475 } 2476 return SCIP_OKAY; 2477 } 2478 2479 /* find the start of the parameter value string */ 2480 while ( *line == ' ' || *line == '\t' || *line == '\r' ) 2481 ++line; 2482 if ( *line == '\0' || *line == '\n' || *line == '#' ) 2483 { 2484 SCIPerrorMessage("emphasis parameter value is missing\n"); 2485 return SCIP_READERROR; 2486 } 2487 paramvaluestr = line; 2488 2489 /* find the end of the parameter value string */ 2490 while ( *line != ' ' && *line != '\t' && *line != '\r' && *line != '\n' && *line != '#' && *line != '\0' ) 2491 ++line; 2492 2493 if ( *line == '#' ) 2494 *line = '\0'; 2495 else if ( *line != '\0' ) 2496 { 2497 *line = '\0'; 2498 ++line; 2499 /* check, if the rest of the line is clean */ 2500 while ( *line == ' ' || *line == '\t' || *line == '\r' ) 2501 ++line; 2502 if ( *line != '\0' && *line != '\n' && *line != '#' ) 2503 { 2504 SCIPerrorMessage("additional characters after emphasis parameter value: %s.\n", line); 2505 return SCIP_READERROR; 2506 } 2507 } 2508 2509 /* determine type of setting */ 2510 if ( strcmp(paramvaluestr, "default") == 0 ) 2511 paramsetting = SCIP_PARAMSETTING_DEFAULT; 2512 else if ( strcmp(paramvaluestr, "aggressive") == 0 ) 2513 paramsetting = SCIP_PARAMSETTING_AGGRESSIVE; 2514 else if ( strcmp(paramvaluestr, "fast") == 0 ) 2515 paramsetting = SCIP_PARAMSETTING_FAST; 2516 else if ( strcmp(paramvaluestr, "off") == 0 ) 2517 paramsetting = SCIP_PARAMSETTING_OFF; 2518 else 2519 { 2520 SCIPerrorMessage("unkown parameter setting: %s.\n", paramvaluestr); 2521 return SCIP_READERROR; 2522 } 2523 2524 /* check which kind of emphasis we want to set */ 2525 if ( strcmp(paramname, "heuristics") == 0 ) 2526 { 2527 SCIP_CALL( SCIPsetSetHeuristics(set, messagehdlr, paramsetting, FALSE) ); 2528 } 2529 else if ( strcmp(paramname, "presolving") == 0 ) 2530 { 2531 SCIP_CALL( SCIPsetSetPresolving(set, messagehdlr, paramsetting, FALSE) ); 2532 } 2533 else if ( strcmp(paramname, "separating") == 0 ) 2534 { 2535 SCIP_CALL( SCIPsetSetSeparating(set, messagehdlr, paramsetting, FALSE) ); 2536 } 2537 2538 return SCIP_OKAY; 2539 } 2540 2541 /** parses a parameter file line "paramname = paramvalue" and sets parameter accordingly */ 2542 static 2543 SCIP_RETCODE paramsetParse( 2544 SCIP_PARAMSET* paramset, /**< parameter set */ 2545 SCIP_SET* set, /**< global SCIP settings */ 2546 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 2547 char* line, /**< line to parse (is modified during parse, but not freed) */ 2548 SCIP_Bool* foundnormalparam /**< pointer to store whether a normal parameter (not emphasis setting) has been found */ 2549 ) 2550 { 2551 char* paramname; 2552 char* paramvaluestr; 2553 char* paramend; 2554 char* lastquote; 2555 SCIP_Bool quoted; 2556 SCIP_Bool fix = FALSE; 2557 2558 assert(paramset != NULL); 2559 assert(line != NULL); 2560 assert(foundnormalparam != NULL); 2561 2562 /* find the start of the parameter name */ 2563 while( *line == ' ' || *line == '\t' || *line == '\r' ) 2564 line++; 2565 if( *line == '\0' || *line == '\n' || *line == '#' ) 2566 return SCIP_OKAY; 2567 paramname = line; 2568 2569 /* find the end of the parameter name */ 2570 while( *line != ' ' && *line != '\t' && *line != '\r' && *line != '\n' && *line != '#' && *line != '\0' && *line != '=' && *line != ':' ) 2571 line++; 2572 paramend = line; 2573 2574 /* skip possible whitespace */ 2575 while( *line == ' ' || *line == '\t' || *line == '\r' ) 2576 line++; 2577 2578 /* check whether first part consists of "emphasis:" */ 2579 if ( *line == ':' ) 2580 { 2581 *paramend = '\0'; /* could have paramend == line */ 2582 if ( strcmp(paramname, "emphasis") != 0 ) 2583 { 2584 SCIPerrorMessage("expected \"emphasis:\" at beginning of line.\n"); 2585 return SCIP_READERROR; 2586 } 2587 2588 /* check that emphasis settings only appear at beginning of file */ 2589 if ( *foundnormalparam ) 2590 { 2591 SCIPerrorMessage("emphasis settings have to appear at top of file.\n"); 2592 return SCIP_READERROR; 2593 } 2594 2595 /* parse emphasis line */ 2596 SCIP_CALL( emphasisParse(paramset, set, messagehdlr, line+1) ); /* message handler */ 2597 return SCIP_OKAY; 2598 } 2599 else if ( *line != '=' ) 2600 { 2601 SCIPerrorMessage("expected character '=' after the parameter name.\n"); 2602 return SCIP_READERROR; 2603 } 2604 *paramend = '\0'; /* could have paramend == line */ 2605 ++line; 2606 2607 /* find the start of the parameter value string */ 2608 while( *line == ' ' || *line == '\t' || *line == '\r' ) 2609 line++; 2610 if( *line == '\0' || *line == '\n' || *line == '#' ) 2611 { 2612 SCIPerrorMessage("parameter value is missing\n"); 2613 return SCIP_READERROR; 2614 } 2615 paramvaluestr = line; 2616 2617 /* find the end of the parameter value string */ 2618 quoted = (*paramvaluestr == '"'); 2619 lastquote = NULL; 2620 while( (quoted || (*line != ' ' && *line != '\t' && *line != '\r' && *line != '\n' && *line != '#')) && *line != '\0' ) 2621 { 2622 if( *line == '"' ) 2623 lastquote = line; 2624 line++; 2625 } 2626 if( lastquote != NULL ) 2627 line = lastquote+1; 2628 if( *line == '#' ) 2629 *line = '\0'; 2630 else if( *line != '\0' ) 2631 { 2632 /* check, if the rest of the line is clean */ 2633 *line = '\0'; 2634 line++; 2635 while( *line == ' ' || *line == '\t' || *line == '\r' ) 2636 line++; 2637 if( *line == 'f' && *(line+1) == 'i' && *(line+2) == 'x' ) 2638 { 2639 fix = TRUE; 2640 line += 3; 2641 2642 while( *line == ' ' || *line == '\t' || *line == '\r' ) 2643 line++; 2644 } 2645 if( *line != '\0' && *line != '\n' && *line != '#' ) 2646 { 2647 SCIPerrorMessage("additional characters <%c> after parameter value (and possible 'fix' keyword)\n", *line); 2648 return SCIP_READERROR; 2649 } 2650 } 2651 2652 SCIP_CALL( SCIPparamsetSet(paramset, set, messagehdlr, paramname, paramvaluestr, fix) ); 2653 2654 *foundnormalparam = TRUE; 2655 2656 return SCIP_OKAY; 2657 } 2658 2659 /** reads parameters from a file */ 2660 SCIP_RETCODE SCIPparamsetRead( 2661 SCIP_PARAMSET* paramset, /**< parameter set */ 2662 SCIP_SET* set, /**< global SCIP settings */ 2663 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 2664 const char* filename /**< file name */ 2665 ) 2666 { 2667 SCIP_RETCODE retcode; 2668 SCIP_Bool foundnormalparam = FALSE; 2669 FILE* file; 2670 char line[1024]; 2671 int lineno; 2672 2673 assert(paramset != NULL); 2674 assert(filename != NULL); 2675 2676 /* open the file for reading */ 2677 file = fopen(filename, "r"); 2678 if( file == NULL ) 2679 { 2680 SCIPerrorMessage("cannot open file <%s> for reading\n", filename); 2681 SCIPprintSysError(filename); 2682 return SCIP_NOFILE; 2683 } 2684 2685 /* read the parameters from the file */ 2686 lineno = 0; 2687 retcode = SCIP_OKAY; 2688 while( fgets(line, (int) sizeof(line), file) != NULL && retcode == SCIP_OKAY ) 2689 { 2690 lineno++; 2691 retcode = paramsetParse(paramset, set, messagehdlr, line, &foundnormalparam); 2692 } 2693 2694 /* close input file */ 2695 fclose(file); 2696 2697 if( retcode == SCIP_READERROR ) 2698 { 2699 SCIPerrorMessage("input error in file <%s> line %d\n", filename, lineno); 2700 } 2701 else 2702 { 2703 SCIP_CALL( retcode ); 2704 } 2705 2706 return SCIP_OKAY; 2707 } 2708 2709 /** writes all parameters in the parameter set to a file */ 2710 SCIP_RETCODE SCIPparamsetWrite( 2711 SCIP_PARAMSET* paramset, /**< parameter set */ 2712 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 2713 const char* filename, /**< file name, or NULL for stdout */ 2714 SCIP_Bool comments, /**< should parameter descriptions be written as comments? */ 2715 SCIP_Bool onlychanged /**< should only the parameters been written, that are changed from default? */ 2716 ) 2717 { 2718 SCIP_RETCODE retcode; 2719 FILE* file; 2720 SCIP_Bool oldquiet = FALSE; 2721 int i; 2722 2723 assert(paramset != NULL); 2724 2725 /* open the file for writing */ 2726 if( filename != NULL ) 2727 { 2728 file = fopen(filename, "w"); 2729 if( file == NULL ) 2730 { 2731 SCIPerrorMessage("cannot open file <%s> for writing\n", filename); 2732 SCIPprintSysError(filename); 2733 return SCIP_FILECREATEERROR; 2734 } 2735 2736 /* temporarily set the quiet flag of the message handler to FALSE */ 2737 if( messagehdlr != NULL ) 2738 { 2739 oldquiet = SCIPmessagehdlrIsQuiet(messagehdlr); 2740 SCIPmessagehdlrSetQuiet(messagehdlr, FALSE); 2741 } 2742 } 2743 else 2744 file = NULL; 2745 2746 if( comments ) 2747 { 2748 /* display the SCIP version as comment in the first line */ 2749 #if( SCIP_SUBVERSION == 0 ) 2750 SCIPmessageFPrintInfo(messagehdlr, file, "# SCIP version %d.%d.%d\n", 2751 SCIP_VERSION_MAJOR, SCIP_VERSION_MINOR, SCIP_VERSION_PATCH); 2752 #else 2753 SCIPmessageFPrintInfo(messagehdlr, file, "# SCIP version %d.%d.%d.%d\n", 2754 SCIP_VERSION_MAJOR, SCIP_VERSION_MINOR, SCIP_VERSION_PATCH, SCIP_SUBVERSION); 2755 #endif 2756 2757 SCIPmessageFPrintInfo(messagehdlr, file, "\n"); 2758 } 2759 2760 /* write the parameters to the file */ 2761 for( i = 0; i < paramset->nparams; ++i ) 2762 { 2763 retcode = paramWrite(paramset->params[i], messagehdlr, file, comments, onlychanged); 2764 if( retcode != SCIP_OKAY ) 2765 { 2766 if( filename != NULL ) 2767 { 2768 assert(file != NULL); 2769 fclose(file); 2770 } 2771 SCIP_CALL( retcode ); 2772 } 2773 } 2774 2775 /* close output file */ 2776 if( filename != NULL ) 2777 { 2778 assert(file != NULL); /*lint !e449*/ 2779 2780 /* reset the quiet flag of the message handler */ 2781 if( messagehdlr != NULL ) 2782 { 2783 SCIPmessagehdlrSetQuiet(messagehdlr, oldquiet); 2784 } 2785 2786 fclose(file); 2787 } 2788 2789 return SCIP_OKAY; 2790 } /*lint !e593*/ 2791 2792 /** installs default values for all parameters */ 2793 SCIP_RETCODE SCIPparamsetSetToDefaults( 2794 SCIP_PARAMSET* paramset, /**< parameter set */ 2795 SCIP_SET* set, /**< global SCIP settings */ 2796 SCIP_MESSAGEHDLR* messagehdlr /**< message handler */ 2797 ) 2798 { 2799 int i; 2800 2801 /* set all parameters to their default values */ 2802 for( i = 0; i < paramset->nparams; ++i ) 2803 { 2804 SCIP_CALL( SCIPparamSetToDefault(paramset->params[i], set, messagehdlr) ); 2805 } 2806 2807 return SCIP_OKAY; 2808 } 2809 2810 /** installs default value for a single parameter */ 2811 SCIP_RETCODE SCIPparamsetSetToDefault( 2812 SCIP_PARAMSET* paramset, /**< parameter set */ 2813 SCIP_SET* set, /**< global SCIP settings */ 2814 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 2815 const char* paramname /**< name of the parameter */ 2816 ) 2817 { 2818 SCIP_PARAM* param; 2819 2820 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)paramname); 2821 2822 if( param != NULL ) 2823 { 2824 SCIP_CALL( SCIPparamSetToDefault(param, set, messagehdlr) ); 2825 } 2826 2827 return SCIP_OKAY; 2828 } 2829 2830 /** resets parameters changed by SCIPparamsetSetHeuristicsXyz functions to their default values 2831 * 2832 * @note fixed parameters stay as they are; you need to unfix them first if they should be changed, too 2833 */ /*lint --e{715}*/ 2834 static 2835 SCIP_RETCODE paramsetSetHeuristicsDefault( 2836 SCIP_PARAMSET* paramset, /**< parameter set */ 2837 SCIP_SET* set, /**< global SCIP settings */ 2838 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 2839 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 2840 ) 2841 { /*lint --e{715}*/ 2842 SCIP_HEUR** heurs; 2843 char paramname[SCIP_MAXSTRLEN]; 2844 int nheurs; 2845 int i; 2846 2847 heurs = set->heurs; 2848 nheurs = set->nheurs; 2849 2850 for( i = 0; i < nheurs; ++i ) 2851 { 2852 const char* heurname; 2853 heurname = SCIPheurGetName(heurs[i]); 2854 2855 /* set frequency parameter to default */ 2856 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "heuristics/%s/freq", heurname); 2857 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, paramname) ); 2858 2859 /* set LP iteration offset to default */ 2860 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "heuristics/%s/maxlpiterofs", heurname); 2861 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, paramname) ); 2862 2863 /* set LP iteration quota to default */ 2864 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "heuristics/%s/maxlpiterquot", heurname); 2865 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, paramname) ); 2866 } 2867 2868 /* set specific parameters for RENS heuristic */ 2869 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "heuristics/rens/nodesofs") ); 2870 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "heuristics/rens/minfixingrate") ); 2871 2872 /* set specific parameters for Crossover heuristic */ 2873 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "heuristics/crossover/nwaitingnodes") ); 2874 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "heuristics/crossover/dontwaitatroot") ); 2875 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "heuristics/crossover/nodesquot") ); 2876 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "heuristics/crossover/minfixingrate") ); 2877 2878 return SCIP_OKAY; 2879 } 2880 2881 /** sets heuristics to aggressive */ 2882 static 2883 SCIP_RETCODE paramsetSetHeuristicsAggressive( 2884 SCIP_PARAMSET* paramset, /**< parameter set */ 2885 SCIP_SET* set, /**< global SCIP settings */ 2886 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 2887 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 2888 ) 2889 { 2890 SCIP_HEUR** heurs; 2891 SCIP_PARAM* param; 2892 char paramname[SCIP_MAXSTRLEN]; 2893 int nheurs; 2894 int i; 2895 2896 heurs = set->heurs; 2897 nheurs = set->nheurs; 2898 2899 SCIP_CALL( paramsetSetHeuristicsDefault(paramset, set, messagehdlr, quiet) ); 2900 2901 for( i = 0; i < nheurs; ++i ) 2902 { 2903 const char* heurname; 2904 heurname = SCIPheurGetName(heurs[i]); 2905 2906 /* dualval heuristic should stay disabled */ 2907 if( strcmp(heurname, "dualval") == 0 ) 2908 continue; 2909 2910 /* the aggressive Benders' decomposition heuristics should remain disabled */ 2911 if( strstr(heurname, "benders") != NULL ) 2912 continue; 2913 2914 /* get frequency parameter of heuristic */ 2915 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "heuristics/%s/freq", heurname); 2916 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)paramname); 2917 2918 if( param != NULL ) 2919 { 2920 int deffreq; 2921 int newfreq; 2922 2923 assert(SCIPparamGetType(param) == SCIP_PARAMTYPE_INT); 2924 deffreq = SCIPparamGetIntDefault(param); 2925 2926 /* change frequency to half of the default value, if it is > 0, otherwise set to 20 */ 2927 if( deffreq == -1 || deffreq == 0 ) 2928 { 2929 newfreq = 20; 2930 } 2931 else 2932 { 2933 newfreq = (int) SCIPsetCeil(set, deffreq/2.0); 2934 newfreq = MAX(newfreq, 1); 2935 } 2936 2937 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, paramname, newfreq, quiet) ); 2938 2939 /* LP iteration limits only get increased for heuristics which are activated by default */ 2940 if( SCIPparamGetIntDefault(param) > -1 ) 2941 { 2942 /* construct (possible) parameter name for LP iteration offset */ 2943 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "heuristics/%s/maxlpiterofs", heurname); 2944 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)paramname); 2945 2946 if( param != NULL && SCIPparamGetType(param) == SCIP_PARAMTYPE_INT ) 2947 { 2948 /* set LP iteration offset to 1.5 time the current value */ 2949 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, paramname, (int) (1.5 * SCIPparamGetIntDefault(param)), quiet) ); 2950 } 2951 2952 /* construct (possible) parameter name for LP iteration quotient parameter */ 2953 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "heuristics/%s/maxlpiterquot", heurname); 2954 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)paramname); 2955 2956 if( param != NULL && SCIPparamGetType(param) == SCIP_PARAMTYPE_REAL ) 2957 { 2958 /* set LP iteration quotient to 1.5 time the current value */ 2959 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, paramname, 1.5 * SCIPparamGetRealDefault(param), quiet) ); 2960 } 2961 } 2962 } 2963 } 2964 2965 /* set specific parameters for RENS heuristic, if the heuristic is included */ 2966 #ifndef NDEBUG 2967 if( SCIPsetFindHeur(set, "rens") != NULL ) 2968 #endif 2969 { 2970 SCIP_CALL( paramSetLongint(paramset, set, messagehdlr, "heuristics/rens/nodesofs", (SCIP_Longint)2000, quiet) ); 2971 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "heuristics/rens/minfixingrate", 0.3, quiet) ); 2972 } 2973 2974 /* set specific parameters for Crossover heuristic, if the heuristic is included */ 2975 #ifndef NDEBUG 2976 if( SCIPsetFindHeur(set, "crossover") != NULL ) 2977 #endif 2978 { 2979 SCIP_CALL( paramSetLongint(paramset, set, messagehdlr, "heuristics/crossover/nwaitingnodes", (SCIP_Longint)20, quiet) ); 2980 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "heuristics/crossover/dontwaitatroot", TRUE, quiet) ); 2981 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "heuristics/crossover/nodesquot", 0.15, quiet) ); 2982 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "heuristics/crossover/minfixingrate", 0.5, quiet) ); 2983 } 2984 2985 /* set specific parameters for Adaptive Large Neighborhood Search heuristic, if the heuristic is included */ 2986 #ifndef NDEBUG 2987 if( SCIPsetFindHeur(set, "alns") != NULL ) 2988 #endif 2989 { 2990 /* activate all neighborhoods explicitly (keep list in alphabetic order) */ 2991 int nneighborhoods = 9; 2992 const char* neighborhoodnames[] = { 2993 "crossover", 2994 "dins", 2995 "localbranching", 2996 "mutation", 2997 "proximity", 2998 "rens", 2999 "rins", 3000 "trustregion", 3001 "zeroobjective" 3002 }; 3003 for( i = 0; i < nneighborhoods; ++i ) 3004 { 3005 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "heuristics/alns/%s/active", neighborhoodnames[i]); 3006 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, paramname, TRUE, quiet) ); 3007 } 3008 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "heuristics/alns/nodesquot", 0.2, quiet) ); 3009 SCIP_CALL( paramSetLongint(paramset, set, messagehdlr, "heuristics/alns/nodesofs", (SCIP_Longint)2000, quiet) ); 3010 } 3011 3012 return SCIP_OKAY; 3013 } 3014 3015 /** sets heuristics to fast */ 3016 static 3017 SCIP_RETCODE paramsetSetHeuristicsFast( 3018 SCIP_PARAMSET* paramset, /**< parameter set */ 3019 SCIP_SET* set, /**< global SCIP settings */ 3020 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 3021 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 3022 ) 3023 { 3024 int i; 3025 3026 SCIP_HEUR** heurs; 3027 int nheurs; 3028 3029 #define NEXPENSIVEHEURFREQS 12 3030 static const char* const expensiveheurfreqs[NEXPENSIVEHEURFREQS] = { 3031 "heuristics/coefdiving/freq", 3032 "heuristics/distributiondiving/freq", 3033 "heuristics/feaspump/freq", 3034 "heuristics/fracdiving/freq", 3035 "heuristics/guideddiving/freq", 3036 "heuristics/linesearchdiving/freq", 3037 "heuristics/nlpdiving/freq", 3038 "heuristics/subnlp/freq", 3039 "heuristics/objpscostdiving/freq", 3040 "heuristics/pscostdiving/freq", 3041 "heuristics/rootsoldiving/freq", 3042 "heuristics/veclendiving/freq" 3043 }; 3044 3045 SCIP_CALL( paramsetSetHeuristicsDefault(paramset, set, messagehdlr, quiet) ); 3046 3047 /* disable all heuristics that use subSCIPs */ 3048 heurs = SCIPgetHeurs(set->scip); 3049 nheurs = SCIPgetNHeurs(set->scip); 3050 for( i = 0; i < nheurs; ++i ) 3051 { 3052 if( SCIPheurUsesSubscip(heurs[i]) ) 3053 { 3054 char paramname[SCIP_MAXSTRLEN]; 3055 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "heuristics/%s/freq", SCIPheurGetName(heurs[i])); 3056 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, paramname, -1, quiet) ); 3057 } 3058 } 3059 3060 /* explicitly turn off further expensive heuristics, if included */ 3061 for( i = 0; i < NEXPENSIVEHEURFREQS; ++i ) 3062 if( SCIPhashtableRetrieve(paramset->hashtable, (void*)expensiveheurfreqs[i]) != NULL ) 3063 { 3064 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, expensiveheurfreqs[i], -1, quiet) ); 3065 } 3066 3067 return SCIP_OKAY; 3068 } 3069 3070 /** turns all heuristics off */ 3071 static 3072 SCIP_RETCODE paramsetSetHeuristicsOff( 3073 SCIP_PARAMSET* paramset, /**< parameter set */ 3074 SCIP_SET* set, /**< global SCIP settings */ 3075 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 3076 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 3077 ) 3078 { 3079 SCIP_HEUR** heurs; 3080 char paramname[SCIP_MAXSTRLEN]; 3081 int nheurs; 3082 int i; 3083 3084 heurs = set->heurs; 3085 nheurs = set->nheurs; 3086 3087 SCIP_CALL( paramsetSetHeuristicsDefault(paramset, set, messagehdlr, quiet) ); 3088 3089 for( i = 0; i < nheurs; ++i ) 3090 { 3091 const char* heurname; 3092 heurname = SCIPheurGetName(heurs[i]); 3093 3094 /* get frequency parameter of heuristic */ 3095 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "heuristics/%s/freq", heurname); 3096 3097 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, paramname, -1, quiet) ); 3098 } 3099 3100 return SCIP_OKAY; 3101 } 3102 3103 /** resets all parameters that start with "presolving" in their name to their default value; additionally set the 3104 * parameters which might have previously been changed by the methods SCIPparamsetSetToPresolving{Off,Fast,Aggressive} 3105 * to their default value 3106 * 3107 * @note fixed parameters stay as they are; you need to unfix them first if they should be changed, too 3108 */ 3109 static 3110 SCIP_RETCODE paramsetSetPresolvingDefault( 3111 SCIP_PARAMSET* paramset, /**< parameter set */ 3112 SCIP_SET* set, /**< global SCIP settings */ 3113 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 3114 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 3115 ) 3116 { /*lint --e{715}*/ 3117 SCIP_PROP** props; 3118 SCIP_CONSHDLR** conshdlrs; 3119 SCIP_PRESOL** presols; 3120 char paramname[SCIP_MAXSTRLEN]; 3121 int nprops; 3122 int nconshdlrs; 3123 int npresols; 3124 int i; 3125 3126 presols = set->presols; 3127 npresols = set->npresols; 3128 3129 /* reset each individual presolver */ 3130 for( i = 0; i < npresols; ++i ) 3131 { 3132 const char* presolname; 3133 presolname = SCIPpresolGetName(presols[i]); 3134 3135 /* reset maxrounds parameter of presolvers */ 3136 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "presolving/%s/maxrounds", presolname); 3137 3138 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, paramname) ); 3139 } 3140 3141 props = set->props; 3142 nprops = set->nprops; 3143 3144 /* reset presolving for each individual propagator */ 3145 for( i = 0; i < nprops; ++i ) 3146 { 3147 const char* propname; 3148 propname = SCIPpropGetName(props[i]); 3149 3150 /* reset maxprerounds parameter of propagator */ 3151 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "propagating/%s/maxprerounds", propname); 3152 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, paramname) ); 3153 } 3154 3155 conshdlrs = set->conshdlrs; 3156 nconshdlrs = set->nconshdlrs; 3157 3158 /* reset presolving settings for each individual constraint handler */ 3159 for( i = 0; i < nconshdlrs; ++i ) 3160 { 3161 const char* conshdlrname; 3162 conshdlrname = SCIPconshdlrGetName(conshdlrs[i]); 3163 3164 /* reset maxprerounds parameter of constraint handler */ 3165 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/maxprerounds", conshdlrname); 3166 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, paramname) ); 3167 3168 /* reset presolpairwise parameter of constraint handler */ 3169 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/presolpairwise", conshdlrname); 3170 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, paramname) ); 3171 } 3172 3173 /* explicitly reset parameters of setppc constraint handler, if the constraint handler is included */ 3174 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "constraints/setppc/cliquelifting") ); 3175 3176 /* explicitly reset parameters of knapsack constraint handler, if the constraint handler is included */ 3177 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "constraints/knapsack/disaggregation") ); 3178 3179 /* explicitly reset restart and maxrounds parameters */ 3180 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "presolving/maxrestarts") ); 3181 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "presolving/restartfac") ); 3182 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "presolving/restartminred") ); 3183 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "presolving/maxrounds") ); 3184 3185 /* explicitly reset probing parameters */ 3186 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "propagating/probing/maxuseless") ); 3187 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "propagating/probing/maxtotaluseless") ); 3188 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "propagating/probing/maxprerounds") ); 3189 3190 return SCIP_OKAY; 3191 } 3192 3193 /** sets presolving to aggressive */ 3194 static 3195 SCIP_RETCODE paramsetSetPresolvingAggressive( 3196 SCIP_PARAMSET* paramset, /**< parameter set */ 3197 SCIP_SET* set, /**< global SCIP settings */ 3198 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 3199 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 3200 ) 3201 { 3202 SCIP_PARAM* param; 3203 SCIP_PRESOL** presols; 3204 char paramname[SCIP_MAXSTRLEN]; 3205 int npresols; 3206 int p; 3207 3208 /* reset previous changes on presolving parameters */ 3209 SCIP_CALL( paramsetSetPresolvingDefault(paramset, set, messagehdlr, quiet) ); 3210 3211 /* explicitly change restart parameters */ 3212 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "presolving/restartfac", 0.0125, quiet) ); 3213 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "presolving/restartminred", 0.06, quiet) ); 3214 3215 /* explicitly enable clique lifting of setppc constraint handler, if included */ 3216 #ifndef NDEBUG 3217 if( SCIPsetFindConshdlr(set, "setppc") != NULL ) 3218 #endif 3219 { 3220 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "constraints/setppc/cliquelifting", TRUE, quiet) ); 3221 } 3222 3223 presols = set->presols; 3224 npresols = set->npresols; 3225 3226 /* enable all presolvers except for convertinttobin */ 3227 for( p = 0; p < npresols; ++p ) 3228 { 3229 const char* presolname; 3230 presolname = SCIPpresolGetName(presols[p]); 3231 3232 /* convertinttobin alters the problem formulation, which needs to be actively enabled by the user */ 3233 if( strcmp(presolname, "convertinttobin") == 0 ) 3234 continue; 3235 3236 /* get maxrounds parameter of presolvers */ 3237 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "presolving/%s/maxrounds", presolname); 3238 3239 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, paramname, -1, quiet) ); 3240 } 3241 3242 /* explicitly change parameters of probing */ 3243 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "propagating/probing/maxuseless"); 3244 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)paramname); 3245 if( param != NULL ) 3246 { 3247 int defvalue; 3248 3249 assert(SCIPparamGetType(param) == SCIP_PARAMTYPE_INT); 3250 defvalue = SCIPparamGetIntDefault(param); 3251 3252 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, paramname, (int) (1.5 * defvalue), quiet) ); 3253 } 3254 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "propagating/probing/maxtotaluseless"); 3255 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)paramname); 3256 if( param != NULL ) 3257 { 3258 int defvalue; 3259 3260 assert(SCIPparamGetType(param) == SCIP_PARAMTYPE_INT); 3261 defvalue = SCIPparamGetIntDefault(param); 3262 3263 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, paramname, (int) (1.5 * defvalue), quiet) ); 3264 } 3265 3266 return SCIP_OKAY; 3267 } 3268 3269 /** sets presolving to fast */ 3270 static 3271 SCIP_RETCODE paramsetSetPresolvingFast( 3272 SCIP_PARAMSET* paramset, /**< parameter set */ 3273 SCIP_SET* set, /**< global SCIP settings */ 3274 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 3275 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 3276 ) 3277 { 3278 SCIP_CONSHDLR** conshdlrs; 3279 SCIP_PARAM* param; 3280 char paramname[SCIP_MAXSTRLEN]; 3281 int nconshdlrs; 3282 int i; 3283 3284 /* reset previous changes on presolving parameters */ 3285 SCIP_CALL( paramsetSetPresolvingDefault(paramset, set, messagehdlr, quiet) ); 3286 3287 conshdlrs = set->conshdlrs; 3288 nconshdlrs = set->nconshdlrs; 3289 3290 /* turn off pairwise comparison for each constraint handler that has this feature */ 3291 for( i = 0; i < nconshdlrs; ++i ) 3292 { 3293 const char* conshdlrname; 3294 conshdlrname = SCIPconshdlrGetName(conshdlrs[i]); 3295 3296 /* get presolpairwise parameter of constraint handler */ 3297 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/presolpairwise", conshdlrname); 3298 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)paramname); 3299 3300 if( param != NULL && SCIPparamGetType(param) == SCIP_PARAMTYPE_BOOL ) 3301 { 3302 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, paramname, FALSE, quiet) ); 3303 } 3304 } 3305 3306 /* explicitly turn off restarts */ 3307 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "presolving/maxrestarts", 0, quiet) ); 3308 3309 /* explicitly change parameters of presolver convertinttobin, if included */ 3310 #ifndef NDEBUG 3311 if( SCIPsetFindPresol(set, "convertinttobin") != NULL ) 3312 #endif 3313 { 3314 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "presolving/convertinttobin/maxrounds", 0, quiet) ); 3315 } 3316 3317 /* turn off probing, if included */ 3318 #ifndef NDEBUG 3319 if( SCIPsetFindProp(set, "probing") != NULL ) 3320 #endif 3321 { 3322 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "propagating/probing/maxprerounds", 0, quiet) ); 3323 } 3324 3325 /* explicitly disable components constraint handler, if included */ 3326 #ifndef NDEBUG 3327 if( SCIPsetFindConshdlr(set, "components") != NULL ) 3328 #endif 3329 { 3330 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "constraints/components/maxprerounds", 0, quiet) ); 3331 } 3332 3333 /* explicitly disable dominated columns presolver, if included */ 3334 #ifndef NDEBUG 3335 if( SCIPsetFindPresol(set, "domcol") != NULL ) 3336 #endif 3337 { 3338 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "presolving/domcol/maxrounds", 0, quiet) ); 3339 } 3340 3341 /* explicitly disable gate extraction presolver, if included */ 3342 #ifndef NDEBUG 3343 if( SCIPsetFindPresol(set, "gateextraction") != NULL ) 3344 #endif 3345 { 3346 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "presolving/gateextraction/maxrounds", 0, quiet) ); 3347 } 3348 3349 /* explicitly disable sparsify presolver, if included */ 3350 #ifndef NDEBUG 3351 if( SCIPsetFindPresol(set, "sparsify") != NULL ) 3352 #endif 3353 { 3354 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "presolving/sparsify/maxrounds", 0, quiet) ); 3355 } 3356 3357 /* explicitly disable dual sparsify presolver, if included */ 3358 #ifndef NDEBUG 3359 if( SCIPsetFindPresol(set, "dualsparsify") != NULL ) 3360 #endif 3361 { 3362 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "presolving/dualsparsify/maxrounds", 0, quiet) ); 3363 } 3364 3365 /* explicitly disable tworowbnd presolver, if included */ 3366 #ifndef NDEBUG 3367 if( SCIPsetFindPresol(set, "tworowbnd") != NULL ) 3368 #endif 3369 { 3370 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "presolving/tworowbnd/maxrounds", 0, quiet) ); 3371 } 3372 3373 /* explicitly forbid the use of implications in logicor presolving */ 3374 #ifndef NDEBUG 3375 if( SCIPsetFindConshdlr(set, "logicor") != NULL ) 3376 #endif 3377 { 3378 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "constraints/logicor/implications", 0, quiet) ); 3379 } 3380 3381 return SCIP_OKAY; 3382 } 3383 3384 /** turns all presolving off */ 3385 static 3386 SCIP_RETCODE paramsetSetPresolvingOff( 3387 SCIP_PARAMSET* paramset, /**< parameter set */ 3388 SCIP_SET* set, /**< global SCIP settings */ 3389 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 3390 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 3391 ) 3392 { 3393 SCIP_PRESOL** presols; 3394 SCIP_PROP** props; 3395 SCIP_CONSHDLR** conshdlrs; 3396 char paramname[SCIP_MAXSTRLEN]; 3397 int npresols; 3398 int nprops; 3399 int nconshdlrs; 3400 int i; 3401 3402 /* reset previous changes on presolving parameters */ 3403 SCIP_CALL( paramsetSetPresolvingDefault(paramset, set, messagehdlr, quiet) ); 3404 3405 presols = set->presols; 3406 npresols = set->npresols; 3407 3408 /* turn each individual presolver off */ 3409 for( i = 0; i < npresols; ++i ) 3410 { 3411 const char* presolname; 3412 presolname = SCIPpresolGetName(presols[i]); 3413 3414 /* get maxrounds parameter of presolvers */ 3415 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "presolving/%s/maxrounds", presolname); 3416 3417 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, paramname, 0, quiet) ); 3418 } 3419 3420 props = set->props; 3421 nprops = set->nprops; 3422 3423 /* turn off presolving for each individual propagator */ 3424 for( i = 0; i < nprops; ++i ) 3425 { 3426 const char* propname; 3427 propname = SCIPpropGetName(props[i]); 3428 3429 /* get maxrounds parameter of propagator */ 3430 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "propagating/%s/maxprerounds", propname); 3431 3432 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, paramname, 0, quiet) ); 3433 } 3434 3435 conshdlrs = set->conshdlrs; 3436 nconshdlrs = set->nconshdlrs; 3437 3438 /* turn off presolving for each individual constraint handler */ 3439 for( i = 0; i < nconshdlrs; ++i ) 3440 { 3441 const char* conshdlrname; 3442 conshdlrname = SCIPconshdlrGetName(conshdlrs[i]); 3443 3444 /* get maxprerounds parameter of constraint handler */ 3445 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/maxprerounds", conshdlrname); 3446 3447 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, paramname, 0, quiet) ); 3448 } 3449 3450 /* explicitly turn off restarts */ 3451 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "presolving/maxrestarts", 0, quiet) ); 3452 3453 /* set the maximum number of presolving rounds to zero */ 3454 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "presolving/maxrounds", 0, quiet) ); 3455 3456 return SCIP_OKAY; 3457 } 3458 3459 /** reset parameters that may have been changed by other SCIPparamsetSetSeparatingXyz to their default values 3460 * 3461 * @note fixed parameters stay as they are; you need to unfix them first if they should be changed, too 3462 */ /*lint !e715*/ 3463 static 3464 SCIP_RETCODE paramsetSetSeparatingDefault( 3465 SCIP_PARAMSET* paramset, /**< parameter set */ 3466 SCIP_SET* set, /**< global SCIP settings */ 3467 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 3468 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 3469 ) 3470 { /*lint --e{715}*/ 3471 SCIP_SEPA** sepas; 3472 SCIP_CONSHDLR** conshdlrs; 3473 char paramname[SCIP_MAXSTRLEN]; 3474 int nconshdlrs; 3475 int nsepas; 3476 int i; 3477 3478 sepas = set->sepas; 3479 nsepas = set->nsepas; 3480 3481 /* reset separating parameters of all separators */ 3482 for( i = 0; i < nsepas; ++i ) 3483 { 3484 const char* sepaname; 3485 sepaname = SCIPsepaGetName(sepas[i]); 3486 3487 /* reset frequency parameter of separator */ 3488 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "separating/%s/freq", sepaname); 3489 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, paramname) ); 3490 3491 /* reset maximum number of rounds in root node */ 3492 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "separating/%s/maxroundsroot", sepaname); 3493 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, paramname) ); 3494 3495 /* reset maximum number of cuts per separation in root node */ 3496 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "separating/%s/maxsepacutsroot", sepaname); 3497 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, paramname) ); 3498 } 3499 3500 conshdlrs = set->conshdlrs; 3501 nconshdlrs = set->nconshdlrs; 3502 3503 /* reset each individual constraint handler separation settings */ 3504 for( i = 0; i < nconshdlrs; ++i ) 3505 { 3506 const char* conshdlrname; 3507 conshdlrname = SCIPconshdlrGetName(conshdlrs[i]); 3508 3509 /* reset separation frequency parameter of constraint handler, if available */ 3510 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/sepafreq", conshdlrname); 3511 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, paramname) ); 3512 3513 /* reset maximal separated cuts in root node of constraint handler, if available */ 3514 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/maxsepacutsroot", conshdlrname); 3515 if( SCIPhashtableRetrieve(paramset->hashtable, (void*)paramname) != NULL ) 3516 { 3517 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, paramname) ); 3518 } 3519 } 3520 3521 /* explicitly reset individual parameters */ 3522 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "constraints/linear/separateall") ); 3523 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "cutselection/hybrid/minorthoroot") ); 3524 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "separating/maxroundsrootsubrun") ); 3525 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "separating/maxaddrounds") ); 3526 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "separating/maxcutsroot") ); 3527 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "separating/poolfreq") ); 3528 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "separating/aggregation/maxfailsroot") ); 3529 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "separating/mcf/maxtestdelta") ); 3530 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "separating/mcf/trynegscaling") ); 3531 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "separating/aggregation/maxtriesroot") ); 3532 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "separating/aggregation/maxaggrsroot") ); 3533 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "separating/maxbounddist") ); 3534 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "separating/zerohalf/maxslackroot") ); 3535 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "separating/zerohalf/maxslack") ); 3536 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "separating/zerohalf/maxsepacutsroot") ); 3537 SCIP_CALL( SCIPparamsetSetToDefault(paramset, set, messagehdlr, "separating/zerohalf/maxroundsroot") ); 3538 3539 return SCIP_OKAY; 3540 } 3541 3542 /** sets separating to aggressive */ 3543 static 3544 SCIP_RETCODE paramsetSetSeparatingAggressive( 3545 SCIP_PARAMSET* paramset, /**< parameter set */ 3546 SCIP_SET* set, /**< global SCIP settings */ 3547 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 3548 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 3549 ) 3550 { 3551 SCIP_CONSHDLR** conshdlrs; 3552 SCIP_SEPA** sepas; 3553 SCIP_PARAM* param; 3554 char paramname[SCIP_MAXSTRLEN]; 3555 int nconshdlrs; 3556 int nsepas; 3557 int i; 3558 3559 sepas = set->sepas; 3560 nsepas = set->nsepas; 3561 3562 /* set all separating parameters to default values */ 3563 SCIP_CALL( paramsetSetSeparatingDefault(paramset, set, messagehdlr, quiet) ); 3564 3565 /* set separating parameters of all separators */ 3566 for( i = 0; i < nsepas; ++i ) 3567 { 3568 const char* sepaname; 3569 sepaname = SCIPsepaGetName(sepas[i]); 3570 3571 /* intobj and cgmip separators should stay disabled */ 3572 if( strcmp(sepaname, "intobj") == 0 || strcmp(sepaname, "cgmip") == 0 ) 3573 continue; 3574 3575 /* get frequency parameter of separator */ 3576 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "separating/%s/freq", sepaname); 3577 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)paramname); 3578 3579 if( param != NULL ) 3580 { 3581 int deffreq; 3582 int newfreq; 3583 3584 assert(SCIPparamGetType(param) == SCIP_PARAMTYPE_INT); 3585 deffreq = SCIPparamGetIntDefault(param); 3586 3587 /* for enabled separators, change frequency to at least every 20th depths and 3588 * enable disabled separators 3589 */ 3590 if( deffreq == -1 ) 3591 newfreq = 0; 3592 else if( deffreq == 0 ) 3593 newfreq = 20; 3594 else 3595 newfreq = MIN(deffreq, 20); 3596 3597 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, paramname, newfreq, quiet) ); 3598 } 3599 3600 /* get maximum number of rounds in root node */ 3601 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "separating/%s/maxroundsroot", sepaname); 3602 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)paramname); 3603 3604 if( param != NULL ) 3605 { 3606 int defrounds; 3607 3608 assert(SCIPparamGetType(param) == SCIP_PARAMTYPE_INT); 3609 defrounds = SCIPparamGetIntDefault(param); 3610 3611 /* increase the maximum number of rounds in the root node by factor of 1.5 */ 3612 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, paramname, (int) (1.5 * defrounds), quiet) ); 3613 } 3614 3615 /* get maximum number of cuts per separation in root node */ 3616 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "separating/%s/maxsepacutsroot", sepaname); 3617 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)paramname); 3618 3619 if( param != NULL ) 3620 { 3621 int defnumber; 3622 3623 assert(SCIPparamGetType(param) == SCIP_PARAMTYPE_INT); 3624 defnumber = SCIPparamGetIntDefault(param); 3625 3626 /* increase the maximum number of cut per separation rounds in the root node by factor of 2 */ 3627 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, paramname, 2*defnumber, quiet) ); 3628 } 3629 } 3630 3631 conshdlrs = set->conshdlrs; 3632 nconshdlrs = set->nconshdlrs; 3633 3634 /* set separating parameters of all constraint handlers */ 3635 for( i = 0; i < nconshdlrs; ++i ) 3636 { 3637 const char* conshdlrname; 3638 conshdlrname = SCIPconshdlrGetName(conshdlrs[i]); 3639 3640 /* get separating frequency parameter of constraint handler */ 3641 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/sepafreq", conshdlrname); 3642 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)paramname); 3643 3644 if( param != NULL ) 3645 { 3646 int deffreq; 3647 int newfreq; 3648 3649 assert(SCIPparamGetType(param) == SCIP_PARAMTYPE_INT); 3650 deffreq = SCIPparamGetIntDefault(param); 3651 3652 /* for constraint handlers with enabled separation, change frequency to at least every 10th depths and 3653 * enable disabled separation routines 3654 */ 3655 if( deffreq == -1 ) 3656 newfreq = 0; 3657 else if( deffreq == 0 ) 3658 newfreq = 10; 3659 else 3660 newfreq = MIN(deffreq, 10); 3661 3662 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, paramname, newfreq, quiet) ); 3663 } 3664 3665 /* get maximal separated cuts in root node of constraint handler */ 3666 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/maxsepacutsroot", conshdlrname); 3667 param = (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)paramname); 3668 3669 if( param != NULL ) 3670 { 3671 int defnumber; 3672 3673 assert(SCIPparamGetType(param) == SCIP_PARAMTYPE_INT); 3674 defnumber = SCIPparamGetIntDefault(param); 3675 3676 /* change maximal cuts in root node to at least 500 */ 3677 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, paramname, MAX(defnumber, 500), quiet) ); 3678 } 3679 } 3680 3681 /* explicitly change general separating parameters */ 3682 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "cutselection/hybrid/minorthoroot", 0.1, quiet) ); 3683 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/maxroundsrootsubrun", 5, quiet) ); 3684 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/maxaddrounds", 5, quiet) ); 3685 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/maxcutsroot", 5000, quiet) ); 3686 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/poolfreq", 10, quiet) ); 3687 3688 /* explicitly change a separating parameter of the linear constraint handler, if included */ 3689 #ifndef NDEBUG 3690 if( SCIPsetFindConshdlr(set, "linear") != NULL ) 3691 #endif 3692 { 3693 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "constraints/linear/separateall", TRUE, quiet) ); 3694 } 3695 3696 /* explicitly change a separating parameter of cmir separator, if included */ 3697 #ifndef NDEBUG 3698 if( SCIPsetFindSepa(set, "aggregation") != NULL ) 3699 #endif 3700 { 3701 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/aggregation/maxfailsroot", 200, quiet) ); 3702 } 3703 3704 /* explicitly change separating parameters of mcf separator, if included */ 3705 #ifndef NDEBUG 3706 if( SCIPsetFindSepa(set, "mcf") != NULL ) 3707 #endif 3708 { 3709 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/mcf/maxtestdelta", -1, quiet) ); 3710 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "separating/mcf/trynegscaling", TRUE, quiet) ); 3711 } 3712 3713 return SCIP_OKAY; 3714 } 3715 3716 /** sets separating to fast */ 3717 static 3718 SCIP_RETCODE paramsetSetSeparatingFast( 3719 SCIP_PARAMSET* paramset, /**< parameter set */ 3720 SCIP_SET* set, /**< global SCIP settings */ 3721 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 3722 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 3723 ) 3724 { 3725 /* reset previous changes on separating parameters */ 3726 SCIP_CALL( paramsetSetSeparatingDefault(paramset, set, messagehdlr, quiet) ); 3727 3728 /* explicitly decrease maxbounddist */ 3729 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "separating/maxbounddist", 0.0, quiet) ); 3730 3731 /* explicitly turn off expensive separators, if included */ 3732 #ifndef NDEBUG 3733 if( SCIPsetFindConshdlr(set, "and") != NULL ) 3734 #endif 3735 { 3736 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "constraints/and/sepafreq", 0, quiet) ); 3737 } 3738 #ifndef NDEBUG 3739 if( SCIPsetFindSepa(set, "aggregation") != NULL ) 3740 #endif 3741 { 3742 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/aggregation/maxroundsroot", 5, quiet) ); 3743 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/aggregation/maxtriesroot", 100, quiet) ); 3744 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/aggregation/maxaggrsroot", 3, quiet) ); 3745 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/aggregation/maxsepacutsroot", 200, quiet) ); 3746 } 3747 #ifndef NDEBUG 3748 if( SCIPsetFindSepa(set, "zerohalf") != NULL ) 3749 #endif 3750 { 3751 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "separating/zerohalf/maxslackroot", 0.0, quiet) ); 3752 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "separating/zerohalf/maxslack", 0.0, quiet) ); 3753 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/zerohalf/maxsepacutsroot", 200, quiet) ); 3754 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/zerohalf/maxroundsroot", 5, quiet) ); 3755 } 3756 #ifndef NDEBUG 3757 if( SCIPsetFindSepa(set, "gomory") != NULL ) 3758 #endif 3759 { 3760 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/gomory/maxroundsroot", 20, quiet) ); 3761 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/gomory/maxsepacutsroot", 200, quiet) ); 3762 } 3763 #ifndef NDEBUG 3764 if( SCIPsetFindSepa(set, "mcf") != NULL ) 3765 #endif 3766 { 3767 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/mcf/freq", -1, quiet) ); 3768 } 3769 3770 return SCIP_OKAY; 3771 } 3772 3773 /** turns all cuts off */ 3774 static 3775 SCIP_RETCODE paramsetSetSeparatingOff( 3776 SCIP_PARAMSET* paramset, /**< parameter set */ 3777 SCIP_SET* set, /**< global SCIP settings */ 3778 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 3779 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 3780 ) 3781 { 3782 SCIP_SEPA** sepas; 3783 SCIP_CONSHDLR** conshdlrs; 3784 char paramname[SCIP_MAXSTRLEN]; 3785 int nsepas; 3786 int nconshdlrs; 3787 int i; 3788 3789 /* reset previous changes on separating parameters */ 3790 SCIP_CALL( paramsetSetSeparatingDefault(paramset, set, messagehdlr, quiet) ); 3791 3792 sepas = set->sepas; 3793 nsepas = set->nsepas; 3794 3795 /* turn each individual separator off */ 3796 for( i = 0; i < nsepas; ++i ) 3797 { 3798 const char* sepaname; 3799 sepaname = SCIPsepaGetName(sepas[i]); 3800 3801 /* get frequency parameter of separator */ 3802 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "separating/%s/freq", sepaname); 3803 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, paramname, -1, quiet) ); 3804 } 3805 3806 conshdlrs = set->conshdlrs; 3807 nconshdlrs = set->nconshdlrs; 3808 3809 /* turn off separation for each individual constraint handler */ 3810 for( i = 0; i < nconshdlrs; ++i ) 3811 { 3812 const char* conshdlrname; 3813 conshdlrname = SCIPconshdlrGetName(conshdlrs[i]); 3814 3815 /* get separation frequency parameter of constraint handler */ 3816 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "constraints/%s/sepafreq", conshdlrname); 3817 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, paramname, -1, quiet) ); 3818 } 3819 3820 return SCIP_OKAY; 3821 } 3822 3823 /** sets parameters to 3824 * 3825 * - \ref SCIP_PARAMEMPHASIS_DEFAULT to use default values (see also SCIPparamsetSetToDefault()) 3826 * - \ref SCIP_PARAMEMPHASIS_COUNTER to get feasible and "fast" counting process 3827 * - \ref SCIP_PARAMEMPHASIS_CPSOLVER to get CP like search (e.g. no LP relaxation) 3828 * - \ref SCIP_PARAMEMPHASIS_EASYCIP to solve easy problems fast 3829 * - \ref SCIP_PARAMEMPHASIS_FEASIBILITY to detect feasibility fast 3830 * - \ref SCIP_PARAMEMPHASIS_HARDLP to be capable to handle hard LPs 3831 * - \ref SCIP_PARAMEMPHASIS_OPTIMALITY to prove optimality fast 3832 * - \ref SCIP_PARAMEMPHASIS_PHASEFEAS to find feasible solutions during a 3 phase solution process 3833 * - \ref SCIP_PARAMEMPHASIS_PHASEIMPROVE to find improved solutions during a 3 phase solution process 3834 * - \ref SCIP_PARAMEMPHASIS_PHASEPROOF to proof optimality during a 3 phase solution process 3835 * - \ref SCIP_PARAMEMPHASIS_NUMERICS to solve problems which cause numerical issues 3836 * - \ref SCIP_PARAMEMPHASIS_BENCHMARK to not try to avoid running into memory limit 3837 */ 3838 SCIP_RETCODE SCIPparamsetSetEmphasis( 3839 SCIP_PARAMSET* paramset, /**< parameter set */ 3840 SCIP_SET* set, /**< global SCIP settings */ 3841 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 3842 SCIP_PARAMEMPHASIS paramemphasis, /**< parameter emphasis */ 3843 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 3844 ) 3845 { 3846 switch( paramemphasis ) 3847 { 3848 case SCIP_PARAMEMPHASIS_DEFAULT: 3849 /* reset all parameter to default */ 3850 SCIP_CALL( SCIPparamsetSetToDefaults(paramset, set, messagehdlr) ); 3851 break; 3852 3853 case SCIP_PARAMEMPHASIS_COUNTER: 3854 /* TODO: should constraints/linear/detectlowerbound and detectcutoffbound be set to FALSE? */ 3855 /* avoid logicor upgrade since the logicor constraint handler does not perform full propagation */ 3856 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "constraints/linear/upgrade/logicor", FALSE, quiet) ); 3857 3858 /* set priority for inference branching to highest possible value */ 3859 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "branching/inference/priority", INT_MAX/4, quiet) ); 3860 3861 /* set priority for depth first search to highest possible value */ 3862 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "nodeselection/dfs/stdpriority", INT_MAX/4, quiet) ); 3863 3864 /* avoid that the ZIMPL reader transforms the problem before the problem is generated */ 3865 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "reading/zplreader/usestartsol", FALSE, quiet) ); 3866 3867 /* turn off all heuristics */ 3868 SCIP_CALL( paramsetSetHeuristicsOff(paramset, set, messagehdlr, quiet) ); 3869 3870 /* turn off all separation */ 3871 SCIP_CALL( paramsetSetSeparatingOff(paramset, set, messagehdlr, quiet) ); 3872 3873 /* turn off restart */ 3874 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "presolving/maxrestarts", 0, quiet) ); 3875 3876 /* unlimited number of propagation rounds in any branch and bound node */ 3877 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "propagating/maxrounds", -1, quiet) ); 3878 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "propagating/maxroundsroot", -1, quiet) ); 3879 3880 /* adjust conflict analysis for depth first search */ 3881 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "conflict/fuiplevels", 1, quiet) ); 3882 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "conflict/dynamic", FALSE, quiet) ); 3883 3884 /* prefer binary variables for branching */ 3885 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "branching/preferbinary", TRUE, quiet) ); 3886 3887 /* turn on aggressive constraint aging */ 3888 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "constraints/agelimit", 1, quiet) ); 3889 3890 /* turn off components presolver since we are currently not able to handle that in case of counting */ 3891 #ifndef NDEBUG 3892 if( SCIPsetFindConshdlr(set, "components") != NULL ) 3893 #endif 3894 { 3895 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "constraints/components/maxprerounds", 0, quiet) ); 3896 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "constraints/components/propfreq", -1, quiet) ); 3897 } 3898 break; 3899 3900 case SCIP_PARAMEMPHASIS_CPSOLVER: 3901 /* shrink the minimal maximum value for the conflict length */ 3902 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "conflict/minmaxvars", 10, quiet) ); 3903 3904 /* use only first unique implication point */ 3905 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "conflict/fuiplevels", 1, quiet) ); 3906 3907 /* do not use reconversion conflicts */ 3908 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "conflict/reconvlevels", 0, quiet) ); 3909 3910 /* after 250 conflict we force a restart since then the variable statistics are reasonable initialized */ 3911 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "conflict/restartnum", 250, quiet) ); 3912 3913 /* increase the number of conflicts which induce a restart */ 3914 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "conflict/restartfac", 2.0, quiet) ); 3915 3916 /* weight the variable which made into a conflict */ 3917 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "conflict/conflictweight", 1.0, quiet) ); 3918 3919 /* do not check pseudo solution (for performance reasons) */ 3920 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "constraints/disableenfops", TRUE, quiet) ); 3921 3922 /* use value based history to detect a reasonable branching point */ 3923 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "history/valuebased", TRUE, quiet) ); 3924 3925 /* turn of LP relaxation */ 3926 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "lp/solvefreq", -1, quiet) ); 3927 3928 /* prefer the down branch in case the value based history does not suggest something */ 3929 SCIP_CALL( paramSetChar(paramset, set, messagehdlr, "nodeselection/childsel", 'd', quiet) ); 3930 3931 /* accept any bound change */ 3932 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "numerics/boundstreps", 1e-6, quiet) ); 3933 3934 /* allow for at most 10 restart, after that the value based history should be reliable */ 3935 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "presolving/maxrestarts", 10, quiet) ); 3936 3937 /* set priority for depth first search to highest possible value */ 3938 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "nodeselection/dfs/stdpriority", INT_MAX/4, quiet) ); 3939 3940 break; 3941 3942 case SCIP_PARAMEMPHASIS_EASYCIP: 3943 /* set heuristics to fast, to avoid spending to much time for involved heuristics */ 3944 SCIP_CALL( paramsetSetHeuristicsFast(paramset, set, messagehdlr, quiet) ); 3945 3946 /* set presolving to fast, to avoid spending to much time for involved presolving */ 3947 SCIP_CALL( paramsetSetPresolvingFast(paramset, set, messagehdlr, quiet) ); 3948 3949 /* set separating to fast, to avoid spending to much time for involved separators */ 3950 SCIP_CALL( paramsetSetSeparatingFast(paramset, set, messagehdlr, quiet) ); 3951 3952 break; 3953 3954 case SCIP_PARAMEMPHASIS_FEASIBILITY: 3955 /* set heuristics aggressive */ 3956 SCIP_CALL( paramsetSetHeuristicsAggressive(paramset, set, messagehdlr, quiet) ); 3957 3958 /* reduce the amount of separation rounds and disable most expensive separators */ 3959 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/maxrounds", 1, quiet) ); 3960 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/maxroundsroot", 5, quiet) ); 3961 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/aggregation/freq", -1, quiet) ); 3962 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/mcf/freq", -1, quiet) ); 3963 3964 /* set priority for node selection "restartdfs" to be higher as the current used one */ 3965 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "nodeselection/restartdfs/stdpriority", INT_MAX/4, quiet) ); 3966 break; 3967 3968 case SCIP_PARAMEMPHASIS_HARDLP: 3969 /* set heuristics to fast, to avoid heuristics which solve also an LP */ 3970 SCIP_CALL( paramsetSetHeuristicsFast(paramset, set, messagehdlr, quiet) ); 3971 3972 /* set presolving to fast, to avoid spending to much time for involved presolving */ 3973 SCIP_CALL( paramsetSetPresolvingFast(paramset, set, messagehdlr, quiet) ); 3974 3975 /* reduce the amount of strong branching */ 3976 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "branching/relpscost/maxreliable", 1.0, quiet) ); 3977 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "branching/relpscost/inititer", 10, quiet) ); 3978 3979 /* reduce the amount of separation rounds */ 3980 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/maxrounds", 1, quiet) ); 3981 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "separating/maxroundsroot", 5, quiet) ); 3982 3983 break; 3984 3985 case SCIP_PARAMEMPHASIS_OPTIMALITY: 3986 /* set cuts aggressive */ 3987 SCIP_CALL( paramsetSetSeparatingAggressive(paramset, set, messagehdlr, quiet) ); 3988 3989 /* increase the amount of strong branching */ 3990 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "branching/fullstrong/maxdepth", 10, quiet) ); 3991 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "branching/fullstrong/priority", INT_MAX / 4, quiet) ); 3992 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "branching/fullstrong/maxbounddist", 0.0, quiet) ); 3993 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "branching/relpscost/sbiterquot", 1.0, quiet) ); 3994 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "branching/relpscost/sbiterofs", 1000000, quiet) ); 3995 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "branching/relpscost/maxreliable", 10.0, quiet) ); 3996 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "branching/relpscost/usehyptestforreliability",TRUE, quiet) ); 3997 break; 3998 case SCIP_PARAMEMPHASIS_PHASEFEAS: 3999 4000 /* enable two phase node selection: UCT will run first, but deactivate itself after a small number of nodes */ 4001 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "nodeselection/uct/stdpriority", (INT_MAX / 4) + 1, quiet) ); 4002 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "nodeselection/restartdfs/stdpriority", INT_MAX/4, quiet) ); 4003 4004 /* enable inference branching */ 4005 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "branching/inference/priority", INT_MAX / 4, quiet) ); 4006 break; 4007 4008 case SCIP_PARAMEMPHASIS_PHASEIMPROVE: 4009 /* use UCT node selection in all subSCIP heuristics that have this parameter */ 4010 { 4011 int h; 4012 SCIP_HEUR** heurs = set->heurs; 4013 int nheurs = set->nheurs; 4014 4015 for( h = 0; h < nheurs; ++h ) 4016 { 4017 char paramname[SCIP_MAXSTRLEN]; 4018 if( SCIPheurUsesSubscip(heurs[h]) ) 4019 { 4020 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "heuristics/%s/useuct", SCIPheurGetName(heurs[h])); 4021 4022 if( (SCIP_PARAM*)SCIPhashtableRetrieve(paramset->hashtable, (void*)paramname) != NULL ) 4023 { 4024 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, paramname, TRUE, quiet) ); 4025 } 4026 } 4027 } 4028 4029 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "heuristics/useuctsubscip", TRUE, quiet) ); 4030 } 4031 break; 4032 case SCIP_PARAMEMPHASIS_PHASEPROOF: 4033 /* deactivate primal heuristics */ 4034 SCIP_CALL( paramsetSetHeuristicsOff(paramset, set, messagehdlr, quiet) ); 4035 4036 /* make aggressive use of separators, also locally */ 4037 SCIP_CALL( paramsetSetSeparatingAggressive(paramset, set, messagehdlr, quiet) ); 4038 4039 /* use depth-first node selection strategy that makes best use of LP warmstarts */ 4040 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "nodeselection/dfs/stdpriority", INT_MAX/4, quiet) ); 4041 4042 /* enable dynamic weights for reliability pseudo cost branching */ 4043 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "branching/relpscost/dynamicweights", TRUE, quiet) ); 4044 break; 4045 4046 case SCIP_PARAMEMPHASIS_NUMERICS: 4047 4048 /* huge val is used as a threshold in multiaggregation; decreasing it leads to safer multiaggregations */ 4049 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "numerics/hugeval", 1e+10, quiet) ); 4050 4051 /* The higher the Markowitz Parameter is, more sparse pivots will be ignored and the numerically 4052 more stable ones will be used as pivot */ 4053 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "lp/minmarkowitz", 0.999, quiet) ); 4054 4055 /* Added parameters as suggested here: https://git.zib.de/integer/scip/issues/2002#note_92716 */ 4056 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "lp/fastmip", 0, quiet) ); 4057 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "lp/scaling", 2, quiet) ); 4058 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "lp/presolving", FALSE, quiet) ); 4059 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "lp/refactorinterval", 40, quiet) ); 4060 4061 /* To prevent numerically bad multiaggregations in dualPresolve() and convertLongEquality() set maxmultiaggrqout small*/ 4062 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "constraints/linear/maxmultaggrquot", 10.0, quiet) ); 4063 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "constraints/linear/maxdualmultaggrquot", 10.0, quiet) ); 4064 4065 /* When upgrading constr with knapsack/setppc causes problems */ 4066 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "constraints/linear/upgrade/knapsack", FALSE, quiet) ); 4067 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "constraints/linear/upgrade/setppc", FALSE, quiet) ); 4068 4069 /* For numerical stability turn rangedrowpropagation, simplifyInequalities and extractCliques off */ 4070 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "constraints/linear/rangedrowpropagation", FALSE, quiet) ); 4071 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "constraints/linear/extractcliques", FALSE, quiet) ); 4072 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "constraints/linear/simplifyinequalities", FALSE, quiet) ); 4073 4074 /* Reduce the max coefratio to prevent the creation of potentially numerical unstable cuts */ 4075 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "separating/maxcoefratio", 100.0, quiet) ); 4076 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "separating/maxcoefratiofacrowprep", 1.0, quiet) ); 4077 4078 #ifdef SCIP_WITH_PAPILO 4079 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "presolving/milp/hugebound", 1e6, quiet) ); 4080 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "presolving/milp/markowitztolerance", 0.1, quiet) ); 4081 #endif 4082 4083 /* weaken domain propagation of nonlinear constraints by increasing relaxation of variable bounds and constraint sides */ 4084 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "constraints/nonlinear/conssiderelaxamount", 1e-7, quiet) ); 4085 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "constraints/nonlinear/varboundrelaxamount", 1e-7, quiet) ); 4086 4087 break; 4088 4089 case SCIP_PARAMEMPHASIS_BENCHMARK: 4090 4091 /* turn off memory saving mode and do not try to avoid memory limit */ 4092 SCIP_CALL( paramSetReal(paramset, set, messagehdlr, "memory/savefac", 1.0, quiet) ); 4093 SCIP_CALL( paramSetBool(paramset, set, messagehdlr, "misc/avoidmemout", FALSE, quiet) ); 4094 break; 4095 4096 default: 4097 SCIPerrorMessage("the parameter setting <%d> is not allowed for emphasis call\n", paramemphasis); 4098 return SCIP_INVALIDCALL; 4099 } 4100 return SCIP_OKAY; 4101 } 4102 4103 /** sets parameters to deactivate separators and heuristics that use auxiliary SCIP instances; should be called for 4104 * auxiliary SCIP instances to avoid recursion 4105 */ 4106 SCIP_RETCODE SCIPparamsetSetToSubscipsOff( 4107 SCIP_PARAMSET* paramset, /**< parameter set */ 4108 SCIP_SET* set, /**< global SCIP settings */ 4109 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 4110 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 4111 ) 4112 { 4113 SCIP_HEUR** heurs; 4114 SCIP_SEPA** sepas; 4115 4116 char paramname[SCIP_MAXSTRLEN]; 4117 4118 int nheurs; 4119 int nsepas; 4120 int i; 4121 4122 heurs = set->heurs; 4123 nheurs = set->nheurs; 4124 4125 /* disable all heuristics that use auxiliary SCIP instances */ 4126 for( i = 0; i < nheurs; ++i ) 4127 { 4128 if( SCIPheurUsesSubscip(heurs[i]) ) 4129 { 4130 const char* heurname; 4131 heurname = SCIPheurGetName(heurs[i]); 4132 4133 /* get frequency parameter of heuristic */ 4134 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "heuristics/%s/freq", heurname); 4135 4136 /* we have to unfix the parameter if it fixed and not already set to -1 */ 4137 if( SCIPparamsetIsFixed(paramset, paramname) ) 4138 { 4139 int oldfreq; 4140 4141 SCIP_CALL( SCIPparamsetGetInt(paramset, paramname, &oldfreq) ); 4142 4143 /* if the frequency is already set to -1, we do not have to unfix it, but must not try to set it, either */ 4144 if( oldfreq == -1 ) 4145 continue; 4146 4147 /* unfix parameter */ 4148 SCIPmessageFPrintInfo(messagehdlr, NULL, "unfixing parameter %s in order to disable sub-SCIPs in the current (sub-)SCIP instance\n", paramname); 4149 SCIP_CALL( SCIPparamsetFix(paramset, paramname, FALSE) ); 4150 } 4151 4152 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, paramname, -1, quiet) ); 4153 } 4154 } 4155 4156 sepas = set->sepas; 4157 nsepas = set->nsepas; 4158 4159 /* disable all separators that use auxiliary SCIP instances */ 4160 for( i = 0; i < nsepas; ++i ) 4161 { 4162 if( SCIPsepaUsesSubscip(sepas[i]) ) 4163 { 4164 const char* sepaname; 4165 sepaname = SCIPsepaGetName(sepas[i]); 4166 4167 /* get frequency parameter of separator */ 4168 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "separating/%s/freq", sepaname); 4169 4170 /* we have to unfix the parameter if it fixed and not already set to -1 */ 4171 if( SCIPparamsetIsFixed(paramset, paramname) ) 4172 { 4173 int oldfreq; 4174 4175 SCIP_CALL( SCIPparamsetGetInt(paramset, paramname, &oldfreq) ); 4176 4177 /* if the frequency is already set to -1, we do not have to unfix it, but must not try to set it, either */ 4178 if( oldfreq == -1 ) 4179 continue; 4180 4181 /* unfix parameter */ 4182 SCIPmessageFPrintInfo(messagehdlr, NULL, "unfixing parameter %s in order to disable sub-SCIPs in the current (sub-)SCIP instance\n", paramname); 4183 SCIP_CALL( SCIPparamsetFix(paramset, paramname, FALSE) ); 4184 } 4185 4186 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, paramname, -1, quiet) ); 4187 } 4188 } 4189 4190 /* turn off components constraint handler */ 4191 #ifndef NDEBUG 4192 if( SCIPsetFindConshdlr(set, "components") != NULL ) 4193 #endif 4194 { 4195 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "constraints/components/maxprerounds", 0, quiet) ); 4196 SCIP_CALL( paramSetInt(paramset, set, messagehdlr, "constraints/components/propfreq", -1, quiet) ); 4197 } 4198 4199 /* marking that the sub-SCIPs have been deactivated */ 4200 set->subscipsoff = TRUE; 4201 4202 return SCIP_OKAY; 4203 } 4204 4205 /** sets heuristic parameters values to 4206 * - SCIP_PARAMSETTING_DEFAULT which are the default values of all heuristic parameters 4207 * - SCIP_PARAMSETTING_FAST such that the time spent on heuristics is decreased 4208 * - SCIP_PARAMSETTING_AGGRESSIVE such that the heuristics are called more aggressively 4209 * - SCIP_PARAMSETTING_OFF which turn off all heuristics 4210 */ 4211 SCIP_RETCODE SCIPparamsetSetHeuristics( 4212 SCIP_PARAMSET* paramset, /**< parameter set */ 4213 SCIP_SET* set, /**< global SCIP settings */ 4214 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 4215 SCIP_PARAMSETTING paramsetting, /**< parameter settings */ 4216 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 4217 ) 4218 { 4219 switch( paramsetting ) 4220 { 4221 case SCIP_PARAMSETTING_DEFAULT: 4222 SCIP_CALL( paramsetSetHeuristicsDefault(paramset, set, messagehdlr, quiet) ); 4223 break; 4224 case SCIP_PARAMSETTING_OFF: 4225 SCIP_CALL( paramsetSetHeuristicsOff(paramset, set, messagehdlr, quiet) ); 4226 break; 4227 case SCIP_PARAMSETTING_FAST: 4228 SCIP_CALL( paramsetSetHeuristicsFast(paramset, set, messagehdlr, quiet) ); 4229 break; 4230 case SCIP_PARAMSETTING_AGGRESSIVE: 4231 SCIP_CALL( paramsetSetHeuristicsAggressive(paramset, set, messagehdlr, quiet) ); 4232 break; 4233 default: 4234 SCIPerrorMessage("the parameter setting <%d> is not allowed for heuristics\n", paramsetting); 4235 return SCIP_INVALIDCALL; 4236 } 4237 4238 return SCIP_OKAY; 4239 } 4240 4241 /** sets presolving parameters to 4242 * - SCIP_PARAMSETTING_DEFAULT which are the default values of all presolving parameters 4243 * - SCIP_PARAMSETTING_FAST such that the time spent on presolving is decreased 4244 * - SCIP_PARAMSETTING_AGGRESSIVE such that the presolving is more aggressive 4245 * - SCIP_PARAMSETTING_OFF which turn off all presolving 4246 */ 4247 SCIP_RETCODE SCIPparamsetSetPresolving( 4248 SCIP_PARAMSET* paramset, /**< parameter set */ 4249 SCIP_SET* set, /**< global SCIP settings */ 4250 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 4251 SCIP_PARAMSETTING paramsetting, /**< parameter settings */ 4252 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 4253 ) 4254 { 4255 switch( paramsetting ) 4256 { 4257 case SCIP_PARAMSETTING_DEFAULT: 4258 SCIP_CALL( paramsetSetPresolvingDefault(paramset, set, messagehdlr, quiet) ); 4259 break; 4260 case SCIP_PARAMSETTING_OFF: 4261 SCIP_CALL( paramsetSetPresolvingOff(paramset, set, messagehdlr, quiet) ); 4262 break; 4263 case SCIP_PARAMSETTING_FAST: 4264 SCIP_CALL( paramsetSetPresolvingFast(paramset, set, messagehdlr, quiet) ); 4265 break; 4266 case SCIP_PARAMSETTING_AGGRESSIVE: 4267 SCIP_CALL( paramsetSetPresolvingAggressive(paramset, set, messagehdlr, quiet) ); 4268 break; 4269 default: 4270 SCIPerrorMessage("the parameter setting <%d> is not allowed for presolving\n", paramsetting); 4271 return SCIP_INVALIDCALL; 4272 } 4273 4274 return SCIP_OKAY; 4275 } 4276 4277 /** sets separating parameters to 4278 * - SCIP_PARAMSETTING_DEFAULT which are the default values of all separating parameters 4279 * - SCIP_PARAMSETTING_FAST such that the time spent on separating is decreased 4280 * - SCIP_PARAMSETTING_AGGRESSIVE such that separating is more aggressive 4281 * - SCIP_PARAMSETTING_OFF which turn off all separating 4282 */ 4283 SCIP_RETCODE SCIPparamsetSetSeparating( 4284 SCIP_PARAMSET* paramset, /**< parameter set */ 4285 SCIP_SET* set, /**< global SCIP settings */ 4286 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 4287 SCIP_PARAMSETTING paramsetting, /**< parameter settings */ 4288 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 4289 ) 4290 { 4291 switch( paramsetting ) 4292 { 4293 case SCIP_PARAMSETTING_DEFAULT: 4294 SCIP_CALL( paramsetSetSeparatingDefault(paramset, set, messagehdlr, quiet) ); 4295 break; 4296 case SCIP_PARAMSETTING_OFF: 4297 SCIP_CALL( paramsetSetSeparatingOff(paramset, set, messagehdlr, quiet) ); 4298 break; 4299 case SCIP_PARAMSETTING_FAST: 4300 SCIP_CALL( paramsetSetSeparatingFast(paramset, set, messagehdlr, quiet) ); 4301 break; 4302 case SCIP_PARAMSETTING_AGGRESSIVE: 4303 SCIP_CALL( paramsetSetSeparatingAggressive(paramset, set, messagehdlr, quiet) ); 4304 break; 4305 default: 4306 SCIPerrorMessage("the parameter setting <%d> is not allowed for separating\n", paramsetting); 4307 return SCIP_INVALIDCALL; 4308 } 4309 4310 return SCIP_OKAY; 4311 } 4312 4313 /** returns the array of parameters */ 4314 SCIP_PARAM** SCIPparamsetGetParams( 4315 SCIP_PARAMSET* paramset /**< parameter set */ 4316 ) 4317 { 4318 assert(paramset != NULL); 4319 4320 return paramset->params; 4321 } 4322 4323 /** returns the number of parameters in the parameter set */ 4324 int SCIPparamsetGetNParams( 4325 SCIP_PARAMSET* paramset /**< parameter set */ 4326 ) 4327 { 4328 assert(paramset != NULL); 4329 4330 return paramset->nparams; 4331 } 4332 4333 /** copies all parameter values of the source parameter set to the corresponding parameters in the target set 4334 * 4335 * by default reoptimization is disabled after copying the parameters. if you want to use reoptimization, you have 4336 * to enable it explicitly. 4337 */ 4338 SCIP_RETCODE SCIPparamsetCopyParams( 4339 SCIP_PARAMSET* sourceparamset, /**< source parameter set */ 4340 SCIP_PARAMSET* targetparamset, /**< target parameter set */ 4341 SCIP_SET* set, /**< global SCIP settings of target SCIP */ 4342 SCIP_MESSAGEHDLR* messagehdlr /**< message handler of target SCIP */ 4343 ) 4344 { 4345 int i; 4346 4347 assert(sourceparamset != NULL); 4348 assert(targetparamset != NULL); 4349 assert(sourceparamset != targetparamset); 4350 assert(set != NULL); 4351 4352 assert(sourceparamset->nparams == 0 || sourceparamset->params != NULL); 4353 assert(targetparamset->nparams == 0 || targetparamset->params != NULL); 4354 4355 for( i = 0; i < sourceparamset->nparams; ++i ) 4356 { 4357 SCIP_PARAM* sourceparam; 4358 SCIP_PARAM* targetparam; 4359 const char* paramname; 4360 4361 sourceparam = sourceparamset->params[i]; 4362 assert(sourceparam != NULL); 4363 4364 /* find parameter of same name in target scip */ 4365 paramname = SCIPparamGetName(sourceparam); 4366 targetparam = (SCIP_PARAM*)SCIPhashtableRetrieve(targetparamset->hashtable, (void*)paramname); 4367 4368 /* if a plugin was not copied, the parameter does not exist in the target SCIP */ 4369 if( targetparam == NULL ) 4370 continue; 4371 4372 assert(SCIPparamGetType(sourceparam) == SCIPparamGetType(targetparam)); 4373 4374 /* set value of target parameter to value of source parameter */ 4375 switch( SCIPparamGetType(sourceparam) ) 4376 { 4377 case SCIP_PARAMTYPE_BOOL: 4378 SCIP_CALL( paramCopyBool(sourceparam, targetparam, set, messagehdlr) ); 4379 break; 4380 4381 case SCIP_PARAMTYPE_INT: 4382 SCIP_CALL( paramCopyInt(sourceparam, targetparam, set, messagehdlr) ); 4383 break; 4384 4385 case SCIP_PARAMTYPE_LONGINT: 4386 SCIP_CALL( paramCopyLongint(sourceparam, targetparam, set, messagehdlr) ); 4387 break; 4388 4389 case SCIP_PARAMTYPE_REAL: 4390 SCIP_CALL( paramCopyReal(sourceparam, targetparam, set, messagehdlr) ); 4391 break; 4392 4393 case SCIP_PARAMTYPE_CHAR: 4394 SCIP_CALL( paramCopyChar(sourceparam, targetparam, set, messagehdlr) ); 4395 break; 4396 4397 case SCIP_PARAMTYPE_STRING: 4398 /* the visualization parameters are explicitly not copied to avoid that the visualization file of the original SCIP is overwritten; 4399 * to avoid a hard coded comparison, each parameter could get a Bool flag which tells if the value 4400 * of that parameter can be copied 4401 */ 4402 if( strncmp(sourceparam->name, "visual/", 7) != 0 ) 4403 { 4404 SCIP_CALL( paramCopyString(sourceparam, targetparam, set, messagehdlr) ); 4405 } 4406 break; 4407 4408 default: 4409 SCIPerrorMessage("unknown parameter type\n"); 4410 return SCIP_INVALIDDATA; 4411 } 4412 4413 /* copy fixing status of parameter */ 4414 SCIPparamSetFixed(targetparam, SCIPparamIsFixed(sourceparam)); 4415 } 4416 4417 /* disable reoptimization explicitly */ 4418 if( set->reopt_enable ) 4419 { 4420 if( SCIPsetIsParamFixed(set, "reoptimization/enable") ) 4421 { 4422 SCIP_CALL( SCIPsetChgParamFixed(set, "reoptimization/enable", FALSE) ); 4423 } 4424 SCIP_CALL( SCIPparamsetSetBool(targetparamset, set, messagehdlr, "reoptimization/enable", FALSE) ); 4425 SCIP_CALL( SCIPsetSetReoptimizationParams(set, messagehdlr) ); 4426 } 4427 4428 return SCIP_OKAY; 4429 } 4430 4431 /** sets fixing status of given parameter */ 4432 void SCIPparamSetFixed( 4433 SCIP_PARAM* param, /**< parameter */ 4434 SCIP_Bool fixed /**< new fixing status of the parameter */ 4435 ) 4436 { 4437 assert(param != NULL); 4438 4439 param->isfixed = fixed; 4440 } 4441 4442 /** checks whether value of bool parameter is valid */ 4443 SCIP_Bool SCIPparamIsValidBool( 4444 SCIP_PARAM* param, /**< parameter */ 4445 SCIP_Bool value /**< value to check */ 4446 ) 4447 { /*lint --e{715}*/ 4448 assert(param != NULL); 4449 return ( value == TRUE || value == FALSE ); 4450 } 4451 4452 /** checks whether value of integer parameter is valid */ 4453 SCIP_Bool SCIPparamIsValidInt( 4454 SCIP_PARAM* param, /**< parameter */ 4455 int value /**< value to check */ 4456 ) 4457 { 4458 assert(param != NULL); 4459 4460 return ( value >= param->data.intparam.minvalue && value <= param->data.intparam.maxvalue ); 4461 } 4462 4463 /** checks whether value of SCIP_Longint parameter is valid */ 4464 SCIP_Bool SCIPparamIsValidLongint( 4465 SCIP_PARAM* param, /**< parameter */ 4466 SCIP_Longint value /**< value to check */ 4467 ) 4468 { 4469 assert( param != NULL ); 4470 4471 return ( value >= param->data.longintparam.minvalue && value <= param->data.longintparam.maxvalue ); 4472 } 4473 4474 /** checks whether value of SCIP_Real parameter is valid */ 4475 SCIP_Bool SCIPparamIsValidReal( 4476 SCIP_PARAM* param, /**< parameter */ 4477 SCIP_Real value /**< value to check */ 4478 ) 4479 { 4480 assert( param != NULL ); 4481 4482 return ( value >= param->data.realparam.minvalue && value <= param->data.realparam.maxvalue ); 4483 } 4484 4485 /** checks whether value of char parameter is valid */ 4486 SCIP_Bool SCIPparamIsValidChar( 4487 SCIP_PARAM* param, /**< parameter */ 4488 const char value /**< value to check */ 4489 ) 4490 { 4491 assert( param != NULL ); 4492 4493 if( value == '\b' || value == '\f' || value == '\n' || value == '\r' || value == '\v' ) 4494 return FALSE; 4495 4496 if( param->data.charparam.allowedvalues != NULL ) 4497 { 4498 char* c; 4499 4500 c = param->data.charparam.allowedvalues; 4501 while( *c != '\0' && *c != value ) 4502 c++; 4503 4504 if( *c != value ) 4505 return FALSE; 4506 } 4507 4508 return TRUE; 4509 } 4510 4511 /** checks whether value of string parameter is valid */ 4512 SCIP_Bool SCIPparamIsValidString( 4513 SCIP_PARAM* param, /**< parameter */ 4514 const char* value /**< value to check */ 4515 ) 4516 { /*lint --e{715}*/ 4517 unsigned int i; 4518 4519 assert(param != NULL); 4520 4521 for( i = 0; i < (unsigned int) strlen(value); ++i ) 4522 { 4523 if( value[i] == '\b' || value[i] == '\f' || value[i] == '\n' || value[i] == '\r' || value[i] == '\v' ) 4524 return FALSE; 4525 } 4526 return TRUE; 4527 } 4528 4529 /** sets value of SCIP_Bool parameter */ 4530 SCIP_RETCODE SCIPparamSetBool( 4531 SCIP_PARAM* param, /**< parameter */ 4532 SCIP_SET* set, /**< global SCIP settings, or NULL if param change method should not be called */ 4533 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 4534 SCIP_Bool value, /**< new value of the parameter */ 4535 SCIP_Bool initialize, /**< is this the initialization of the parameter? */ 4536 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 4537 ) 4538 { 4539 assert(param != NULL); 4540 4541 /* check if value is possible for the parameter */ 4542 SCIP_CALL_QUIET( paramTestBool(param, messagehdlr, value) ); 4543 4544 /* is the value of the parameter changed? */ 4545 if( initialize || (param->data.boolparam.valueptr != NULL && *param->data.boolparam.valueptr != value) 4546 || (param->data.boolparam.valueptr == NULL && param->data.boolparam.curvalue != value) ) 4547 { 4548 SCIP_Bool oldvalue = FALSE; 4549 4550 /* check if the parameter is not fixed */ 4551 SCIP_CALL_QUIET( paramTestFixed(param, messagehdlr) ); 4552 4553 if( !initialize ) 4554 oldvalue = SCIPparamGetBool(param); 4555 4556 /* set the parameter's current value */ 4557 if( param->data.boolparam.valueptr != NULL ) 4558 *param->data.boolparam.valueptr = value; 4559 else 4560 param->data.boolparam.curvalue = value; 4561 4562 /* call the parameter's change information method, unless initializing */ 4563 if( !initialize && param->paramchgd != NULL && set != NULL ) 4564 { 4565 SCIP_RETCODE retcode; 4566 4567 retcode = param->paramchgd(set->scip, param); 4568 4569 if( retcode == SCIP_PARAMETERWRONGVAL ) 4570 { 4571 if( param->data.boolparam.valueptr != NULL ) 4572 *param->data.boolparam.valueptr = oldvalue; 4573 else 4574 param->data.boolparam.curvalue = oldvalue; 4575 } 4576 else 4577 { 4578 SCIP_CALL( retcode ); 4579 } 4580 } 4581 } 4582 4583 if( !quiet ) 4584 { 4585 SCIP_CALL( paramWrite(param, messagehdlr, NULL, FALSE, TRUE) ); 4586 } 4587 4588 return SCIP_OKAY; 4589 } 4590 4591 /** sets value of int parameter */ 4592 SCIP_RETCODE SCIPparamSetInt( 4593 SCIP_PARAM* param, /**< parameter */ 4594 SCIP_SET* set, /**< global SCIP settings, or NULL if param change method should not be called */ 4595 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 4596 int value, /**< new value of the parameter */ 4597 SCIP_Bool initialize, /**< is this the initialization of the parameter? */ 4598 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 4599 ) 4600 { 4601 assert(param != NULL); 4602 4603 /* check if value is possible for the parameter */ 4604 SCIP_CALL_QUIET( paramTestInt(param, messagehdlr, value) ); 4605 4606 /* is the value of the parameter changed? */ 4607 if( initialize || (param->data.intparam.valueptr != NULL && *param->data.intparam.valueptr != value) 4608 || (param->data.intparam.valueptr == NULL && param->data.intparam.curvalue != value) ) 4609 { 4610 int oldvalue = 0; 4611 4612 /* check if the parameter is not fixed */ 4613 SCIP_CALL_QUIET( paramTestFixed(param, messagehdlr) ); 4614 4615 if( !initialize ) 4616 oldvalue = SCIPparamGetInt(param); 4617 4618 /* set the parameter's current value */ 4619 if( param->data.intparam.valueptr != NULL ) 4620 *param->data.intparam.valueptr = value; 4621 else 4622 param->data.intparam.curvalue = value; 4623 4624 /* call the parameter's change information method, unless initialization */ 4625 if( !initialize && param->paramchgd != NULL && set != NULL ) 4626 { 4627 SCIP_RETCODE retcode; 4628 4629 retcode = param->paramchgd(set->scip, param); 4630 4631 if( retcode == SCIP_PARAMETERWRONGVAL ) 4632 { 4633 if( param->data.intparam.valueptr != NULL ) 4634 *param->data.intparam.valueptr = oldvalue; 4635 else 4636 param->data.intparam.curvalue = oldvalue; 4637 } 4638 else 4639 { 4640 SCIP_CALL( retcode ); 4641 } 4642 } 4643 } 4644 4645 if( !quiet ) 4646 { 4647 SCIP_CALL( paramWrite(param, messagehdlr, NULL, FALSE, TRUE) ); 4648 } 4649 4650 return SCIP_OKAY; 4651 } 4652 4653 /** sets value of SCIP_Longint parameter */ 4654 SCIP_RETCODE SCIPparamSetLongint( 4655 SCIP_PARAM* param, /**< parameter */ 4656 SCIP_SET* set, /**< global SCIP settings, or NULL if param change method should not be called */ 4657 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 4658 SCIP_Longint value, /**< new value of the parameter */ 4659 SCIP_Bool initialize, /**< is this the initialization of the parameter? */ 4660 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 4661 ) 4662 { 4663 assert(param != NULL); 4664 4665 /* check if value is possible for the parameter */ 4666 SCIP_CALL_QUIET( paramTestLongint(param, messagehdlr, value) ); 4667 4668 /* is the value of the parameter changed? */ 4669 if( initialize || (param->data.longintparam.valueptr != NULL && *param->data.longintparam.valueptr != value) 4670 || (param->data.longintparam.valueptr == NULL && param->data.longintparam.curvalue != value) ) 4671 { 4672 SCIP_Longint oldvalue = 0L; 4673 4674 /* check if the parameter is not fixed */ 4675 SCIP_CALL_QUIET( paramTestFixed(param, messagehdlr) ); 4676 4677 if( !initialize ) 4678 oldvalue = SCIPparamGetLongint(param); 4679 4680 /* set the parameter's current value */ 4681 if( param->data.longintparam.valueptr != NULL ) 4682 *param->data.longintparam.valueptr = value; 4683 else 4684 param->data.longintparam.curvalue = value; 4685 4686 /* call the parameter's change information method, unless initialization */ 4687 if( !initialize && param->paramchgd != NULL && set != NULL ) 4688 { 4689 SCIP_RETCODE retcode; 4690 4691 retcode = param->paramchgd(set->scip, param); 4692 4693 if( retcode == SCIP_PARAMETERWRONGVAL ) 4694 { 4695 if( param->data.longintparam.valueptr != NULL ) 4696 *param->data.longintparam.valueptr = oldvalue; 4697 else 4698 param->data.longintparam.curvalue = oldvalue; 4699 } 4700 else 4701 { 4702 SCIP_CALL( retcode ); 4703 } 4704 } 4705 } 4706 4707 if( !quiet ) 4708 { 4709 SCIP_CALL( paramWrite(param, messagehdlr, NULL, FALSE, TRUE) ); 4710 } 4711 4712 return SCIP_OKAY; 4713 } 4714 4715 /** sets value of SCIP_Real parameter */ 4716 SCIP_RETCODE SCIPparamSetReal( 4717 SCIP_PARAM* param, /**< parameter */ 4718 SCIP_SET* set, /**< global SCIP settings, or NULL if param change method should not be called */ 4719 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 4720 SCIP_Real value, /**< new value of the parameter */ 4721 SCIP_Bool initialize, /**< is this the initialization of the parameter? */ 4722 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 4723 ) 4724 { 4725 assert(param != NULL); 4726 4727 /* check if value is possible for the parameter */ 4728 value = MAX(value, SCIP_REAL_MIN); 4729 value = MIN(value, SCIP_REAL_MAX); 4730 SCIP_CALL_QUIET( paramTestReal(param, messagehdlr, value) ); 4731 4732 /* is the value of the parameter changed? */ 4733 if( initialize || (param->data.realparam.valueptr != NULL && *param->data.realparam.valueptr != value) /*lint !e777*/ 4734 || (param->data.realparam.valueptr == NULL && param->data.realparam.curvalue != value) ) /*lint !e777*/ 4735 { 4736 SCIP_Real oldvalue = 0.0; 4737 4738 /* check if the parameter is not fixed */ 4739 SCIP_CALL_QUIET( paramTestFixed(param, messagehdlr) ); 4740 4741 if( !initialize ) 4742 oldvalue = SCIPparamGetReal(param); 4743 4744 /* set the parameter's current value */ 4745 if( param->data.realparam.valueptr != NULL ) 4746 *param->data.realparam.valueptr = value; 4747 else 4748 param->data.realparam.curvalue = value; 4749 4750 /* call the parameter's change information method, unless initializing */ 4751 if( !initialize && param->paramchgd != NULL && set != NULL ) 4752 { 4753 SCIP_RETCODE retcode; 4754 4755 retcode = param->paramchgd(set->scip, param); 4756 4757 if( retcode == SCIP_PARAMETERWRONGVAL ) 4758 { 4759 if( param->data.realparam.valueptr != NULL ) 4760 *param->data.realparam.valueptr = oldvalue; 4761 else 4762 param->data.realparam.curvalue = oldvalue; 4763 } 4764 else 4765 { 4766 SCIP_CALL( retcode ); 4767 } 4768 } 4769 } 4770 4771 if( !quiet ) 4772 { 4773 SCIP_CALL( paramWrite(param, messagehdlr, NULL, FALSE, TRUE) ); 4774 } 4775 4776 return SCIP_OKAY; 4777 } 4778 4779 /** sets value of char parameter */ 4780 SCIP_RETCODE SCIPparamSetChar( 4781 SCIP_PARAM* param, /**< parameter */ 4782 SCIP_SET* set, /**< global SCIP settings, or NULL if param change method should not be called */ 4783 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 4784 char value, /**< new value of the parameter */ 4785 SCIP_Bool initialize, /**< is this the initialization of the parameter? */ 4786 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 4787 ) 4788 { 4789 assert(param != NULL); 4790 4791 /* check, if value is possible for the parameter and the parameter is not fixed */ 4792 SCIP_CALL_QUIET( paramTestChar(param, messagehdlr, value) ); 4793 4794 /* is the value of the parameter changed? */ 4795 if( initialize || (param->data.charparam.valueptr != NULL && *param->data.charparam.valueptr != value) 4796 || (param->data.charparam.valueptr == NULL && param->data.charparam.curvalue != value) ) 4797 { 4798 char oldvalue = '\0'; 4799 4800 SCIP_CALL_QUIET( paramTestFixed(param, messagehdlr) ); 4801 4802 if( !initialize ) 4803 oldvalue = SCIPparamGetChar(param); 4804 4805 /* set the parameter's current value */ 4806 if( param->data.charparam.valueptr != NULL ) 4807 *param->data.charparam.valueptr = value; 4808 else 4809 param->data.charparam.curvalue = value; 4810 4811 /* call the parameter's change information method, unless initializing */ 4812 if( !initialize && param->paramchgd != NULL && set != NULL ) 4813 { 4814 SCIP_RETCODE retcode; 4815 4816 retcode = param->paramchgd(set->scip, param); 4817 4818 if( retcode == SCIP_PARAMETERWRONGVAL ) 4819 { 4820 if( param->data.charparam.valueptr != NULL ) 4821 *param->data.charparam.valueptr = oldvalue; 4822 else 4823 param->data.charparam.curvalue = oldvalue; 4824 } 4825 else 4826 { 4827 SCIP_CALL( retcode ); 4828 } 4829 } 4830 } 4831 4832 if( !quiet ) 4833 { 4834 SCIP_CALL( paramWrite(param, messagehdlr, NULL, FALSE, TRUE) ); 4835 } 4836 4837 return SCIP_OKAY; 4838 } 4839 4840 /** sets value of string parameter */ 4841 SCIP_RETCODE SCIPparamSetString( 4842 SCIP_PARAM* param, /**< parameter */ 4843 SCIP_SET* set, /**< global SCIP settings, or NULL if param change method should not be called */ 4844 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 4845 const char* value, /**< new value of the parameter */ 4846 SCIP_Bool initialize, /**< is this the initialization of the parameter? */ 4847 SCIP_Bool quiet /**< should the parameter be set quiet (no output) */ 4848 ) 4849 { 4850 char* oldvalue = NULL; 4851 4852 assert(param != NULL); 4853 4854 /* check if value is possible for the parameter and the parameter is not fixed */ 4855 SCIP_CALL_QUIET( paramTestString(param, messagehdlr, value) ); 4856 SCIP_CALL_QUIET( paramTestFixed(param, messagehdlr) ); 4857 4858 /* set the parameter's current value */ 4859 if( param->data.stringparam.valueptr != NULL ) 4860 { 4861 if( !initialize ) 4862 oldvalue = *param->data.stringparam.valueptr; 4863 SCIP_ALLOC( BMSduplicateMemoryArray(param->data.stringparam.valueptr, value, strlen(value)+1) ); 4864 } 4865 else 4866 { 4867 if( !initialize ) 4868 oldvalue = param->data.stringparam.curvalue; 4869 SCIP_ALLOC( BMSduplicateMemoryArray(¶m->data.stringparam.curvalue, value, strlen(value)+1) ); 4870 } 4871 4872 /* call the parameter's change information method, unless initializing */ 4873 if( !initialize && param->paramchgd != NULL && set != NULL ) 4874 { 4875 SCIP_RETCODE retcode; 4876 4877 retcode = param->paramchgd(set->scip, param); 4878 4879 if( retcode == SCIP_PARAMETERWRONGVAL ) 4880 { 4881 if( param->data.stringparam.valueptr != NULL ) 4882 { 4883 BMSfreeMemoryArrayNull(param->data.stringparam.valueptr); 4884 *param->data.stringparam.valueptr = oldvalue; 4885 } 4886 else 4887 { 4888 BMSfreeMemoryArrayNull(¶m->data.stringparam.curvalue); 4889 param->data.stringparam.curvalue = oldvalue; 4890 } 4891 } 4892 else 4893 { 4894 BMSfreeMemoryArrayNull(&oldvalue); 4895 SCIP_CALL( retcode ); 4896 } 4897 } 4898 else 4899 { 4900 BMSfreeMemoryArrayNull(&oldvalue); 4901 } 4902 4903 if( !quiet ) 4904 { 4905 SCIP_CALL( paramWrite(param, messagehdlr, NULL, FALSE, TRUE) ); 4906 } 4907 4908 return SCIP_OKAY; 4909 } 4910 4911 /** changes default value of SCIP_Bool parameter */ 4912 void SCIPparamSetDefaultBool( 4913 SCIP_PARAM* param, /**< parameter */ 4914 SCIP_Bool defaultvalue /**< new default value */ 4915 ) 4916 { 4917 assert(param != NULL); 4918 assert(param->paramtype == SCIP_PARAMTYPE_BOOL); 4919 4920 param->data.boolparam.defaultvalue = defaultvalue; 4921 } 4922 4923 /** changes default value of int parameter */ 4924 void SCIPparamSetDefaultInt( 4925 SCIP_PARAM* param, /**< parameter */ 4926 int defaultvalue /**< new default value */ 4927 ) 4928 { 4929 assert(param != NULL); 4930 assert(param->paramtype == SCIP_PARAMTYPE_INT); 4931 4932 assert(param->data.intparam.minvalue <= defaultvalue && param->data.intparam.maxvalue >= defaultvalue); 4933 4934 param->data.intparam.defaultvalue = defaultvalue; 4935 } 4936 4937 /** sets default value of SCIP_Longint parameter */ 4938 void SCIPparamSetDefaultLongint( 4939 SCIP_PARAM* param, /**< parameter */ 4940 SCIP_Longint defaultvalue /**< new default value */ 4941 ) 4942 { 4943 assert(param != NULL); 4944 assert(param->paramtype == SCIP_PARAMTYPE_LONGINT); 4945 4946 assert(param->data.longintparam.minvalue <= defaultvalue && param->data.longintparam.maxvalue >= defaultvalue); 4947 4948 param->data.longintparam.defaultvalue = defaultvalue; 4949 } 4950 4951 /** sets default value of SCIP_Real parameter */ 4952 void SCIPparamSetDefaultReal( 4953 SCIP_PARAM* param, /**< parameter */ 4954 SCIP_Real defaultvalue /**< new default value */ 4955 ) 4956 { 4957 assert(param != NULL); 4958 assert(param->paramtype == SCIP_PARAMTYPE_REAL); 4959 4960 assert(param->data.realparam.minvalue <= defaultvalue && param->data.realparam.maxvalue >= defaultvalue); 4961 4962 param->data.realparam.defaultvalue = defaultvalue; 4963 } 4964 4965 /** sets default value of char parameter */ 4966 void SCIPparamSetDefaultChar( 4967 SCIP_PARAM* param, /**< parameter */ 4968 char defaultvalue /**< new default value */ 4969 ) 4970 { 4971 assert(param != NULL); 4972 assert(param->paramtype == SCIP_PARAMTYPE_CHAR); 4973 4974 param->data.charparam.defaultvalue = defaultvalue; 4975 } 4976 4977 /** sets default value of string parameter */ 4978 void SCIPparamSetDefaultString( 4979 SCIP_PARAM* param, /**< parameter */ 4980 const char* defaultvalue /**< new default value */ 4981 ) 4982 { 4983 assert(param != NULL); 4984 assert(param->paramtype == SCIP_PARAMTYPE_STRING); 4985 4986 BMSfreeMemoryArray(¶m->data.stringparam.defaultvalue); 4987 SCIP_ALLOC_ABORT( BMSduplicateMemoryArray(¶m->data.stringparam.defaultvalue, defaultvalue, strlen(defaultvalue)+1) ); 4988 } 4989 4990 /** sets the parameter to its default setting */ 4991 SCIP_RETCODE SCIPparamSetToDefault( 4992 SCIP_PARAM* param, /**< parameter */ 4993 SCIP_SET* set, /**< global SCIP settings */ 4994 SCIP_MESSAGEHDLR* messagehdlr /**< message handler */ 4995 ) 4996 { 4997 assert(param != NULL); 4998 4999 /* do not change the parameter if it is fixed */ 5000 if( SCIPparamIsFixed(param) ) 5001 { 5002 SCIPsetDebugMsg(set, "parameter <%s> is fixed and is not reset to its default value.\n", param->name); 5003 5004 return SCIP_OKAY; 5005 } 5006 5007 switch( param->paramtype ) 5008 { 5009 case SCIP_PARAMTYPE_BOOL: 5010 SCIP_CALL( SCIPparamSetBool(param, set, messagehdlr, SCIPparamGetBoolDefault(param), FALSE, TRUE) ); 5011 break; 5012 5013 case SCIP_PARAMTYPE_INT: 5014 SCIP_CALL( SCIPparamSetInt(param, set, messagehdlr, SCIPparamGetIntDefault(param), FALSE, TRUE) ); 5015 break; 5016 5017 case SCIP_PARAMTYPE_LONGINT: 5018 SCIP_CALL( SCIPparamSetLongint(param, set, messagehdlr, SCIPparamGetLongintDefault(param), FALSE, TRUE) ); 5019 break; 5020 5021 case SCIP_PARAMTYPE_REAL: 5022 SCIP_CALL( SCIPparamSetReal(param, set, messagehdlr, SCIPparamGetRealDefault(param), FALSE, TRUE) ); 5023 break; 5024 5025 case SCIP_PARAMTYPE_CHAR: 5026 SCIP_CALL( SCIPparamSetChar(param, set, messagehdlr, SCIPparamGetCharDefault(param), FALSE, TRUE) ); 5027 break; 5028 5029 case SCIP_PARAMTYPE_STRING: 5030 SCIP_CALL( SCIPparamSetString(param, set, messagehdlr, SCIPparamGetStringDefault(param), FALSE, TRUE) ); 5031 break; 5032 5033 default: 5034 SCIPerrorMessage("unknown parameter type\n"); 5035 return SCIP_INVALIDDATA; 5036 } 5037 5038 return SCIP_OKAY; 5039 } 5040 5041 /** writes a single parameter to a file */ 5042 SCIP_RETCODE SCIPparamWrite( 5043 SCIP_PARAM* param, /**< parameter */ 5044 SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */ 5045 const char* filename, /**< file name, or NULL for stdout */ 5046 SCIP_Bool comments, /**< should parameter descriptions be written as comments? */ 5047 SCIP_Bool onlychanged /**< should only the parameters been written, that are changed from default? */ 5048 ) 5049 { 5050 SCIP_RETCODE retcode; 5051 FILE* file; 5052 5053 assert(param != NULL); 5054 5055 /* open the file for writing */ 5056 if( filename != NULL ) 5057 { 5058 file = fopen(filename, "w"); 5059 if( file == NULL ) 5060 { 5061 SCIPerrorMessage("cannot open file <%s> for writing\n", filename); 5062 SCIPprintSysError(filename); 5063 return SCIP_FILECREATEERROR; 5064 } 5065 } 5066 else 5067 file = NULL; 5068 5069 /* write the parameter to the file */ 5070 retcode = paramWrite(param, messagehdlr, file, comments, onlychanged); 5071 5072 /* close output file */ 5073 if( filename != NULL ) 5074 { 5075 assert(file != NULL); /*lint !e449*/ 5076 fclose(file); 5077 } 5078 5079 SCIP_CALL( retcode ); 5080 5081 return SCIP_OKAY; 5082 } 5083